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 | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 77 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 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 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 434 | encode_open_maxsz + \ |
| 435 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 436 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 438 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 439 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 440 | decode_open_maxsz + \ |
| 441 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 442 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 443 | #define NFS4_enc_open_confirm_sz \ |
| 444 | (compound_encode_hdr_maxsz + \ |
| 445 | encode_putfh_maxsz + \ |
| 446 | encode_open_confirm_maxsz) |
| 447 | #define NFS4_dec_open_confirm_sz \ |
| 448 | (compound_decode_hdr_maxsz + \ |
| 449 | decode_putfh_maxsz + \ |
| 450 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 452 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 454 | encode_open_maxsz + \ |
| 455 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 457 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 459 | decode_open_maxsz + \ |
| 460 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #define NFS4_enc_open_downgrade_sz \ |
| 462 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 464 | encode_putfh_maxsz + \ |
| 465 | encode_open_downgrade_maxsz + \ |
| 466 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define NFS4_dec_open_downgrade_sz \ |
| 468 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 469 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 470 | decode_putfh_maxsz + \ |
| 471 | decode_open_downgrade_maxsz + \ |
| 472 | decode_getattr_maxsz) |
| 473 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 474 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 475 | encode_putfh_maxsz + \ |
| 476 | encode_close_maxsz + \ |
| 477 | encode_getattr_maxsz) |
| 478 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 479 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 480 | decode_putfh_maxsz + \ |
| 481 | decode_close_maxsz + \ |
| 482 | decode_getattr_maxsz) |
| 483 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 484 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 485 | encode_putfh_maxsz + \ |
| 486 | encode_setattr_maxsz + \ |
| 487 | encode_getattr_maxsz) |
| 488 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 489 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 490 | decode_putfh_maxsz + \ |
| 491 | decode_setattr_maxsz + \ |
| 492 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 494 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | encode_putfh_maxsz + \ |
| 496 | encode_fsinfo_maxsz) |
| 497 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 498 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | decode_putfh_maxsz + \ |
| 500 | decode_fsinfo_maxsz) |
| 501 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 502 | encode_renew_maxsz) |
| 503 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 504 | decode_renew_maxsz) |
| 505 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 506 | encode_setclientid_maxsz) |
| 507 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 508 | decode_setclientid_maxsz) |
| 509 | #define NFS4_enc_setclientid_confirm_sz \ |
| 510 | (compound_encode_hdr_maxsz + \ |
| 511 | encode_setclientid_confirm_maxsz + \ |
| 512 | encode_putrootfh_maxsz + \ |
| 513 | encode_fsinfo_maxsz) |
| 514 | #define NFS4_dec_setclientid_confirm_sz \ |
| 515 | (compound_decode_hdr_maxsz + \ |
| 516 | decode_setclientid_confirm_maxsz + \ |
| 517 | decode_putrootfh_maxsz + \ |
| 518 | decode_fsinfo_maxsz) |
| 519 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 520 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 522 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 524 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 526 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 528 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 530 | encode_lockt_maxsz) |
| 531 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 532 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 533 | decode_putfh_maxsz + \ |
| 534 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 536 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 538 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 540 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 542 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 543 | #define NFS4_enc_release_lockowner_sz \ |
| 544 | (compound_encode_hdr_maxsz + \ |
| 545 | encode_lockowner_maxsz) |
| 546 | #define NFS4_dec_release_lockowner_sz \ |
| 547 | (compound_decode_hdr_maxsz + \ |
| 548 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 550 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 552 | encode_access_maxsz + \ |
| 553 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 555 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 557 | decode_access_maxsz + \ |
| 558 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 560 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | encode_putfh_maxsz + \ |
| 562 | encode_getattr_maxsz) |
| 563 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 564 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | decode_putfh_maxsz + \ |
| 566 | decode_getattr_maxsz) |
| 567 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 568 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | encode_putfh_maxsz + \ |
| 570 | encode_lookup_maxsz + \ |
| 571 | encode_getattr_maxsz + \ |
| 572 | encode_getfh_maxsz) |
| 573 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 574 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 576 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | decode_getattr_maxsz + \ |
| 578 | decode_getfh_maxsz) |
| 579 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 580 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | encode_putrootfh_maxsz + \ |
| 582 | encode_getattr_maxsz + \ |
| 583 | encode_getfh_maxsz) |
| 584 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 585 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | decode_putrootfh_maxsz + \ |
| 587 | decode_getattr_maxsz + \ |
| 588 | decode_getfh_maxsz) |
| 589 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 590 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | encode_putfh_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 592 | encode_remove_maxsz + \ |
| 593 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 595 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | decode_putfh_maxsz + \ |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 597 | decode_remove_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 598 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 600 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | encode_putfh_maxsz + \ |
| 602 | encode_savefh_maxsz + \ |
| 603 | encode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 604 | encode_rename_maxsz + \ |
| 605 | encode_getattr_maxsz + \ |
| 606 | encode_restorefh_maxsz + \ |
| 607 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 609 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | decode_putfh_maxsz + \ |
| 611 | decode_savefh_maxsz + \ |
| 612 | decode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 613 | decode_rename_maxsz + \ |
| 614 | decode_getattr_maxsz + \ |
| 615 | decode_restorefh_maxsz + \ |
| 616 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 618 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | encode_putfh_maxsz + \ |
| 620 | encode_savefh_maxsz + \ |
| 621 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 622 | encode_link_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 623 | encode_getattr_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 624 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 625 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 627 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | decode_putfh_maxsz + \ |
| 629 | decode_savefh_maxsz + \ |
| 630 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 631 | decode_link_maxsz + \ |
| 632 | decode_getattr_maxsz + \ |
| 633 | decode_restorefh_maxsz + \ |
| 634 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 636 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | encode_putfh_maxsz + \ |
| 638 | encode_symlink_maxsz + \ |
| 639 | encode_getattr_maxsz + \ |
| 640 | encode_getfh_maxsz) |
| 641 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 642 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | decode_putfh_maxsz + \ |
| 644 | decode_symlink_maxsz + \ |
| 645 | decode_getattr_maxsz + \ |
| 646 | decode_getfh_maxsz) |
| 647 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 648 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | encode_putfh_maxsz + \ |
| 650 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 651 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 652 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 654 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | decode_putfh_maxsz + \ |
| 656 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 657 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 658 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 660 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | encode_putfh_maxsz + \ |
| 662 | encode_getattr_maxsz) |
| 663 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 664 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | decode_putfh_maxsz + \ |
| 666 | decode_getattr_maxsz) |
| 667 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 668 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 670 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 672 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 674 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 676 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 677 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | encode_getattr_maxsz) |
| 679 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 680 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 681 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | decode_getattr_maxsz) |
| 683 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 686 | encode_delegreturn_maxsz + \ |
| 687 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 689 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 690 | decode_delegreturn_maxsz + \ |
| 691 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 692 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 693 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 694 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 695 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 696 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 697 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 698 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 699 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 700 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 701 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 702 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 703 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 704 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 705 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 706 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 707 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 708 | #define NFS4_enc_fs_locations_sz \ |
| 709 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 710 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 711 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 712 | encode_lookup_maxsz + \ |
| 713 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 714 | #define NFS4_dec_fs_locations_sz \ |
| 715 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 716 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 717 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 718 | decode_lookup_maxsz + \ |
| 719 | decode_fs_locations_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 720 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 721 | encode_sequence_maxsz + \ |
| 722 | encode_putfh_maxsz + \ |
| 723 | encode_secinfo_maxsz) |
| 724 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 725 | decode_sequence_maxsz + \ |
| 726 | decode_putfh_maxsz + \ |
| 727 | decode_secinfo_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 728 | #if defined(CONFIG_NFS_V4_1) |
| 729 | #define NFS4_enc_exchange_id_sz \ |
| 730 | (compound_encode_hdr_maxsz + \ |
| 731 | encode_exchange_id_maxsz) |
| 732 | #define NFS4_dec_exchange_id_sz \ |
| 733 | (compound_decode_hdr_maxsz + \ |
| 734 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 735 | #define NFS4_enc_create_session_sz \ |
| 736 | (compound_encode_hdr_maxsz + \ |
| 737 | encode_create_session_maxsz) |
| 738 | #define NFS4_dec_create_session_sz \ |
| 739 | (compound_decode_hdr_maxsz + \ |
| 740 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 741 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 742 | encode_destroy_session_maxsz) |
| 743 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 744 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 745 | #define NFS4_enc_sequence_sz \ |
| 746 | (compound_decode_hdr_maxsz + \ |
| 747 | encode_sequence_maxsz) |
| 748 | #define NFS4_dec_sequence_sz \ |
| 749 | (compound_decode_hdr_maxsz + \ |
| 750 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 751 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 752 | encode_sequence_maxsz + \ |
| 753 | encode_putrootfh_maxsz + \ |
| 754 | encode_fsinfo_maxsz) |
| 755 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 756 | decode_sequence_maxsz + \ |
| 757 | decode_putrootfh_maxsz + \ |
| 758 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 759 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 760 | encode_sequence_maxsz + \ |
| 761 | encode_reclaim_complete_maxsz) |
| 762 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 763 | decode_sequence_maxsz + \ |
| 764 | decode_reclaim_complete_maxsz) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 765 | #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \ |
| 766 | encode_sequence_maxsz + \ |
| 767 | encode_putfh_maxsz + \ |
| 768 | encode_getdevicelist_maxsz) |
| 769 | #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \ |
| 770 | decode_sequence_maxsz + \ |
| 771 | decode_putfh_maxsz + \ |
| 772 | decode_getdevicelist_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 773 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 774 | encode_sequence_maxsz +\ |
| 775 | encode_getdeviceinfo_maxsz) |
| 776 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 777 | decode_sequence_maxsz + \ |
| 778 | decode_getdeviceinfo_maxsz) |
| 779 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 780 | encode_sequence_maxsz + \ |
| 781 | encode_putfh_maxsz + \ |
| 782 | encode_layoutget_maxsz) |
| 783 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 784 | decode_sequence_maxsz + \ |
| 785 | decode_putfh_maxsz + \ |
| 786 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 787 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 788 | encode_sequence_maxsz +\ |
| 789 | encode_putfh_maxsz + \ |
| 790 | encode_layoutcommit_maxsz + \ |
| 791 | encode_getattr_maxsz) |
| 792 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 793 | decode_sequence_maxsz + \ |
| 794 | decode_putfh_maxsz + \ |
| 795 | decode_layoutcommit_maxsz + \ |
| 796 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 797 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 798 | encode_sequence_maxsz + \ |
| 799 | encode_putfh_maxsz + \ |
| 800 | encode_layoutreturn_maxsz) |
| 801 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 802 | decode_sequence_maxsz + \ |
| 803 | decode_putfh_maxsz + \ |
| 804 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 805 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 806 | encode_sequence_maxsz + \ |
| 807 | encode_putrootfh_maxsz +\ |
| 808 | encode_secinfo_no_name_maxsz) |
| 809 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 810 | decode_sequence_maxsz + \ |
| 811 | decode_putrootfh_maxsz + \ |
| 812 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 813 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 814 | encode_sequence_maxsz + \ |
| 815 | encode_test_stateid_maxsz) |
| 816 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 817 | decode_sequence_maxsz + \ |
| 818 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 819 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 820 | encode_sequence_maxsz + \ |
| 821 | encode_free_stateid_maxsz) |
| 822 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 823 | decode_sequence_maxsz + \ |
| 824 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 825 | |
| 826 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 827 | compound_encode_hdr_maxsz + |
| 828 | encode_sequence_maxsz + |
| 829 | encode_putfh_maxsz + |
| 830 | encode_getattr_maxsz) * |
| 831 | XDR_UNIT); |
| 832 | |
| 833 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 834 | compound_decode_hdr_maxsz + |
| 835 | decode_sequence_maxsz + |
| 836 | decode_putfh_maxsz) * |
| 837 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 838 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 840 | static unsigned short send_implementation_id = 1; |
| 841 | |
| 842 | module_param(send_implementation_id, ushort, 0644); |
| 843 | MODULE_PARM_DESC(send_implementation_id, |
| 844 | "Send implementation ID with NFSv4.1 exchange_id"); |
| 845 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 846 | static const umode_t nfs_type2fmt[] = { |
| 847 | [NF4BAD] = 0, |
| 848 | [NF4REG] = S_IFREG, |
| 849 | [NF4DIR] = S_IFDIR, |
| 850 | [NF4BLK] = S_IFBLK, |
| 851 | [NF4CHR] = S_IFCHR, |
| 852 | [NF4LNK] = S_IFLNK, |
| 853 | [NF4SOCK] = S_IFSOCK, |
| 854 | [NF4FIFO] = S_IFIFO, |
| 855 | [NF4ATTRDIR] = 0, |
| 856 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | }; |
| 858 | |
| 859 | struct compound_hdr { |
| 860 | int32_t status; |
| 861 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 862 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | uint32_t taglen; |
| 864 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 865 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 866 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | }; |
| 868 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 869 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 870 | { |
| 871 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 872 | BUG_ON(!p); |
| 873 | return p; |
| 874 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 876 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 877 | { |
| 878 | __be32 *p; |
| 879 | |
| 880 | p = xdr_reserve_space(xdr, len); |
| 881 | xdr_encode_opaque_fixed(p, buf, len); |
| 882 | } |
| 883 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 885 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 886 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 888 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | xdr_encode_opaque(p, str, len); |
| 890 | } |
| 891 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 892 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 893 | { |
| 894 | __be32 *p; |
| 895 | |
| 896 | p = reserve_space(xdr, 4); |
| 897 | *p = cpu_to_be32(n); |
| 898 | } |
| 899 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 900 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 901 | { |
| 902 | __be32 *p; |
| 903 | |
| 904 | p = reserve_space(xdr, 8); |
| 905 | xdr_encode_hyper(p, n); |
| 906 | } |
| 907 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 908 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 909 | const struct nfs_seqid *seqid) |
| 910 | { |
| 911 | encode_uint32(xdr, seqid->sequence->counter); |
| 912 | } |
| 913 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 914 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 915 | struct rpc_rqst *req, |
| 916 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 918 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 919 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 920 | |
| 921 | /* initialize running count of expected bytes in reply. |
| 922 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 923 | * but this is not required as a MUST for the server to do so. */ |
| 924 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 927 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 928 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 929 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 930 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 931 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 932 | } |
| 933 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 934 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 935 | uint32_t replen, |
| 936 | struct compound_hdr *hdr) |
| 937 | { |
| 938 | encode_uint32(xdr, op); |
| 939 | hdr->nops++; |
| 940 | hdr->replen += replen; |
| 941 | } |
| 942 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 943 | static void encode_nops(struct compound_hdr *hdr) |
| 944 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 945 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 946 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | } |
| 948 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 949 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 950 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 951 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 952 | } |
| 953 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 955 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 956 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | } |
| 958 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 959 | 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] | 960 | { |
| 961 | char owner_name[IDMAP_NAMESZ]; |
| 962 | char owner_group[IDMAP_NAMESZ]; |
| 963 | int owner_namelen = 0; |
| 964 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 965 | __be32 *p; |
| 966 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | int len; |
| 968 | uint32_t bmval0 = 0; |
| 969 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | |
| 971 | /* |
| 972 | * We reserve enough space to write the entire attribute buffer at once. |
| 973 | * In the worst-case, this would be |
| 974 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 975 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 976 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | */ |
| 978 | len = 16; |
| 979 | |
| 980 | /* Sigh */ |
| 981 | if (iap->ia_valid & ATTR_SIZE) |
| 982 | len += 8; |
| 983 | if (iap->ia_valid & ATTR_MODE) |
| 984 | len += 4; |
| 985 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 986 | 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] | 987 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 988 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 989 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | /* XXX */ |
| 991 | strcpy(owner_name, "nobody"); |
| 992 | owner_namelen = sizeof("nobody") - 1; |
| 993 | /* goto out; */ |
| 994 | } |
| 995 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 996 | } |
| 997 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 998 | 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] | 999 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1000 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 1001 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | strcpy(owner_group, "nobody"); |
| 1003 | owner_grouplen = sizeof("nobody") - 1; |
| 1004 | /* goto out; */ |
| 1005 | } |
| 1006 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1007 | } |
| 1008 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 1009 | len += 16; |
| 1010 | else if (iap->ia_valid & ATTR_ATIME) |
| 1011 | len += 4; |
| 1012 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 1013 | len += 16; |
| 1014 | else if (iap->ia_valid & ATTR_MTIME) |
| 1015 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1016 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | |
| 1018 | /* |
| 1019 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 1020 | * buffer length to be backfilled at the end of this routine. |
| 1021 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1022 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | q = p; |
| 1024 | p += 3; |
| 1025 | |
| 1026 | if (iap->ia_valid & ATTR_SIZE) { |
| 1027 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1028 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
| 1030 | if (iap->ia_valid & ATTR_MODE) { |
| 1031 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1032 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | } |
| 1034 | if (iap->ia_valid & ATTR_UID) { |
| 1035 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1036 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | } |
| 1038 | if (iap->ia_valid & ATTR_GID) { |
| 1039 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1040 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | } |
| 1042 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1043 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1044 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1045 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 1046 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 1047 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | } |
| 1049 | else if (iap->ia_valid & ATTR_ATIME) { |
| 1050 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1051 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | } |
| 1053 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1054 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1055 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1056 | *p++ = cpu_to_be32(0); |
| 1057 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 1058 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | } |
| 1060 | else if (iap->ia_valid & ATTR_MTIME) { |
| 1061 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1062 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1064 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | /* |
| 1066 | * Now we backfill the bitmap and the attribute buffer length. |
| 1067 | */ |
| 1068 | if (len != ((char *)p - (char *)q) + 4) { |
Weston Andros Adamson | f9fd2d9 | 2012-01-26 13:32:22 -0500 | [diff] [blame] | 1069 | printk(KERN_ERR "NFS: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | len, ((char *)p - (char *)q) + 4); |
| 1071 | BUG(); |
| 1072 | } |
| 1073 | len = (char *)p - (char *)q - 12; |
| 1074 | *q++ = htonl(bmval0); |
| 1075 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1076 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1081 | 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] | 1082 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1083 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1084 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | } |
| 1086 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1087 | 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] | 1088 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1089 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1090 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1091 | encode_nfs4_stateid(xdr, arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | } |
| 1093 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1094 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1096 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1097 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1098 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1099 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1100 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1101 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1104 | 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] | 1105 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1106 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1107 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1108 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1109 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | |
| 1111 | switch (create->ftype) { |
| 1112 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1113 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1114 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1115 | 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] | 1116 | break; |
| 1117 | |
| 1118 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1119 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1120 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1121 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | break; |
| 1123 | |
| 1124 | default: |
| 1125 | break; |
| 1126 | } |
| 1127 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1128 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1129 | encode_attrs(xdr, create->attrs, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1132 | static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1134 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1136 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1137 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1138 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1139 | *p = cpu_to_be32(bitmap); |
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 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1146 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1147 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | } |
| 1152 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1153 | static void |
| 1154 | encode_getattr_three(struct xdr_stream *xdr, |
| 1155 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1156 | struct compound_hdr *hdr) |
| 1157 | { |
| 1158 | __be32 *p; |
| 1159 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1160 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1161 | if (bm2) { |
| 1162 | p = reserve_space(xdr, 16); |
| 1163 | *p++ = cpu_to_be32(3); |
| 1164 | *p++ = cpu_to_be32(bm0); |
| 1165 | *p++ = cpu_to_be32(bm1); |
| 1166 | *p = cpu_to_be32(bm2); |
| 1167 | } else if (bm1) { |
| 1168 | p = reserve_space(xdr, 12); |
| 1169 | *p++ = cpu_to_be32(2); |
| 1170 | *p++ = cpu_to_be32(bm0); |
| 1171 | *p = cpu_to_be32(bm1); |
| 1172 | } else { |
| 1173 | p = reserve_space(xdr, 8); |
| 1174 | *p++ = cpu_to_be32(1); |
| 1175 | *p = cpu_to_be32(bm0); |
| 1176 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1177 | } |
| 1178 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1179 | 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] | 1180 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1181 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1182 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1185 | 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] | 1186 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1187 | encode_getattr_three(xdr, |
| 1188 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1189 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1190 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1191 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | } |
| 1193 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1194 | 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] | 1195 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1196 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1197 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1198 | } |
| 1199 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1200 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1202 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1205 | 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] | 1206 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1207 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1208 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | } |
| 1210 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1211 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1212 | { |
| 1213 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1214 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1215 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1216 | } |
| 1217 | |
| 1218 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1219 | { |
| 1220 | if (fl->fl_end == OFFSET_MAX) |
| 1221 | return ~(uint64_t)0; |
| 1222 | return fl->fl_end - fl->fl_start + 1; |
| 1223 | } |
| 1224 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1225 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1226 | { |
| 1227 | __be32 *p; |
| 1228 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1229 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1230 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1231 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1232 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1233 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1234 | xdr_encode_hyper(p, lowner->id); |
| 1235 | } |
| 1236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | /* |
| 1238 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1239 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1240 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1241 | 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] | 1242 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1243 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1245 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1246 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1247 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1248 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1249 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1250 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1251 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1252 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1253 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1254 | encode_nfs4_stateid(xdr, args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1255 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1256 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | } |
| 1258 | else { |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1259 | encode_nfs4_stateid(xdr, args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1260 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | } |
| 1263 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1264 | 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] | 1265 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1266 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1268 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1269 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1270 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1271 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1272 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
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 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1276 | 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] | 1277 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1278 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1280 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1281 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1282 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1283 | encode_nfs4_stateid(xdr, args->stateid); |
| 1284 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1285 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1286 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1289 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1290 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1291 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1292 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1293 | } |
| 1294 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1295 | 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] | 1296 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1297 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1298 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1299 | } |
| 1300 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1301 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1303 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1305 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1306 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1307 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1308 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1309 | break; |
| 1310 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1311 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1312 | break; |
| 1313 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1314 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1315 | break; |
| 1316 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1317 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1319 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
| 1322 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1323 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1324 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | /* |
| 1326 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1327 | * owner 4 = 32 |
| 1328 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1329 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1330 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1331 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1332 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1333 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1334 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1335 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1336 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1337 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1341 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1342 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1343 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1345 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1347 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1348 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1349 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1350 | break; |
| 1351 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1352 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1353 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1354 | if (nfs4_has_persistent_session(clp)) { |
| 1355 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1356 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1357 | } else { |
| 1358 | struct iattr dummy; |
| 1359 | |
| 1360 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1361 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1362 | dummy.ia_valid = 0; |
| 1363 | encode_attrs(xdr, &dummy, arg->server); |
| 1364 | } |
| 1365 | } else { |
| 1366 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1367 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1373 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1374 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1376 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1378 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1379 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1380 | break; |
| 1381 | default: |
| 1382 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1383 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1384 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | } |
| 1386 | } |
| 1387 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1388 | 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] | 1389 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1390 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1392 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1394 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1395 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1396 | break; |
| 1397 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1398 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1399 | break; |
| 1400 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1401 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1402 | break; |
| 1403 | default: |
| 1404 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1409 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1410 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1412 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1413 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | encode_string(xdr, name->len, name->name); |
| 1415 | } |
| 1416 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1417 | 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] | 1418 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1419 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1421 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1422 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | encode_delegation_type(xdr, type); |
| 1424 | } |
| 1425 | |
| 1426 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1427 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1428 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1430 | p = reserve_space(xdr, 4); |
| 1431 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1432 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | encode_string(xdr, name->len, name->name); |
| 1434 | } |
| 1435 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1436 | 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] | 1437 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1438 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | encode_openhdr(xdr, arg); |
| 1440 | encode_opentype(xdr, arg); |
| 1441 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1442 | case NFS4_OPEN_CLAIM_NULL: |
| 1443 | encode_claim_null(xdr, arg->name); |
| 1444 | break; |
| 1445 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1446 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1447 | break; |
| 1448 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1449 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1450 | break; |
| 1451 | default: |
| 1452 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | } |
| 1455 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1456 | 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] | 1457 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1458 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1459 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1460 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | } |
| 1462 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1463 | 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] | 1464 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1465 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1466 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1467 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1468 | encode_share_access(xdr, arg->fmode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | } |
| 1470 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1471 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1472 | 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] | 1473 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1474 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1475 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | } |
| 1477 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1478 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1480 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | } |
| 1482 | |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1483 | static void encode_open_stateid(struct xdr_stream *xdr, |
| 1484 | const struct nfs_open_context *ctx, |
| 1485 | const struct nfs_lock_context *l_ctx, |
| 1486 | fmode_t fmode, |
| 1487 | int zero_seqid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | nfs4_stateid stateid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | if (ctx->state != NULL) { |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1492 | nfs4_select_rw_stateid(&stateid, ctx->state, |
| 1493 | fmode, l_ctx->lockowner, l_ctx->pid); |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1494 | if (zero_seqid) |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1495 | stateid.seqid = 0; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1496 | encode_nfs4_stateid(xdr, &stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | } else |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1498 | encode_nfs4_stateid(xdr, &zero_stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | } |
| 1500 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1501 | 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] | 1502 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1503 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1505 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1506 | encode_open_stateid(xdr, args->context, args->lock_context, |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1507 | FMODE_READ, hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1508 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1509 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1510 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1511 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | } |
| 1513 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1514 | 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] | 1515 | { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1516 | uint32_t attrs[2] = { |
| 1517 | FATTR4_WORD0_RDATTR_ERROR, |
| 1518 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1519 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1520 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1521 | __be32 *p, verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1523 | if (readdir->plus) { |
| 1524 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1525 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1526 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1527 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1528 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1529 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1530 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1531 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1532 | /* Use mounted_on_fileid only if the server supports it */ |
| 1533 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1534 | attrs[0] |= FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1535 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1536 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1537 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1538 | encode_nfs4_verifier(xdr, &readdir->verifier); |
| 1539 | p = reserve_space(xdr, 20); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1540 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1541 | *p++ = cpu_to_be32(readdir->count); |
| 1542 | *p++ = cpu_to_be32(2); |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1543 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1544 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1545 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1546 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1547 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1548 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1549 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1550 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1551 | attrs[0] & readdir->bitmask[0], |
| 1552 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1553 | } |
| 1554 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1555 | 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] | 1556 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1557 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | } |
| 1559 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1560 | static void encode_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] | 1561 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1562 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1563 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1566 | static void 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] | 1567 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1568 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1569 | encode_string(xdr, oldname->len, oldname->name); |
| 1570 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | } |
| 1572 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1573 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1574 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1576 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1577 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | } |
| 1579 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1580 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1581 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1582 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1583 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1584 | } |
| 1585 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1586 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1587 | 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] | 1588 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1589 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1590 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1591 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1592 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1593 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1594 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1595 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1596 | BUG_ON(arg->acl_len % 4); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1597 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1598 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1599 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1602 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1603 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1604 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1605 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | } |
| 1607 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1608 | 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] | 1609 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1610 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1611 | encode_nfs4_stateid(xdr, &arg->stateid); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1612 | encode_attrs(xdr, arg->iap, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | } |
| 1614 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1615 | 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] | 1616 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1617 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1618 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1619 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1620 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
| 1622 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1623 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1624 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1626 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1627 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1628 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | } |
| 1630 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1631 | 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] | 1632 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1633 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1634 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1635 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1636 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1637 | } |
| 1638 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1639 | 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] | 1640 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1641 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1643 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1644 | encode_open_stateid(xdr, args->context, args->lock_context, |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1645 | FMODE_WRITE, hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1647 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1648 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1649 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1650 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | |
| 1652 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | } |
| 1654 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1655 | 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] | 1656 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1657 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1658 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1660 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1661 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1662 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1663 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1664 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1665 | } |
| 1666 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1667 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1668 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1669 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1670 | struct nfs41_exchange_id_args *args, |
| 1671 | struct compound_hdr *hdr) |
| 1672 | { |
| 1673 | __be32 *p; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1674 | char impl_name[NFS4_OPAQUE_LIMIT]; |
| 1675 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1676 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1677 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1678 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1679 | |
| 1680 | encode_string(xdr, args->id_len, args->id); |
| 1681 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1682 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1683 | *p++ = cpu_to_be32(args->flags); |
| 1684 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1685 | |
| 1686 | if (send_implementation_id && |
| 1687 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1688 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
| 1689 | <= NFS4_OPAQUE_LIMIT + 1) |
| 1690 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1691 | utsname()->sysname, utsname()->release, |
| 1692 | utsname()->version, utsname()->machine); |
| 1693 | |
| 1694 | if (len > 0) { |
| 1695 | *p = cpu_to_be32(1); /* implementation id array length=1 */ |
| 1696 | |
| 1697 | encode_string(xdr, |
| 1698 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1699 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1700 | encode_string(xdr, len, impl_name); |
| 1701 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1702 | p = reserve_space(xdr, 12); |
| 1703 | p = xdr_encode_hyper(p, 0); |
| 1704 | *p = cpu_to_be32(0); |
| 1705 | } else |
| 1706 | *p = cpu_to_be32(0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1707 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1708 | |
| 1709 | static void encode_create_session(struct xdr_stream *xdr, |
| 1710 | struct nfs41_create_session_args *args, |
| 1711 | struct compound_hdr *hdr) |
| 1712 | { |
| 1713 | __be32 *p; |
| 1714 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1715 | uint32_t len; |
| 1716 | struct nfs_client *clp = args->client; |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1717 | u32 max_resp_sz_cached; |
| 1718 | |
| 1719 | /* |
| 1720 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1721 | * 2 is the verifier. |
| 1722 | */ |
| 1723 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1724 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1725 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1726 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1727 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1728 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1729 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
| 1730 | p = reserve_space(xdr, 16 + 2*28 + 20 + len + 12); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1731 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1732 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1733 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1734 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1735 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1736 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1737 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1738 | *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] | 1739 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1740 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1741 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1742 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1743 | |
| 1744 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1745 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1746 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1747 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1748 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1749 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1750 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1751 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1752 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1753 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1754 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1755 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1756 | |
| 1757 | /* authsys_parms rfc1831 */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1758 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1759 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1760 | *p++ = cpu_to_be32(0); /* UID */ |
| 1761 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1762 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1763 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1764 | |
| 1765 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1766 | struct nfs4_session *session, |
| 1767 | struct compound_hdr *hdr) |
| 1768 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1769 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1770 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1771 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1772 | |
| 1773 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1774 | struct nfs41_reclaim_complete_args *args, |
| 1775 | struct compound_hdr *hdr) |
| 1776 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1777 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1778 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1779 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1780 | #endif /* CONFIG_NFS_V4_1 */ |
| 1781 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1782 | static void encode_sequence(struct xdr_stream *xdr, |
| 1783 | const struct nfs4_sequence_args *args, |
| 1784 | struct compound_hdr *hdr) |
| 1785 | { |
| 1786 | #if defined(CONFIG_NFS_V4_1) |
| 1787 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1788 | struct nfs4_slot_table *tp; |
| 1789 | struct nfs4_slot *slot; |
| 1790 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1791 | |
| 1792 | if (!session) |
| 1793 | return; |
| 1794 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1795 | tp = &session->fc_slot_table; |
| 1796 | |
| 1797 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1798 | slot = tp->slots + args->sa_slotid; |
| 1799 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1800 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1801 | |
| 1802 | /* |
| 1803 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1804 | */ |
| 1805 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1806 | "max_slotid=%d cache_this=%d\n", |
| 1807 | __func__, |
| 1808 | ((u32 *)session->sess_id.data)[0], |
| 1809 | ((u32 *)session->sess_id.data)[1], |
| 1810 | ((u32 *)session->sess_id.data)[2], |
| 1811 | ((u32 *)session->sess_id.data)[3], |
| 1812 | slot->seq_nr, args->sa_slotid, |
| 1813 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1814 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1815 | 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] | 1816 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1817 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1818 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1819 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1820 | #endif /* CONFIG_NFS_V4_1 */ |
| 1821 | } |
| 1822 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1823 | #ifdef CONFIG_NFS_V4_1 |
| 1824 | static void |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1825 | encode_getdevicelist(struct xdr_stream *xdr, |
| 1826 | const struct nfs4_getdevicelist_args *args, |
| 1827 | struct compound_hdr *hdr) |
| 1828 | { |
| 1829 | __be32 *p; |
| 1830 | nfs4_verifier dummy = { |
| 1831 | .data = "dummmmmy", |
| 1832 | }; |
| 1833 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1834 | encode_op_hdr(xdr, OP_GETDEVICELIST, decode_getdevicelist_maxsz, hdr); |
| 1835 | p = reserve_space(xdr, 16); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1836 | *p++ = cpu_to_be32(args->layoutclass); |
| 1837 | *p++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM); |
| 1838 | xdr_encode_hyper(p, 0ULL); /* cookie */ |
| 1839 | encode_nfs4_verifier(xdr, &dummy); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1840 | } |
| 1841 | |
| 1842 | static void |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1843 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1844 | const struct nfs4_getdeviceinfo_args *args, |
| 1845 | struct compound_hdr *hdr) |
| 1846 | { |
| 1847 | __be32 *p; |
| 1848 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1849 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
| 1850 | p = reserve_space(xdr, 12 + NFS4_DEVICEID4_SIZE); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1851 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1852 | NFS4_DEVICEID4_SIZE); |
| 1853 | *p++ = cpu_to_be32(args->pdev->layout_type); |
| 1854 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ |
| 1855 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1856 | } |
| 1857 | |
| 1858 | static void |
| 1859 | encode_layoutget(struct xdr_stream *xdr, |
| 1860 | const struct nfs4_layoutget_args *args, |
| 1861 | struct compound_hdr *hdr) |
| 1862 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1863 | __be32 *p; |
| 1864 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1865 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1866 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1867 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1868 | *p++ = cpu_to_be32(args->type); |
| 1869 | *p++ = cpu_to_be32(args->range.iomode); |
| 1870 | p = xdr_encode_hyper(p, args->range.offset); |
| 1871 | p = xdr_encode_hyper(p, args->range.length); |
| 1872 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1873 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1874 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1875 | |
| 1876 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1877 | __func__, |
| 1878 | args->type, |
| 1879 | args->range.iomode, |
| 1880 | (unsigned long)args->range.offset, |
| 1881 | (unsigned long)args->range.length, |
| 1882 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1883 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1884 | |
| 1885 | static int |
| 1886 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1887 | struct inode *inode, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1888 | const struct nfs4_layoutcommit_args *args, |
| 1889 | struct compound_hdr *hdr) |
| 1890 | { |
| 1891 | __be32 *p; |
| 1892 | |
| 1893 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1894 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1895 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1896 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1897 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1898 | /* Only whole file layouts */ |
| 1899 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1900 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1901 | *p = cpu_to_be32(0); /* reclaim */ |
| 1902 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1903 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1904 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1905 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1906 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1907 | *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] | 1908 | |
| 1909 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) |
| 1910 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1911 | NFS_I(inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1912 | else |
| 1913 | encode_uint32(xdr, 0); /* no layout-type payload */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1914 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1915 | return 0; |
| 1916 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1917 | |
| 1918 | static void |
| 1919 | encode_layoutreturn(struct xdr_stream *xdr, |
| 1920 | const struct nfs4_layoutreturn_args *args, |
| 1921 | struct compound_hdr *hdr) |
| 1922 | { |
| 1923 | __be32 *p; |
| 1924 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1925 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 1926 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1927 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 1928 | *p++ = cpu_to_be32(args->layout_type); |
| 1929 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 1930 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1931 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1932 | p = xdr_encode_hyper(p, 0); |
| 1933 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 1934 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1935 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1936 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 1937 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 1938 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 1939 | NFS_I(args->inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1940 | } else |
| 1941 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1942 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 1943 | |
| 1944 | static int |
| 1945 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 1946 | const struct nfs41_secinfo_no_name_args *args, |
| 1947 | struct compound_hdr *hdr) |
| 1948 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1949 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 1950 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 1951 | return 0; |
| 1952 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 1953 | |
| 1954 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 1955 | struct nfs41_test_stateid_args *args, |
| 1956 | struct compound_hdr *hdr) |
| 1957 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1958 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 1959 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1960 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 1961 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 1962 | |
| 1963 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 1964 | struct nfs41_free_stateid_args *args, |
| 1965 | struct compound_hdr *hdr) |
| 1966 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1967 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1968 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 1969 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1970 | #endif /* CONFIG_NFS_V4_1 */ |
| 1971 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | /* |
| 1973 | * END OF "GENERIC" ENCODE ROUTINES. |
| 1974 | */ |
| 1975 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1976 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 1977 | { |
| 1978 | #if defined(CONFIG_NFS_V4_1) |
| 1979 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1980 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1981 | #endif /* CONFIG_NFS_V4_1 */ |
| 1982 | return 0; |
| 1983 | } |
| 1984 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1985 | /* |
| 1986 | * Encode an ACCESS request |
| 1987 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1988 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 1989 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1992 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1993 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1994 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1995 | encode_compound_hdr(xdr, req, &hdr); |
| 1996 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 1997 | encode_putfh(xdr, args->fh, &hdr); |
| 1998 | encode_access(xdr, args->access, &hdr); |
| 1999 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2000 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | } |
| 2002 | |
| 2003 | /* |
| 2004 | * Encode LOOKUP request |
| 2005 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2006 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2007 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2009 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2010 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2011 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2012 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2013 | encode_compound_hdr(xdr, req, &hdr); |
| 2014 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2015 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2016 | encode_lookup(xdr, args->name, &hdr); |
| 2017 | encode_getfh(xdr, &hdr); |
| 2018 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2019 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | } |
| 2021 | |
| 2022 | /* |
| 2023 | * Encode LOOKUP_ROOT request |
| 2024 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2025 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2026 | struct xdr_stream *xdr, |
| 2027 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2030 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2033 | encode_compound_hdr(xdr, req, &hdr); |
| 2034 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2035 | encode_putrootfh(xdr, &hdr); |
| 2036 | encode_getfh(xdr, &hdr); |
| 2037 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2038 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | } |
| 2040 | |
| 2041 | /* |
| 2042 | * Encode REMOVE request |
| 2043 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2044 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2045 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2046 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2048 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2051 | encode_compound_hdr(xdr, req, &hdr); |
| 2052 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2053 | encode_putfh(xdr, args->fh, &hdr); |
| 2054 | encode_remove(xdr, &args->name, &hdr); |
| 2055 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2056 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | } |
| 2058 | |
| 2059 | /* |
| 2060 | * Encode RENAME request |
| 2061 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2062 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2063 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2066 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2069 | encode_compound_hdr(xdr, req, &hdr); |
| 2070 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2071 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2072 | encode_savefh(xdr, &hdr); |
| 2073 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2074 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
| 2075 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2076 | encode_restorefh(xdr, &hdr); |
| 2077 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2078 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | } |
| 2080 | |
| 2081 | /* |
| 2082 | * Encode LINK request |
| 2083 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2084 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2085 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2088 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2091 | encode_compound_hdr(xdr, req, &hdr); |
| 2092 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2093 | encode_putfh(xdr, args->fh, &hdr); |
| 2094 | encode_savefh(xdr, &hdr); |
| 2095 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2096 | encode_link(xdr, args->name, &hdr); |
| 2097 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2098 | encode_restorefh(xdr, &hdr); |
| 2099 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2100 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | } |
| 2102 | |
| 2103 | /* |
| 2104 | * Encode CREATE request |
| 2105 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2106 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2107 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2110 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2113 | encode_compound_hdr(xdr, req, &hdr); |
| 2114 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2115 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2116 | encode_create(xdr, args, &hdr); |
| 2117 | encode_getfh(xdr, &hdr); |
| 2118 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2119 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | } |
| 2121 | |
| 2122 | /* |
| 2123 | * Encode SYMLINK request |
| 2124 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2125 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2126 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2128 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | } |
| 2130 | |
| 2131 | /* |
| 2132 | * Encode GETATTR request |
| 2133 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2134 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2135 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2138 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2141 | encode_compound_hdr(xdr, req, &hdr); |
| 2142 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2143 | encode_putfh(xdr, args->fh, &hdr); |
| 2144 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2145 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2146 | } |
| 2147 | |
| 2148 | /* |
| 2149 | * Encode a CLOSE request |
| 2150 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2151 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2152 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2154 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2155 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2156 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2158 | encode_compound_hdr(xdr, req, &hdr); |
| 2159 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2160 | encode_putfh(xdr, args->fh, &hdr); |
| 2161 | encode_close(xdr, args, &hdr); |
| 2162 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2163 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | } |
| 2165 | |
| 2166 | /* |
| 2167 | * Encode an OPEN request |
| 2168 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2169 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2170 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2173 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2174 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2176 | encode_compound_hdr(xdr, req, &hdr); |
| 2177 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2178 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2179 | encode_open(xdr, args, &hdr); |
| 2180 | encode_getfh(xdr, &hdr); |
| 2181 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2182 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2183 | } |
| 2184 | |
| 2185 | /* |
| 2186 | * Encode an OPEN_CONFIRM request |
| 2187 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2188 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2189 | struct xdr_stream *xdr, |
| 2190 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2193 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2194 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2196 | encode_compound_hdr(xdr, req, &hdr); |
| 2197 | encode_putfh(xdr, args->fh, &hdr); |
| 2198 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2199 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | /* |
| 2203 | * Encode an OPEN request with no attributes. |
| 2204 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2205 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2206 | struct xdr_stream *xdr, |
| 2207 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2210 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2213 | encode_compound_hdr(xdr, req, &hdr); |
| 2214 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2215 | encode_putfh(xdr, args->fh, &hdr); |
| 2216 | encode_open(xdr, args, &hdr); |
| 2217 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2218 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | /* |
| 2222 | * Encode an OPEN_DOWNGRADE request |
| 2223 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2224 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2225 | struct xdr_stream *xdr, |
| 2226 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2229 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2232 | encode_compound_hdr(xdr, req, &hdr); |
| 2233 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2234 | encode_putfh(xdr, args->fh, &hdr); |
| 2235 | encode_open_downgrade(xdr, args, &hdr); |
| 2236 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2237 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | } |
| 2239 | |
| 2240 | /* |
| 2241 | * Encode a LOCK request |
| 2242 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2243 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2244 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2247 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2250 | encode_compound_hdr(xdr, req, &hdr); |
| 2251 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2252 | encode_putfh(xdr, args->fh, &hdr); |
| 2253 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2254 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | } |
| 2256 | |
| 2257 | /* |
| 2258 | * Encode a LOCKT request |
| 2259 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2260 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2261 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2263 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2264 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2267 | encode_compound_hdr(xdr, req, &hdr); |
| 2268 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2269 | encode_putfh(xdr, args->fh, &hdr); |
| 2270 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2271 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | } |
| 2273 | |
| 2274 | /* |
| 2275 | * Encode a LOCKU request |
| 2276 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2277 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2278 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2281 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2284 | encode_compound_hdr(xdr, req, &hdr); |
| 2285 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2286 | encode_putfh(xdr, args->fh, &hdr); |
| 2287 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2288 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2289 | } |
| 2290 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2291 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2292 | struct xdr_stream *xdr, |
| 2293 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2294 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2295 | struct compound_hdr hdr = { |
| 2296 | .minorversion = 0, |
| 2297 | }; |
| 2298 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2299 | encode_compound_hdr(xdr, req, &hdr); |
| 2300 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2301 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2302 | } |
| 2303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | /* |
| 2305 | * Encode a READLINK request |
| 2306 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2307 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2308 | const struct nfs4_readlink *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 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2311 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2314 | encode_compound_hdr(xdr, req, &hdr); |
| 2315 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2316 | encode_putfh(xdr, args->fh, &hdr); |
| 2317 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2318 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2319 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2320 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2321 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | } |
| 2323 | |
| 2324 | /* |
| 2325 | * Encode a READDIR request |
| 2326 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2327 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2328 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2331 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2334 | encode_compound_hdr(xdr, req, &hdr); |
| 2335 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2336 | encode_putfh(xdr, args->fh, &hdr); |
| 2337 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2338 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2339 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2340 | args->pgbase, args->count); |
| 2341 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2342 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2343 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2344 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | /* |
| 2348 | * Encode a READ request |
| 2349 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2350 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2351 | struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2354 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2357 | encode_compound_hdr(xdr, req, &hdr); |
| 2358 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2359 | encode_putfh(xdr, args->fh, &hdr); |
| 2360 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2362 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2364 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2365 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | } |
| 2367 | |
| 2368 | /* |
| 2369 | * Encode an SETATTR request |
| 2370 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2371 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2372 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2374 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2375 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2376 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2377 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2378 | encode_compound_hdr(xdr, req, &hdr); |
| 2379 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2380 | encode_putfh(xdr, args->fh, &hdr); |
| 2381 | encode_setattr(xdr, args, args->server, &hdr); |
| 2382 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2383 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2384 | } |
| 2385 | |
| 2386 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2387 | * Encode a GETACL request |
| 2388 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2389 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2390 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2391 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2392 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2393 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2394 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2395 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2396 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2397 | encode_compound_hdr(xdr, req, &hdr); |
| 2398 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2399 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2400 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2401 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2402 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2403 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2404 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2405 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2406 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2407 | } |
| 2408 | |
| 2409 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2410 | * Encode a WRITE request |
| 2411 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2412 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2413 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2415 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2416 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2418 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2419 | encode_compound_hdr(xdr, req, &hdr); |
| 2420 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2421 | encode_putfh(xdr, args->fh, &hdr); |
| 2422 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2423 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2424 | if (args->bitmask) |
| 2425 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2426 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2427 | } |
| 2428 | |
| 2429 | /* |
| 2430 | * a COMMIT request |
| 2431 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2432 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 2433 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2436 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2439 | encode_compound_hdr(xdr, req, &hdr); |
| 2440 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2441 | encode_putfh(xdr, args->fh, &hdr); |
| 2442 | encode_commit(xdr, args, &hdr); |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 2443 | if (args->bitmask) |
| 2444 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2445 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2446 | } |
| 2447 | |
| 2448 | /* |
| 2449 | * FSINFO request |
| 2450 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2451 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2452 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2454 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2455 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2458 | encode_compound_hdr(xdr, req, &hdr); |
| 2459 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2460 | encode_putfh(xdr, args->fh, &hdr); |
| 2461 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2462 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | /* |
| 2466 | * a PATHCONF request |
| 2467 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2468 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2469 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2472 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2474 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2475 | encode_compound_hdr(xdr, req, &hdr); |
| 2476 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2477 | encode_putfh(xdr, args->fh, &hdr); |
| 2478 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2479 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2480 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2481 | } |
| 2482 | |
| 2483 | /* |
| 2484 | * a STATFS request |
| 2485 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2486 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2487 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2488 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2490 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2491 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2493 | encode_compound_hdr(xdr, req, &hdr); |
| 2494 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2495 | encode_putfh(xdr, args->fh, &hdr); |
| 2496 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2497 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2498 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | } |
| 2500 | |
| 2501 | /* |
| 2502 | * GETATTR_BITMAP request |
| 2503 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2504 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2505 | struct xdr_stream *xdr, |
| 2506 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2507 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2508 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2509 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2512 | encode_compound_hdr(xdr, req, &hdr); |
| 2513 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2514 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2515 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2516 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2517 | FATTR4_WORD0_LINK_SUPPORT| |
| 2518 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2519 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2520 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | } |
| 2522 | |
| 2523 | /* |
| 2524 | * a RENEW request |
| 2525 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2526 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2527 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2529 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2530 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | }; |
| 2532 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2533 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2534 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2535 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | } |
| 2537 | |
| 2538 | /* |
| 2539 | * a SETCLIENTID request |
| 2540 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2541 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2542 | struct xdr_stream *xdr, |
| 2543 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2546 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | }; |
| 2548 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2549 | encode_compound_hdr(xdr, req, &hdr); |
| 2550 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2551 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2552 | } |
| 2553 | |
| 2554 | /* |
| 2555 | * a SETCLIENTID_CONFIRM request |
| 2556 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2557 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2558 | struct xdr_stream *xdr, |
| 2559 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2562 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2564 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2565 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2566 | encode_compound_hdr(xdr, req, &hdr); |
| 2567 | encode_setclientid_confirm(xdr, arg, &hdr); |
| 2568 | encode_putrootfh(xdr, &hdr); |
| 2569 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2570 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | /* |
| 2574 | * DELEGRETURN request |
| 2575 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2576 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2577 | struct xdr_stream *xdr, |
| 2578 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2580 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2581 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2584 | encode_compound_hdr(xdr, req, &hdr); |
| 2585 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2586 | encode_putfh(xdr, args->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2587 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2588 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2589 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | } |
| 2591 | |
| 2592 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2593 | * Encode FS_LOCATIONS request |
| 2594 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2595 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2596 | struct xdr_stream *xdr, |
| 2597 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2598 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2599 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2600 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2601 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2602 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2603 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2604 | encode_compound_hdr(xdr, req, &hdr); |
| 2605 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2606 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2607 | encode_lookup(xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2608 | replen = hdr.replen; /* get the attribute into args->page */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2609 | encode_fs_locations(xdr, args->bitmask, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2610 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2611 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2612 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2613 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2614 | } |
| 2615 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2616 | /* |
| 2617 | * Encode SECINFO request |
| 2618 | */ |
| 2619 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2620 | struct xdr_stream *xdr, |
| 2621 | struct nfs4_secinfo_arg *args) |
| 2622 | { |
| 2623 | struct compound_hdr hdr = { |
| 2624 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2625 | }; |
| 2626 | |
| 2627 | encode_compound_hdr(xdr, req, &hdr); |
| 2628 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2629 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2630 | encode_secinfo(xdr, args->name, &hdr); |
| 2631 | encode_nops(&hdr); |
| 2632 | } |
| 2633 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2634 | #if defined(CONFIG_NFS_V4_1) |
| 2635 | /* |
| 2636 | * EXCHANGE_ID request |
| 2637 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2638 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2639 | struct xdr_stream *xdr, |
| 2640 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2641 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2642 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2643 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2644 | }; |
| 2645 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2646 | encode_compound_hdr(xdr, req, &hdr); |
| 2647 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2648 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2649 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2650 | |
| 2651 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2652 | * a CREATE_SESSION request |
| 2653 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2654 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2655 | struct xdr_stream *xdr, |
| 2656 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2657 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2658 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2659 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2660 | }; |
| 2661 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2662 | encode_compound_hdr(xdr, req, &hdr); |
| 2663 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2664 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2665 | } |
| 2666 | |
| 2667 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2668 | * a DESTROY_SESSION request |
| 2669 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2670 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2671 | struct xdr_stream *xdr, |
| 2672 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2673 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2674 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2675 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2676 | }; |
| 2677 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2678 | encode_compound_hdr(xdr, req, &hdr); |
| 2679 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2680 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2681 | } |
| 2682 | |
| 2683 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2684 | * a SEQUENCE request |
| 2685 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2686 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2687 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2688 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2689 | struct compound_hdr hdr = { |
| 2690 | .minorversion = nfs4_xdr_minorversion(args), |
| 2691 | }; |
| 2692 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2693 | encode_compound_hdr(xdr, req, &hdr); |
| 2694 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2695 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2699 | * a GET_LEASE_TIME request |
| 2700 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2701 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2702 | struct xdr_stream *xdr, |
| 2703 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2704 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2705 | struct compound_hdr hdr = { |
| 2706 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2707 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2708 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2709 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2710 | encode_compound_hdr(xdr, req, &hdr); |
| 2711 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2712 | encode_putrootfh(xdr, &hdr); |
| 2713 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2714 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2715 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2716 | |
| 2717 | /* |
| 2718 | * a RECLAIM_COMPLETE request |
| 2719 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2720 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2721 | struct xdr_stream *xdr, |
| 2722 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2723 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2724 | struct compound_hdr hdr = { |
| 2725 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2726 | }; |
| 2727 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2728 | encode_compound_hdr(xdr, req, &hdr); |
| 2729 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2730 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2731 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2732 | } |
| 2733 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2734 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 2735 | * Encode GETDEVICELIST request |
| 2736 | */ |
| 2737 | static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst *req, |
| 2738 | struct xdr_stream *xdr, |
| 2739 | struct nfs4_getdevicelist_args *args) |
| 2740 | { |
| 2741 | struct compound_hdr hdr = { |
| 2742 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2743 | }; |
| 2744 | |
| 2745 | encode_compound_hdr(xdr, req, &hdr); |
| 2746 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2747 | encode_putfh(xdr, args->fh, &hdr); |
| 2748 | encode_getdevicelist(xdr, args, &hdr); |
| 2749 | encode_nops(&hdr); |
| 2750 | } |
| 2751 | |
| 2752 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2753 | * Encode GETDEVICEINFO request |
| 2754 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2755 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2756 | struct xdr_stream *xdr, |
| 2757 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2758 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2759 | struct compound_hdr hdr = { |
| 2760 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2761 | }; |
| 2762 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2763 | encode_compound_hdr(xdr, req, &hdr); |
| 2764 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2765 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2766 | |
| 2767 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2768 | * so that notification bitmap is put in xdr_buf tail */ |
| 2769 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2770 | args->pdev->pages, args->pdev->pgbase, |
| 2771 | args->pdev->pglen); |
| 2772 | |
| 2773 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2774 | } |
| 2775 | |
| 2776 | /* |
| 2777 | * Encode LAYOUTGET request |
| 2778 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2779 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2780 | struct xdr_stream *xdr, |
| 2781 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2782 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2783 | struct compound_hdr hdr = { |
| 2784 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2785 | }; |
| 2786 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2787 | encode_compound_hdr(xdr, req, &hdr); |
| 2788 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2789 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2790 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2791 | |
| 2792 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2793 | args->layout.pages, 0, args->layout.pglen); |
| 2794 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2795 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2796 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2797 | |
| 2798 | /* |
| 2799 | * Encode LAYOUTCOMMIT request |
| 2800 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2801 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2802 | struct xdr_stream *xdr, |
| 2803 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2804 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2805 | struct nfs4_layoutcommit_data *data = |
| 2806 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2807 | struct compound_hdr hdr = { |
| 2808 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2809 | }; |
| 2810 | |
| 2811 | encode_compound_hdr(xdr, req, &hdr); |
| 2812 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2813 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2814 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2815 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2816 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2817 | } |
| 2818 | |
| 2819 | /* |
| 2820 | * Encode LAYOUTRETURN request |
| 2821 | */ |
| 2822 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2823 | struct xdr_stream *xdr, |
| 2824 | struct nfs4_layoutreturn_args *args) |
| 2825 | { |
| 2826 | struct compound_hdr hdr = { |
| 2827 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2828 | }; |
| 2829 | |
| 2830 | encode_compound_hdr(xdr, req, &hdr); |
| 2831 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2832 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2833 | encode_layoutreturn(xdr, args, &hdr); |
| 2834 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2835 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2836 | |
| 2837 | /* |
| 2838 | * Encode SECINFO_NO_NAME request |
| 2839 | */ |
| 2840 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2841 | struct xdr_stream *xdr, |
| 2842 | struct nfs41_secinfo_no_name_args *args) |
| 2843 | { |
| 2844 | struct compound_hdr hdr = { |
| 2845 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2846 | }; |
| 2847 | |
| 2848 | encode_compound_hdr(xdr, req, &hdr); |
| 2849 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2850 | encode_putrootfh(xdr, &hdr); |
| 2851 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2852 | encode_nops(&hdr); |
| 2853 | return 0; |
| 2854 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2855 | |
| 2856 | /* |
| 2857 | * Encode TEST_STATEID request |
| 2858 | */ |
| 2859 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2860 | struct xdr_stream *xdr, |
| 2861 | struct nfs41_test_stateid_args *args) |
| 2862 | { |
| 2863 | struct compound_hdr hdr = { |
| 2864 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2865 | }; |
| 2866 | |
| 2867 | encode_compound_hdr(xdr, req, &hdr); |
| 2868 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2869 | encode_test_stateid(xdr, args, &hdr); |
| 2870 | encode_nops(&hdr); |
| 2871 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2872 | |
| 2873 | /* |
| 2874 | * Encode FREE_STATEID request |
| 2875 | */ |
| 2876 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2877 | struct xdr_stream *xdr, |
| 2878 | struct nfs41_free_stateid_args *args) |
| 2879 | { |
| 2880 | struct compound_hdr hdr = { |
| 2881 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2882 | }; |
| 2883 | |
| 2884 | encode_compound_hdr(xdr, req, &hdr); |
| 2885 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2886 | encode_free_stateid(xdr, args, &hdr); |
| 2887 | encode_nops(&hdr); |
| 2888 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2889 | #endif /* CONFIG_NFS_V4_1 */ |
| 2890 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 2891 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 2892 | { |
| 2893 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 2894 | "Remaining buffer length is %tu words.\n", |
| 2895 | func, xdr->end - xdr->p); |
| 2896 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2898 | 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] | 2899 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2900 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2902 | p = xdr_inline_decode(xdr, 4); |
| 2903 | if (unlikely(!p)) |
| 2904 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2905 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2906 | p = xdr_inline_decode(xdr, *len); |
| 2907 | if (unlikely(!p)) |
| 2908 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2909 | *string = (char *)p; |
| 2910 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2911 | out_overflow: |
| 2912 | print_overflow_msg(__func__, xdr); |
| 2913 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2914 | } |
| 2915 | |
| 2916 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 2917 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2918 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2919 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2920 | p = xdr_inline_decode(xdr, 8); |
| 2921 | if (unlikely(!p)) |
| 2922 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2923 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2924 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2925 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2926 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 2927 | if (unlikely(!p)) |
| 2928 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2929 | hdr->tag = (char *)p; |
| 2930 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2931 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 2932 | if (unlikely(hdr->nops < 1)) |
| 2933 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2935 | out_overflow: |
| 2936 | print_overflow_msg(__func__, xdr); |
| 2937 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2938 | } |
| 2939 | |
| 2940 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 2941 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2942 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2943 | uint32_t opnum; |
| 2944 | int32_t nfserr; |
| 2945 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2946 | p = xdr_inline_decode(xdr, 8); |
| 2947 | if (unlikely(!p)) |
| 2948 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2949 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2950 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 2951 | dprintk("nfs: Server returned operation" |
| 2952 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | opnum, expected); |
| 2954 | return -EIO; |
| 2955 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2956 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2957 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 2958 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2959 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2960 | out_overflow: |
| 2961 | print_overflow_msg(__func__, xdr); |
| 2962 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 2966 | 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] | 2967 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2968 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2969 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2970 | char *str; |
| 2971 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2972 | p = xdr_inline_decode(xdr, 12); |
| 2973 | if (likely(p)) |
| 2974 | return decode_opaque_inline(xdr, &strlen, &str); |
| 2975 | print_overflow_msg(__func__, xdr); |
| 2976 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | } |
| 2978 | |
| 2979 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 2980 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2981 | uint32_t bmlen; |
| 2982 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2983 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2984 | p = xdr_inline_decode(xdr, 4); |
| 2985 | if (unlikely(!p)) |
| 2986 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2987 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2989 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2990 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 2991 | if (unlikely(!p)) |
| 2992 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2994 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2995 | if (bmlen > 1) { |
| 2996 | bitmap[1] = be32_to_cpup(p++); |
| 2997 | if (bmlen > 2) |
| 2998 | bitmap[2] = be32_to_cpup(p); |
| 2999 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3000 | } |
| 3001 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3002 | out_overflow: |
| 3003 | print_overflow_msg(__func__, xdr); |
| 3004 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3005 | } |
| 3006 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3007 | 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] | 3008 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3009 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3010 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3011 | p = xdr_inline_decode(xdr, 4); |
| 3012 | if (unlikely(!p)) |
| 3013 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3014 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3015 | *savep = xdr->p; |
| 3016 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3017 | out_overflow: |
| 3018 | print_overflow_msg(__func__, xdr); |
| 3019 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3020 | } |
| 3021 | |
| 3022 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3023 | { |
| 3024 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3025 | int ret; |
| 3026 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3027 | if (unlikely(ret < 0)) |
| 3028 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3030 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3031 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3032 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3033 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | return 0; |
| 3035 | } |
| 3036 | |
| 3037 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3038 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3039 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3040 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | |
| 3042 | *type = 0; |
| 3043 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3044 | return -EIO; |
| 3045 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3046 | p = xdr_inline_decode(xdr, 4); |
| 3047 | if (unlikely(!p)) |
| 3048 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3049 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3050 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3051 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | return -EIO; |
| 3053 | } |
| 3054 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3055 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3057 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3058 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3059 | out_overflow: |
| 3060 | print_overflow_msg(__func__, xdr); |
| 3061 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3062 | } |
| 3063 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3064 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3065 | uint32_t *bitmap, uint32_t *type) |
| 3066 | { |
| 3067 | __be32 *p; |
| 3068 | |
| 3069 | *type = 0; |
| 3070 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3071 | return -EIO; |
| 3072 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3073 | p = xdr_inline_decode(xdr, 4); |
| 3074 | if (unlikely(!p)) |
| 3075 | goto out_overflow; |
| 3076 | *type = be32_to_cpup(p); |
| 3077 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3078 | } |
| 3079 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3080 | return 0; |
| 3081 | out_overflow: |
| 3082 | print_overflow_msg(__func__, xdr); |
| 3083 | return -EIO; |
| 3084 | } |
| 3085 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3086 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3087 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3088 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3089 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3090 | |
| 3091 | *change = 0; |
| 3092 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3093 | return -EIO; |
| 3094 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3095 | p = xdr_inline_decode(xdr, 8); |
| 3096 | if (unlikely(!p)) |
| 3097 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3098 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3100 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3101 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3102 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3103 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3104 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3105 | out_overflow: |
| 3106 | print_overflow_msg(__func__, xdr); |
| 3107 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3108 | } |
| 3109 | |
| 3110 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3111 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3112 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3113 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3114 | |
| 3115 | *size = 0; |
| 3116 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3117 | return -EIO; |
| 3118 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
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 | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3122 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3123 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3124 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3125 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3126 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3127 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3128 | out_overflow: |
| 3129 | print_overflow_msg(__func__, xdr); |
| 3130 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3131 | } |
| 3132 | |
| 3133 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3134 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3135 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | |
| 3137 | *res = 0; |
| 3138 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3139 | return -EIO; |
| 3140 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3141 | p = xdr_inline_decode(xdr, 4); |
| 3142 | if (unlikely(!p)) |
| 3143 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3144 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3145 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3146 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3147 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3148 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3149 | out_overflow: |
| 3150 | print_overflow_msg(__func__, xdr); |
| 3151 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3152 | } |
| 3153 | |
| 3154 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3155 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3156 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | |
| 3158 | *res = 0; |
| 3159 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3160 | return -EIO; |
| 3161 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3162 | p = xdr_inline_decode(xdr, 4); |
| 3163 | if (unlikely(!p)) |
| 3164 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3165 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3167 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3168 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3169 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3170 | out_overflow: |
| 3171 | print_overflow_msg(__func__, xdr); |
| 3172 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3173 | } |
| 3174 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3175 | 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] | 3176 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3177 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3178 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3179 | |
| 3180 | fsid->major = 0; |
| 3181 | fsid->minor = 0; |
| 3182 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3183 | return -EIO; |
| 3184 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3185 | p = xdr_inline_decode(xdr, 16); |
| 3186 | if (unlikely(!p)) |
| 3187 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3188 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3189 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3190 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3191 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3192 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3193 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3194 | (unsigned long long)fsid->major, |
| 3195 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3196 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3197 | out_overflow: |
| 3198 | print_overflow_msg(__func__, xdr); |
| 3199 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3203 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3204 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3205 | |
| 3206 | *res = 60; |
| 3207 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3208 | return -EIO; |
| 3209 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3210 | p = xdr_inline_decode(xdr, 4); |
| 3211 | if (unlikely(!p)) |
| 3212 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3213 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3215 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3216 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3217 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3218 | out_overflow: |
| 3219 | print_overflow_msg(__func__, xdr); |
| 3220 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3221 | } |
| 3222 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3223 | 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] | 3224 | { |
| 3225 | __be32 *p; |
| 3226 | |
| 3227 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3228 | return -EIO; |
| 3229 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3230 | p = xdr_inline_decode(xdr, 4); |
| 3231 | if (unlikely(!p)) |
| 3232 | goto out_overflow; |
| 3233 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3234 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3235 | } |
| 3236 | return 0; |
| 3237 | out_overflow: |
| 3238 | print_overflow_msg(__func__, xdr); |
| 3239 | return -EIO; |
| 3240 | } |
| 3241 | |
| 3242 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3243 | { |
| 3244 | __be32 *p; |
| 3245 | int len; |
| 3246 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3247 | if (fh != NULL) |
| 3248 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3249 | |
| 3250 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3251 | return -EIO; |
| 3252 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3253 | p = xdr_inline_decode(xdr, 4); |
| 3254 | if (unlikely(!p)) |
| 3255 | goto out_overflow; |
| 3256 | len = be32_to_cpup(p); |
| 3257 | if (len > NFS4_FHSIZE) |
| 3258 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3259 | p = xdr_inline_decode(xdr, len); |
| 3260 | if (unlikely(!p)) |
| 3261 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3262 | if (fh != NULL) { |
| 3263 | memcpy(fh->data, p, len); |
| 3264 | fh->size = len; |
| 3265 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3266 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3267 | } |
| 3268 | return 0; |
| 3269 | out_overflow: |
| 3270 | print_overflow_msg(__func__, xdr); |
| 3271 | return -EIO; |
| 3272 | } |
| 3273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3275 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3276 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | |
| 3278 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 3279 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3280 | return -EIO; |
| 3281 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3282 | p = xdr_inline_decode(xdr, 4); |
| 3283 | if (unlikely(!p)) |
| 3284 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3285 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3286 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3287 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3288 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3290 | out_overflow: |
| 3291 | print_overflow_msg(__func__, xdr); |
| 3292 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | } |
| 3294 | |
| 3295 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3296 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3297 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3298 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3299 | |
| 3300 | *fileid = 0; |
| 3301 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3302 | return -EIO; |
| 3303 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3304 | p = xdr_inline_decode(xdr, 8); |
| 3305 | if (unlikely(!p)) |
| 3306 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3307 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3309 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3311 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3312 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3313 | out_overflow: |
| 3314 | print_overflow_msg(__func__, xdr); |
| 3315 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3316 | } |
| 3317 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3318 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3319 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3320 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3321 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3322 | |
| 3323 | *fileid = 0; |
| 3324 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3325 | return -EIO; |
| 3326 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3327 | p = xdr_inline_decode(xdr, 8); |
| 3328 | if (unlikely(!p)) |
| 3329 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3330 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3331 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3332 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3333 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3334 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3335 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3336 | out_overflow: |
| 3337 | print_overflow_msg(__func__, xdr); |
| 3338 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3339 | } |
| 3340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3342 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3343 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3344 | int status = 0; |
| 3345 | |
| 3346 | *res = 0; |
| 3347 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3348 | return -EIO; |
| 3349 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3350 | p = xdr_inline_decode(xdr, 8); |
| 3351 | if (unlikely(!p)) |
| 3352 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3353 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3354 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3355 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3356 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3357 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3358 | out_overflow: |
| 3359 | print_overflow_msg(__func__, xdr); |
| 3360 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3364 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3365 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3366 | int status = 0; |
| 3367 | |
| 3368 | *res = 0; |
| 3369 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3370 | return -EIO; |
| 3371 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3372 | p = xdr_inline_decode(xdr, 8); |
| 3373 | if (unlikely(!p)) |
| 3374 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3375 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3376 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3377 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3378 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3379 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3380 | out_overflow: |
| 3381 | print_overflow_msg(__func__, xdr); |
| 3382 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3383 | } |
| 3384 | |
| 3385 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3386 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3387 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3388 | int status = 0; |
| 3389 | |
| 3390 | *res = 0; |
| 3391 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3392 | return -EIO; |
| 3393 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3394 | p = xdr_inline_decode(xdr, 8); |
| 3395 | if (unlikely(!p)) |
| 3396 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3397 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3398 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3399 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3400 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3401 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3402 | out_overflow: |
| 3403 | print_overflow_msg(__func__, xdr); |
| 3404 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3405 | } |
| 3406 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3407 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3408 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3409 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3410 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3411 | int status = 0; |
| 3412 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3413 | p = xdr_inline_decode(xdr, 4); |
| 3414 | if (unlikely(!p)) |
| 3415 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3416 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3417 | if (n == 0) |
| 3418 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3419 | dprintk("pathname4: "); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3420 | path->ncomponents = 0; |
| 3421 | while (path->ncomponents < n) { |
| 3422 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3423 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3424 | if (unlikely(status != 0)) |
| 3425 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3426 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3427 | pr_cont("%s%.*s ", |
| 3428 | (path->ncomponents != n ? "/ " : ""), |
| 3429 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3430 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 3431 | path->ncomponents++; |
| 3432 | else { |
| 3433 | dprintk("cannot parse %d components in path\n", n); |
| 3434 | goto out_eio; |
| 3435 | } |
| 3436 | } |
| 3437 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3438 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3439 | root_path: |
| 3440 | /* a root pathname is sent as a zero component4 */ |
| 3441 | path->ncomponents = 1; |
| 3442 | path->components[0].len=0; |
| 3443 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3444 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3445 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3446 | out_eio: |
| 3447 | dprintk(" status %d", status); |
| 3448 | status = -EIO; |
| 3449 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3450 | out_overflow: |
| 3451 | print_overflow_msg(__func__, xdr); |
| 3452 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3453 | } |
| 3454 | |
| 3455 | 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] | 3456 | { |
| 3457 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3458 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3459 | int status = -EIO; |
| 3460 | |
| 3461 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3462 | goto out; |
| 3463 | status = 0; |
| 3464 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3465 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3466 | status = -EIO; |
| 3467 | /* Ignore borken servers that return unrequested attrs */ |
| 3468 | if (unlikely(res == NULL)) |
| 3469 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3470 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3471 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3472 | if (unlikely(status != 0)) |
| 3473 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3474 | p = xdr_inline_decode(xdr, 4); |
| 3475 | if (unlikely(!p)) |
| 3476 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3477 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3478 | if (n <= 0) |
| 3479 | goto out_eio; |
| 3480 | res->nlocations = 0; |
| 3481 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3482 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3483 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3484 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3485 | p = xdr_inline_decode(xdr, 4); |
| 3486 | if (unlikely(!p)) |
| 3487 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3488 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3489 | |
| 3490 | loc->nservers = 0; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3491 | dprintk("%s: servers:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3492 | while (loc->nservers < m) { |
| 3493 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3494 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3495 | if (unlikely(status != 0)) |
| 3496 | goto out_eio; |
| 3497 | dprintk("%s ", server->data); |
| 3498 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3499 | loc->nservers++; |
| 3500 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3501 | unsigned int i; |
| 3502 | dprintk("%s: using first %u of %u servers " |
| 3503 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3504 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3505 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3506 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3507 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3508 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3509 | char *data; |
| 3510 | status = decode_opaque_inline(xdr, &len, &data); |
| 3511 | if (unlikely(status != 0)) |
| 3512 | goto out_eio; |
| 3513 | } |
| 3514 | } |
| 3515 | } |
| 3516 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3517 | if (unlikely(status != 0)) |
| 3518 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3519 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3520 | res->nlocations++; |
| 3521 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3522 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3523 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3524 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3525 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3526 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3527 | out_overflow: |
| 3528 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3529 | out_eio: |
| 3530 | status = -EIO; |
| 3531 | goto out; |
| 3532 | } |
| 3533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3535 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3536 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | int status = 0; |
| 3538 | |
| 3539 | *res = 0; |
| 3540 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3541 | return -EIO; |
| 3542 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3543 | p = xdr_inline_decode(xdr, 8); |
| 3544 | if (unlikely(!p)) |
| 3545 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3546 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3547 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3548 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3549 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3550 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3551 | out_overflow: |
| 3552 | print_overflow_msg(__func__, xdr); |
| 3553 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3554 | } |
| 3555 | |
| 3556 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3557 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3558 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3559 | int status = 0; |
| 3560 | |
| 3561 | *maxlink = 1; |
| 3562 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3563 | return -EIO; |
| 3564 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3565 | p = xdr_inline_decode(xdr, 4); |
| 3566 | if (unlikely(!p)) |
| 3567 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3568 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3569 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3570 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3571 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3572 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3573 | out_overflow: |
| 3574 | print_overflow_msg(__func__, xdr); |
| 3575 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3576 | } |
| 3577 | |
| 3578 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3579 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3580 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3581 | int status = 0; |
| 3582 | |
| 3583 | *maxname = 1024; |
| 3584 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3585 | return -EIO; |
| 3586 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3587 | p = xdr_inline_decode(xdr, 4); |
| 3588 | if (unlikely(!p)) |
| 3589 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3590 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3591 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3592 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3593 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3594 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3595 | out_overflow: |
| 3596 | print_overflow_msg(__func__, xdr); |
| 3597 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3598 | } |
| 3599 | |
| 3600 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3601 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3602 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3603 | int status = 0; |
| 3604 | |
| 3605 | *res = 1024; |
| 3606 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3607 | return -EIO; |
| 3608 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3609 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3610 | p = xdr_inline_decode(xdr, 8); |
| 3611 | if (unlikely(!p)) |
| 3612 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3613 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3614 | if (maxread > 0x7FFFFFFF) |
| 3615 | maxread = 0x7FFFFFFF; |
| 3616 | *res = (uint32_t)maxread; |
| 3617 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3618 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3619 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3621 | out_overflow: |
| 3622 | print_overflow_msg(__func__, xdr); |
| 3623 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3624 | } |
| 3625 | |
| 3626 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3627 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3628 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3629 | int status = 0; |
| 3630 | |
| 3631 | *res = 1024; |
| 3632 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3633 | return -EIO; |
| 3634 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3635 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3636 | p = xdr_inline_decode(xdr, 8); |
| 3637 | if (unlikely(!p)) |
| 3638 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3639 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3640 | if (maxwrite > 0x7FFFFFFF) |
| 3641 | maxwrite = 0x7FFFFFFF; |
| 3642 | *res = (uint32_t)maxwrite; |
| 3643 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3644 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3645 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3646 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3647 | out_overflow: |
| 3648 | print_overflow_msg(__func__, xdr); |
| 3649 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3650 | } |
| 3651 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3652 | 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] | 3653 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3654 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3655 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3656 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3657 | |
| 3658 | *mode = 0; |
| 3659 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3660 | return -EIO; |
| 3661 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3662 | p = xdr_inline_decode(xdr, 4); |
| 3663 | if (unlikely(!p)) |
| 3664 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3665 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3666 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3667 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3668 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3669 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3670 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3671 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3672 | out_overflow: |
| 3673 | print_overflow_msg(__func__, xdr); |
| 3674 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3675 | } |
| 3676 | |
| 3677 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3678 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3679 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3680 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3681 | |
| 3682 | *nlink = 1; |
| 3683 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3684 | return -EIO; |
| 3685 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3686 | p = xdr_inline_decode(xdr, 4); |
| 3687 | if (unlikely(!p)) |
| 3688 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3689 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3690 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3691 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3692 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3693 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3694 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3695 | out_overflow: |
| 3696 | print_overflow_msg(__func__, xdr); |
| 3697 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3698 | } |
| 3699 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3700 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3701 | const struct nfs_server *server, uint32_t *uid, |
| 3702 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3704 | uint32_t len; |
| 3705 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3706 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | |
| 3708 | *uid = -2; |
| 3709 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3710 | return -EIO; |
| 3711 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3712 | p = xdr_inline_decode(xdr, 4); |
| 3713 | if (unlikely(!p)) |
| 3714 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3715 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3716 | p = xdr_inline_decode(xdr, len); |
| 3717 | if (unlikely(!p)) |
| 3718 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3719 | if (owner_name != NULL) { |
| 3720 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3721 | if (owner_name->data != NULL) { |
| 3722 | owner_name->len = len; |
| 3723 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3724 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3725 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3726 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3727 | ret = NFS_ATTR_FATTR_OWNER; |
| 3728 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3730 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3731 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3732 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3733 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3734 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3735 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3736 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3737 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3738 | out_overflow: |
| 3739 | print_overflow_msg(__func__, xdr); |
| 3740 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3741 | } |
| 3742 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3743 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3744 | const struct nfs_server *server, uint32_t *gid, |
| 3745 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3747 | uint32_t len; |
| 3748 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3749 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3750 | |
| 3751 | *gid = -2; |
| 3752 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3753 | return -EIO; |
| 3754 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3755 | p = xdr_inline_decode(xdr, 4); |
| 3756 | if (unlikely(!p)) |
| 3757 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3758 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3759 | p = xdr_inline_decode(xdr, len); |
| 3760 | if (unlikely(!p)) |
| 3761 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3762 | if (group_name != NULL) { |
| 3763 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3764 | if (group_name->data != NULL) { |
| 3765 | group_name->len = len; |
| 3766 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3767 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3768 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3769 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3770 | ret = NFS_ATTR_FATTR_GROUP; |
| 3771 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3772 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3773 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3774 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3775 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3776 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3777 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3778 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3779 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3780 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3781 | out_overflow: |
| 3782 | print_overflow_msg(__func__, xdr); |
| 3783 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | } |
| 3785 | |
| 3786 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3787 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3788 | uint32_t major = 0, minor = 0; |
| 3789 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3790 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3791 | |
| 3792 | *rdev = MKDEV(0,0); |
| 3793 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3794 | return -EIO; |
| 3795 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3796 | dev_t tmp; |
| 3797 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3798 | p = xdr_inline_decode(xdr, 8); |
| 3799 | if (unlikely(!p)) |
| 3800 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3801 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3802 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | tmp = MKDEV(major, minor); |
| 3804 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3805 | *rdev = tmp; |
| 3806 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3807 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3808 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3809 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3810 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3811 | out_overflow: |
| 3812 | print_overflow_msg(__func__, xdr); |
| 3813 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | } |
| 3815 | |
| 3816 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3817 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3818 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | int status = 0; |
| 3820 | |
| 3821 | *res = 0; |
| 3822 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3823 | return -EIO; |
| 3824 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3825 | p = xdr_inline_decode(xdr, 8); |
| 3826 | if (unlikely(!p)) |
| 3827 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3828 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3830 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3831 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3832 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3833 | out_overflow: |
| 3834 | print_overflow_msg(__func__, xdr); |
| 3835 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3839 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3840 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3841 | int status = 0; |
| 3842 | |
| 3843 | *res = 0; |
| 3844 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3845 | return -EIO; |
| 3846 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3847 | p = xdr_inline_decode(xdr, 8); |
| 3848 | if (unlikely(!p)) |
| 3849 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3850 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3851 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3852 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3853 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3855 | out_overflow: |
| 3856 | print_overflow_msg(__func__, xdr); |
| 3857 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3858 | } |
| 3859 | |
| 3860 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3861 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3862 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | int status = 0; |
| 3864 | |
| 3865 | *res = 0; |
| 3866 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3867 | return -EIO; |
| 3868 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3869 | p = xdr_inline_decode(xdr, 8); |
| 3870 | if (unlikely(!p)) |
| 3871 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3872 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3873 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 3874 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3875 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3876 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3877 | out_overflow: |
| 3878 | print_overflow_msg(__func__, xdr); |
| 3879 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3880 | } |
| 3881 | |
| 3882 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 3883 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3884 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3885 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3886 | |
| 3887 | *used = 0; |
| 3888 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 3889 | return -EIO; |
| 3890 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3891 | p = xdr_inline_decode(xdr, 8); |
| 3892 | if (unlikely(!p)) |
| 3893 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3894 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3895 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3896 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3897 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3898 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3899 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3900 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3901 | out_overflow: |
| 3902 | print_overflow_msg(__func__, xdr); |
| 3903 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3904 | } |
| 3905 | |
| 3906 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 3907 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3908 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3909 | uint64_t sec; |
| 3910 | uint32_t nsec; |
| 3911 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3912 | p = xdr_inline_decode(xdr, 12); |
| 3913 | if (unlikely(!p)) |
| 3914 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3915 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3916 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3917 | time->tv_sec = (time_t)sec; |
| 3918 | time->tv_nsec = (long)nsec; |
| 3919 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3920 | out_overflow: |
| 3921 | print_overflow_msg(__func__, xdr); |
| 3922 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3923 | } |
| 3924 | |
| 3925 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3926 | { |
| 3927 | int status = 0; |
| 3928 | |
| 3929 | time->tv_sec = 0; |
| 3930 | time->tv_nsec = 0; |
| 3931 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 3932 | return -EIO; |
| 3933 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 3934 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3935 | if (status == 0) |
| 3936 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 3938 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3939 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3940 | return status; |
| 3941 | } |
| 3942 | |
| 3943 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3944 | { |
| 3945 | int status = 0; |
| 3946 | |
| 3947 | time->tv_sec = 0; |
| 3948 | time->tv_nsec = 0; |
| 3949 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 3950 | return -EIO; |
| 3951 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 3952 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3953 | if (status == 0) |
| 3954 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3955 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 3956 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3957 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | return status; |
| 3959 | } |
| 3960 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 3961 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 3962 | struct timespec *time) |
| 3963 | { |
| 3964 | int status = 0; |
| 3965 | |
| 3966 | time->tv_sec = 0; |
| 3967 | time->tv_nsec = 0; |
| 3968 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 3969 | return -EIO; |
| 3970 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 3971 | status = decode_attr_time(xdr, time); |
| 3972 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 3973 | } |
| 3974 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 3975 | (long)time->tv_nsec); |
| 3976 | return status; |
| 3977 | } |
| 3978 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3979 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3980 | { |
| 3981 | int status = 0; |
| 3982 | |
| 3983 | time->tv_sec = 0; |
| 3984 | time->tv_nsec = 0; |
| 3985 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 3986 | return -EIO; |
| 3987 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 3988 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3989 | if (status == 0) |
| 3990 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 3992 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3993 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3994 | return status; |
| 3995 | } |
| 3996 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3997 | 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] | 3998 | { |
| 3999 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 4000 | unsigned int nwords = xdr->p - savep; |
| 4001 | |
| 4002 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4003 | dprintk("%s: server returned incorrect attribute length: " |
| 4004 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4005 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | attrwords << 2, |
| 4007 | (attrwords < nwords) ? '<' : '>', |
| 4008 | nwords << 2); |
| 4009 | return -EIO; |
| 4010 | } |
| 4011 | return 0; |
| 4012 | } |
| 4013 | |
| 4014 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4015 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4016 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4017 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4018 | p = xdr_inline_decode(xdr, 20); |
| 4019 | if (unlikely(!p)) |
| 4020 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4021 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4022 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4023 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4024 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4025 | out_overflow: |
| 4026 | print_overflow_msg(__func__, xdr); |
| 4027 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 4031 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4032 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4033 | uint32_t supp, acc; |
| 4034 | int status; |
| 4035 | |
| 4036 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4037 | if (status) |
| 4038 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4039 | p = xdr_inline_decode(xdr, 8); |
| 4040 | if (unlikely(!p)) |
| 4041 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4042 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4043 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4044 | access->supported = supp; |
| 4045 | access->access = acc; |
| 4046 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4047 | out_overflow: |
| 4048 | print_overflow_msg(__func__, xdr); |
| 4049 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4050 | } |
| 4051 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4052 | 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] | 4053 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4054 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4055 | |
| 4056 | p = xdr_inline_decode(xdr, len); |
| 4057 | if (likely(p)) { |
| 4058 | memcpy(buf, p, len); |
| 4059 | return 0; |
| 4060 | } |
| 4061 | print_overflow_msg(__func__, xdr); |
| 4062 | return -EIO; |
| 4063 | } |
| 4064 | |
| 4065 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4066 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4067 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4068 | } |
| 4069 | |
| 4070 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4071 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | int status; |
| 4073 | |
| 4074 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4075 | if (status != -EIO) |
| 4076 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4077 | if (!status) |
| 4078 | status = decode_stateid(xdr, &res->stateid); |
| 4079 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4080 | } |
| 4081 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4082 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4083 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4084 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4085 | } |
| 4086 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4087 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4089 | int status; |
| 4090 | |
| 4091 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4092 | if (!status) |
| 4093 | status = decode_verifier(xdr, res->verf->verifier); |
| 4094 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4095 | } |
| 4096 | |
| 4097 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4098 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4099 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4100 | uint32_t bmlen; |
| 4101 | int status; |
| 4102 | |
| 4103 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4104 | if (status) |
| 4105 | return status; |
| 4106 | if ((status = decode_change_info(xdr, cinfo))) |
| 4107 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4108 | p = xdr_inline_decode(xdr, 4); |
| 4109 | if (unlikely(!p)) |
| 4110 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4111 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4112 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4113 | if (likely(p)) |
| 4114 | return 0; |
| 4115 | out_overflow: |
| 4116 | print_overflow_msg(__func__, xdr); |
| 4117 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4118 | } |
| 4119 | |
| 4120 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4121 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4122 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4123 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4124 | int status; |
| 4125 | |
| 4126 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4127 | goto xdr_error; |
| 4128 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4129 | goto xdr_error; |
| 4130 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4131 | goto xdr_error; |
| 4132 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4133 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4134 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4135 | &res->fh_expire_type)) != 0) |
| 4136 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4138 | goto xdr_error; |
| 4139 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4140 | goto xdr_error; |
| 4141 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4142 | goto xdr_error; |
| 4143 | status = verify_attr_len(xdr, savep, attrlen); |
| 4144 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4145 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | return status; |
| 4147 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4149 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4150 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4151 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4152 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4153 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4155 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4156 | goto xdr_error; |
| 4157 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4158 | goto xdr_error; |
| 4159 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4160 | goto xdr_error; |
| 4161 | |
| 4162 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4163 | goto xdr_error; |
| 4164 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4165 | goto xdr_error; |
| 4166 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4167 | goto xdr_error; |
| 4168 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4169 | goto xdr_error; |
| 4170 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4171 | goto xdr_error; |
| 4172 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4173 | goto xdr_error; |
| 4174 | |
| 4175 | status = verify_attr_len(xdr, savep, attrlen); |
| 4176 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4177 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4178 | return status; |
| 4179 | } |
| 4180 | |
| 4181 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4182 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4183 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4184 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4185 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4186 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4187 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4188 | goto xdr_error; |
| 4189 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4190 | goto xdr_error; |
| 4191 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4192 | goto xdr_error; |
| 4193 | |
| 4194 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4195 | goto xdr_error; |
| 4196 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4197 | goto xdr_error; |
| 4198 | |
| 4199 | status = verify_attr_len(xdr, savep, attrlen); |
| 4200 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4201 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4202 | return status; |
| 4203 | } |
| 4204 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4205 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4206 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4207 | struct nfs4_fs_locations *fs_loc, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4208 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4209 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4210 | int status; |
| 4211 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4212 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4213 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4215 | status = decode_attr_type(xdr, bitmap, &type); |
| 4216 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4217 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4218 | fattr->mode = 0; |
| 4219 | if (status != 0) { |
| 4220 | fattr->mode |= nfs_type2fmt[type]; |
| 4221 | fattr->valid |= status; |
| 4222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4223 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4224 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4225 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4226 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4227 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4228 | |
| 4229 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4230 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4231 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4232 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4233 | |
| 4234 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4235 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4236 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4237 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4238 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4239 | err = 0; |
| 4240 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4241 | if (status < 0) |
| 4242 | goto xdr_error; |
| 4243 | |
| 4244 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4245 | if (status < 0) |
| 4246 | goto xdr_error; |
| 4247 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4248 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4249 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4250 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4251 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4252 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4253 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4254 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4255 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4256 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4257 | |
| 4258 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4259 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4260 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4261 | if (status != 0) { |
| 4262 | fattr->mode |= fmode; |
| 4263 | fattr->valid |= status; |
| 4264 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4265 | |
| 4266 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4267 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4268 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4269 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4270 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4271 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4272 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4274 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4275 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4276 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4277 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4278 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4279 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4280 | |
| 4281 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4282 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4284 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4285 | |
| 4286 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4287 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4288 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4289 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4290 | |
| 4291 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4292 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4293 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4294 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4295 | |
| 4296 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4297 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4298 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4299 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4300 | |
| 4301 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4302 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4303 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4304 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4305 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4306 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4307 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4308 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4309 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4310 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4311 | xdr_error: |
| 4312 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4313 | return status; |
| 4314 | } |
| 4315 | |
| 4316 | 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] | 4317 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
| 4318 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4319 | { |
| 4320 | __be32 *savep; |
| 4321 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4322 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4323 | int status; |
| 4324 | |
| 4325 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4326 | if (status < 0) |
| 4327 | goto xdr_error; |
| 4328 | |
| 4329 | status = decode_attr_bitmap(xdr, bitmap); |
| 4330 | if (status < 0) |
| 4331 | goto xdr_error; |
| 4332 | |
| 4333 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4334 | if (status < 0) |
| 4335 | goto xdr_error; |
| 4336 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4337 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4338 | if (status < 0) |
| 4339 | goto xdr_error; |
| 4340 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4341 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4342 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4343 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4344 | return status; |
| 4345 | } |
| 4346 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4347 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4348 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4349 | { |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4350 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4351 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4352 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4353 | /* |
| 4354 | * Decode potentially multiple layout types. Currently we only support |
| 4355 | * one layout driver per file system. |
| 4356 | */ |
| 4357 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4358 | uint32_t *layouttype) |
| 4359 | { |
| 4360 | uint32_t *p; |
| 4361 | int num; |
| 4362 | |
| 4363 | p = xdr_inline_decode(xdr, 4); |
| 4364 | if (unlikely(!p)) |
| 4365 | goto out_overflow; |
| 4366 | num = be32_to_cpup(p); |
| 4367 | |
| 4368 | /* pNFS is not supported by the underlying file system */ |
| 4369 | if (num == 0) { |
| 4370 | *layouttype = 0; |
| 4371 | return 0; |
| 4372 | } |
| 4373 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4374 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4375 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4376 | |
| 4377 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4378 | p = xdr_inline_decode(xdr, num * 4); |
| 4379 | if (unlikely(!p)) |
| 4380 | goto out_overflow; |
| 4381 | *layouttype = be32_to_cpup(p); |
| 4382 | return 0; |
| 4383 | out_overflow: |
| 4384 | print_overflow_msg(__func__, xdr); |
| 4385 | return -EIO; |
| 4386 | } |
| 4387 | |
| 4388 | /* |
| 4389 | * The type of file system exported. |
| 4390 | * Note we must ensure that layouttype is set in any non-error case. |
| 4391 | */ |
| 4392 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4393 | uint32_t *layouttype) |
| 4394 | { |
| 4395 | int status = 0; |
| 4396 | |
| 4397 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4398 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4399 | return -EIO; |
| 4400 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4401 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4402 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4403 | } else |
| 4404 | *layouttype = 0; |
| 4405 | return status; |
| 4406 | } |
| 4407 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4408 | /* |
| 4409 | * The prefered block size for layout directed io |
| 4410 | */ |
| 4411 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4412 | uint32_t *res) |
| 4413 | { |
| 4414 | __be32 *p; |
| 4415 | |
| 4416 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4417 | *res = 0; |
| 4418 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4419 | p = xdr_inline_decode(xdr, 4); |
| 4420 | if (unlikely(!p)) { |
| 4421 | print_overflow_msg(__func__, xdr); |
| 4422 | return -EIO; |
| 4423 | } |
| 4424 | *res = be32_to_cpup(p); |
| 4425 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4426 | } |
| 4427 | return 0; |
| 4428 | } |
| 4429 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4430 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4431 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4432 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4433 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4434 | int status; |
| 4435 | |
| 4436 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4437 | goto xdr_error; |
| 4438 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4439 | goto xdr_error; |
| 4440 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4441 | goto xdr_error; |
| 4442 | |
| 4443 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4444 | |
| 4445 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4446 | goto xdr_error; |
| 4447 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4448 | goto xdr_error; |
| 4449 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4450 | goto xdr_error; |
| 4451 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4452 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4453 | goto xdr_error; |
| 4454 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4455 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4456 | if (status != 0) |
| 4457 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4458 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4459 | if (status != 0) |
| 4460 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4461 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4462 | if (status) |
| 4463 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4464 | |
| 4465 | status = verify_attr_len(xdr, savep, attrlen); |
| 4466 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4467 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4468 | return status; |
| 4469 | } |
| 4470 | |
| 4471 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4472 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4473 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4474 | uint32_t len; |
| 4475 | int status; |
| 4476 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4477 | /* Zero handle first to allow comparisons */ |
| 4478 | memset(fh, 0, sizeof(*fh)); |
| 4479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4480 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4481 | if (status) |
| 4482 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4483 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4484 | p = xdr_inline_decode(xdr, 4); |
| 4485 | if (unlikely(!p)) |
| 4486 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4487 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4488 | if (len > NFS4_FHSIZE) |
| 4489 | return -EIO; |
| 4490 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4491 | p = xdr_inline_decode(xdr, len); |
| 4492 | if (unlikely(!p)) |
| 4493 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4494 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4495 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4496 | out_overflow: |
| 4497 | print_overflow_msg(__func__, xdr); |
| 4498 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4499 | } |
| 4500 | |
| 4501 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4502 | { |
| 4503 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4505 | status = decode_op_hdr(xdr, OP_LINK); |
| 4506 | if (status) |
| 4507 | return status; |
| 4508 | return decode_change_info(xdr, cinfo); |
| 4509 | } |
| 4510 | |
| 4511 | /* |
| 4512 | * We create the owner, so we know a proper owner.id length is 4. |
| 4513 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4514 | 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] | 4515 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4516 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4517 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4518 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4519 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4520 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4521 | if (unlikely(!p)) |
| 4522 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4523 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4524 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4525 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4526 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4527 | fl->fl_start = (loff_t)offset; |
| 4528 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4529 | if (length == ~(uint64_t)0) |
| 4530 | fl->fl_end = OFFSET_MAX; |
| 4531 | fl->fl_type = F_WRLCK; |
| 4532 | if (type & 1) |
| 4533 | fl->fl_type = F_RDLCK; |
| 4534 | fl->fl_pid = 0; |
| 4535 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4536 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4537 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4538 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4539 | if (likely(p)) |
| 4540 | return -NFS4ERR_DENIED; |
| 4541 | out_overflow: |
| 4542 | print_overflow_msg(__func__, xdr); |
| 4543 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4544 | } |
| 4545 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4546 | 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] | 4547 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4548 | int status; |
| 4549 | |
| 4550 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4551 | if (status == -EIO) |
| 4552 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4553 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4554 | status = decode_stateid(xdr, &res->stateid); |
| 4555 | if (unlikely(status)) |
| 4556 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4557 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4558 | status = decode_lock_denied(xdr, NULL); |
| 4559 | if (res->open_seqid != NULL) |
| 4560 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4561 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4562 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4563 | return status; |
| 4564 | } |
| 4565 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4566 | 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] | 4567 | { |
| 4568 | int status; |
| 4569 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4570 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4571 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4572 | return status; |
| 4573 | } |
| 4574 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4575 | 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] | 4576 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4577 | int status; |
| 4578 | |
| 4579 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4580 | if (status != -EIO) |
| 4581 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4582 | if (status == 0) |
| 4583 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4584 | return status; |
| 4585 | } |
| 4586 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4587 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4588 | { |
| 4589 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4590 | } |
| 4591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4592 | static int decode_lookup(struct xdr_stream *xdr) |
| 4593 | { |
| 4594 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4595 | } |
| 4596 | |
| 4597 | /* This is too sick! */ |
| 4598 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4599 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4600 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4601 | uint32_t limit_type, nblocks, blocksize; |
| 4602 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4603 | p = xdr_inline_decode(xdr, 12); |
| 4604 | if (unlikely(!p)) |
| 4605 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4606 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4607 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4608 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4609 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4610 | break; |
| 4611 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4612 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4613 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4614 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4615 | } |
| 4616 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4617 | out_overflow: |
| 4618 | print_overflow_msg(__func__, xdr); |
| 4619 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4620 | } |
| 4621 | |
| 4622 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4623 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4624 | __be32 *p; |
| 4625 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4626 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4627 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4628 | p = xdr_inline_decode(xdr, 4); |
| 4629 | if (unlikely(!p)) |
| 4630 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4631 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4633 | res->delegation_type = 0; |
| 4634 | return 0; |
| 4635 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4636 | status = decode_stateid(xdr, &res->delegation); |
| 4637 | if (unlikely(status)) |
| 4638 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4639 | p = xdr_inline_decode(xdr, 4); |
| 4640 | if (unlikely(!p)) |
| 4641 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4642 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4643 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4644 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4645 | case NFS4_OPEN_DELEGATE_READ: |
| 4646 | res->delegation_type = FMODE_READ; |
| 4647 | break; |
| 4648 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4649 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4650 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4651 | return -EIO; |
| 4652 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4653 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4654 | out_overflow: |
| 4655 | print_overflow_msg(__func__, xdr); |
| 4656 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4657 | } |
| 4658 | |
| 4659 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4660 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4661 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4662 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4663 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4664 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4665 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4666 | if (status != -EIO) |
| 4667 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4668 | if (!status) |
| 4669 | status = decode_stateid(xdr, &res->stateid); |
| 4670 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4671 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4672 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4673 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4674 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4675 | p = xdr_inline_decode(xdr, 8); |
| 4676 | if (unlikely(!p)) |
| 4677 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4678 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4679 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4680 | if (bmlen > 10) |
| 4681 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4682 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4683 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4684 | if (unlikely(!p)) |
| 4685 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4686 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4687 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4688 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4689 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4690 | res->attrset[i] = 0; |
| 4691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4692 | return decode_delegation(xdr, res); |
| 4693 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4694 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4695 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4696 | out_overflow: |
| 4697 | print_overflow_msg(__func__, xdr); |
| 4698 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4699 | } |
| 4700 | |
| 4701 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4702 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4703 | int status; |
| 4704 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4705 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4706 | if (status != -EIO) |
| 4707 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4708 | if (!status) |
| 4709 | status = decode_stateid(xdr, &res->stateid); |
| 4710 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | } |
| 4712 | |
| 4713 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4714 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4715 | int status; |
| 4716 | |
| 4717 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4718 | if (status != -EIO) |
| 4719 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4720 | if (!status) |
| 4721 | status = decode_stateid(xdr, &res->stateid); |
| 4722 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | } |
| 4724 | |
| 4725 | static int decode_putfh(struct xdr_stream *xdr) |
| 4726 | { |
| 4727 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4728 | } |
| 4729 | |
| 4730 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4731 | { |
| 4732 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4733 | } |
| 4734 | |
| 4735 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4736 | { |
| 4737 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4738 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4739 | uint32_t count, eof, recvd, hdrlen; |
| 4740 | int status; |
| 4741 | |
| 4742 | status = decode_op_hdr(xdr, OP_READ); |
| 4743 | if (status) |
| 4744 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4745 | p = xdr_inline_decode(xdr, 8); |
| 4746 | if (unlikely(!p)) |
| 4747 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4748 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4749 | count = be32_to_cpup(p); |
Chuck Lever | 8111f37 | 2010-12-14 14:58:01 +0000 | [diff] [blame] | 4750 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4751 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4752 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4753 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | "count %u > recvd %u\n", count, recvd); |
| 4755 | count = recvd; |
| 4756 | eof = 0; |
| 4757 | } |
| 4758 | xdr_read_pages(xdr, count); |
| 4759 | res->eof = eof; |
| 4760 | res->count = count; |
| 4761 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4762 | out_overflow: |
| 4763 | print_overflow_msg(__func__, xdr); |
| 4764 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4765 | } |
| 4766 | |
| 4767 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4768 | { |
| 4769 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4770 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4771 | size_t hdrlen; |
| 4772 | u32 recvd, pglen = rcvbuf->page_len; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4773 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4774 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4775 | |
| 4776 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4777 | if (!status) |
| 4778 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4779 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4780 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4781 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4782 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4783 | __func__, verf[0], verf[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4784 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4785 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4786 | recvd = rcvbuf->len - hdrlen; |
| 4787 | if (pglen > recvd) |
| 4788 | pglen = recvd; |
| 4789 | xdr_read_pages(xdr, pglen); |
| 4790 | |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4791 | |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 4792 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4793 | } |
| 4794 | |
| 4795 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4796 | { |
| 4797 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4798 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4799 | size_t hdrlen; |
| 4800 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4801 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4802 | int status; |
| 4803 | |
| 4804 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4805 | if (status) |
| 4806 | return status; |
| 4807 | |
| 4808 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4809 | p = xdr_inline_decode(xdr, 4); |
| 4810 | if (unlikely(!p)) |
| 4811 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4812 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4813 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4814 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4815 | return -ENAMETOOLONG; |
| 4816 | } |
| 4817 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4818 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4819 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4820 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4821 | "count %u > recvd %u\n", len, recvd); |
| 4822 | return -EIO; |
| 4823 | } |
| 4824 | xdr_read_pages(xdr, len); |
| 4825 | /* |
| 4826 | * The XDR encode routine has set things up so that |
| 4827 | * the link text will be copied directly into the |
| 4828 | * buffer. We just have to do overflow-checking, |
| 4829 | * and and null-terminate the text (the VFS expects |
| 4830 | * null-termination). |
| 4831 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 4832 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4833 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4834 | out_overflow: |
| 4835 | print_overflow_msg(__func__, xdr); |
| 4836 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4837 | } |
| 4838 | |
| 4839 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4840 | { |
| 4841 | int status; |
| 4842 | |
| 4843 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 4844 | if (status) |
| 4845 | goto out; |
| 4846 | status = decode_change_info(xdr, cinfo); |
| 4847 | out: |
| 4848 | return status; |
| 4849 | } |
| 4850 | |
| 4851 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 4852 | struct nfs4_change_info *new_cinfo) |
| 4853 | { |
| 4854 | int status; |
| 4855 | |
| 4856 | status = decode_op_hdr(xdr, OP_RENAME); |
| 4857 | if (status) |
| 4858 | goto out; |
| 4859 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 4860 | goto out; |
| 4861 | status = decode_change_info(xdr, new_cinfo); |
| 4862 | out: |
| 4863 | return status; |
| 4864 | } |
| 4865 | |
| 4866 | static int decode_renew(struct xdr_stream *xdr) |
| 4867 | { |
| 4868 | return decode_op_hdr(xdr, OP_RENEW); |
| 4869 | } |
| 4870 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4871 | static int |
| 4872 | decode_restorefh(struct xdr_stream *xdr) |
| 4873 | { |
| 4874 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 4875 | } |
| 4876 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4877 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4878 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4879 | { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4880 | __be32 *savep, *bm_p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4881 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4882 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4883 | struct kvec *iov = req->rq_rcv_buf.head; |
| 4884 | int status; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4885 | size_t page_len = xdr->buf->page_len; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4886 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4887 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4888 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4889 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4890 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4891 | bm_p = xdr->p; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4892 | res->acl_data_offset = be32_to_cpup(bm_p) + 2; |
| 4893 | res->acl_data_offset <<= 2; |
| 4894 | /* Check if the acl data starts beyond the allocated buffer */ |
| 4895 | if (res->acl_data_offset > page_len) |
| 4896 | return -ERANGE; |
| 4897 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4898 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4899 | goto out; |
| 4900 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4901 | goto out; |
| 4902 | |
| 4903 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 4904 | return -EIO; |
| 4905 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4906 | size_t hdrlen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4907 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4908 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 4909 | * are stored with the acl data to handle the problem of |
| 4910 | * variable length bitmaps.*/ |
| 4911 | xdr->p = bm_p; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4912 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4913 | /* We ignore &savep and don't do consistency checks on |
| 4914 | * the attr length. Let userspace figure it out.... */ |
| 4915 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4916 | attrlen += res->acl_data_offset; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4917 | if (attrlen > page_len) { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4918 | if (res->acl_flags & NFS4_ACL_LEN_REQUEST) { |
| 4919 | /* getxattr interface called with a NULL buf */ |
| 4920 | res->acl_len = attrlen; |
| 4921 | goto out; |
| 4922 | } |
Sachin Prabhu | 5794d21 | 2012-04-17 14:36:40 +0100 | [diff] [blame] | 4923 | dprintk("NFS: acl reply: attrlen %u > page_len %zu\n", |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4924 | attrlen, page_len); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4925 | return -EINVAL; |
| 4926 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 4927 | xdr_read_pages(xdr, attrlen); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4928 | res->acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 4929 | } else |
| 4930 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4931 | |
| 4932 | out: |
| 4933 | return status; |
| 4934 | } |
| 4935 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4936 | static int |
| 4937 | decode_savefh(struct xdr_stream *xdr) |
| 4938 | { |
| 4939 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 4940 | } |
| 4941 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 4942 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4943 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4944 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4945 | uint32_t bmlen; |
| 4946 | int status; |
| 4947 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4948 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 4949 | if (status) |
| 4950 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4951 | p = xdr_inline_decode(xdr, 4); |
| 4952 | if (unlikely(!p)) |
| 4953 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4954 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4955 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4956 | if (likely(p)) |
| 4957 | return 0; |
| 4958 | out_overflow: |
| 4959 | print_overflow_msg(__func__, xdr); |
| 4960 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4961 | } |
| 4962 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4963 | 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] | 4964 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4965 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4966 | uint32_t opnum; |
| 4967 | int32_t nfserr; |
| 4968 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4969 | p = xdr_inline_decode(xdr, 8); |
| 4970 | if (unlikely(!p)) |
| 4971 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4972 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4973 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4974 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4975 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4976 | return -EIO; |
| 4977 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4978 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4979 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4980 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 4981 | if (unlikely(!p)) |
| 4982 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4983 | p = xdr_decode_hyper(p, &res->clientid); |
| 4984 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4985 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 4986 | uint32_t len; |
| 4987 | |
| 4988 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4989 | p = xdr_inline_decode(xdr, 4); |
| 4990 | if (unlikely(!p)) |
| 4991 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4992 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4993 | p = xdr_inline_decode(xdr, len); |
| 4994 | if (unlikely(!p)) |
| 4995 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4996 | |
| 4997 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4998 | p = xdr_inline_decode(xdr, 4); |
| 4999 | if (unlikely(!p)) |
| 5000 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5001 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5002 | p = xdr_inline_decode(xdr, len); |
| 5003 | if (unlikely(!p)) |
| 5004 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5005 | return -NFSERR_CLID_INUSE; |
| 5006 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5007 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | |
| 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_setclientid_confirm(struct xdr_stream *xdr) |
| 5016 | { |
| 5017 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5018 | } |
| 5019 | |
| 5020 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 5021 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5022 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5023 | int status; |
| 5024 | |
| 5025 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5026 | if (status) |
| 5027 | return status; |
| 5028 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5029 | p = xdr_inline_decode(xdr, 16); |
| 5030 | if (unlikely(!p)) |
| 5031 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5032 | res->count = be32_to_cpup(p++); |
| 5033 | res->verf->committed = be32_to_cpup(p++); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5034 | memcpy(res->verf->verifier, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5035 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5036 | out_overflow: |
| 5037 | print_overflow_msg(__func__, xdr); |
| 5038 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5039 | } |
| 5040 | |
| 5041 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5042 | { |
| 5043 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5044 | } |
| 5045 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5046 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) |
| 5047 | { |
| 5048 | __be32 *p; |
| 5049 | |
| 5050 | p = xdr_inline_decode(xdr, 4); |
| 5051 | if (unlikely(!p)) |
| 5052 | goto out_overflow; |
| 5053 | flavor->gss.sec_oid4.len = be32_to_cpup(p); |
| 5054 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) |
| 5055 | goto out_err; |
| 5056 | |
| 5057 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); |
| 5058 | if (unlikely(!p)) |
| 5059 | goto out_overflow; |
| 5060 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); |
| 5061 | |
| 5062 | p = xdr_inline_decode(xdr, 8); |
| 5063 | if (unlikely(!p)) |
| 5064 | goto out_overflow; |
| 5065 | flavor->gss.qop4 = be32_to_cpup(p++); |
| 5066 | flavor->gss.service = be32_to_cpup(p); |
| 5067 | |
| 5068 | return 0; |
| 5069 | |
| 5070 | out_overflow: |
| 5071 | print_overflow_msg(__func__, xdr); |
| 5072 | return -EIO; |
| 5073 | out_err: |
| 5074 | return -EINVAL; |
| 5075 | } |
| 5076 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5077 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5078 | { |
| 5079 | struct nfs4_secinfo_flavor *sec_flavor; |
| 5080 | int status; |
| 5081 | __be32 *p; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5082 | int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5083 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5084 | p = xdr_inline_decode(xdr, 4); |
| 5085 | if (unlikely(!p)) |
| 5086 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5087 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5088 | res->flavors->num_flavors = 0; |
| 5089 | num_flavors = be32_to_cpup(p); |
| 5090 | |
| 5091 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5092 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5093 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5094 | break; |
| 5095 | |
| 5096 | p = xdr_inline_decode(xdr, 4); |
| 5097 | if (unlikely(!p)) |
| 5098 | goto out_overflow; |
| 5099 | sec_flavor->flavor = be32_to_cpup(p); |
| 5100 | |
| 5101 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5102 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5103 | if (status) |
| 5104 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5105 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5106 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5107 | } |
| 5108 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5109 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5110 | out: |
| 5111 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5112 | out_overflow: |
| 5113 | print_overflow_msg(__func__, xdr); |
| 5114 | return -EIO; |
| 5115 | } |
| 5116 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5117 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5118 | { |
| 5119 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5120 | if (status) |
| 5121 | return status; |
| 5122 | return decode_secinfo_common(xdr, res); |
| 5123 | } |
| 5124 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5125 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5126 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5127 | { |
| 5128 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5129 | if (status) |
| 5130 | return status; |
| 5131 | return decode_secinfo_common(xdr, res); |
| 5132 | } |
| 5133 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5134 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5135 | struct nfs41_exchange_id_res *res) |
| 5136 | { |
| 5137 | __be32 *p; |
| 5138 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5139 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5140 | int status; |
| 5141 | struct nfs_client *clp = res->client; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5142 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5143 | |
| 5144 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5145 | if (status) |
| 5146 | return status; |
| 5147 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5148 | p = xdr_inline_decode(xdr, 8); |
| 5149 | if (unlikely(!p)) |
| 5150 | goto out_overflow; |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 5151 | xdr_decode_hyper(p, &clp->cl_clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5152 | p = xdr_inline_decode(xdr, 12); |
| 5153 | if (unlikely(!p)) |
| 5154 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5155 | clp->cl_seqid = be32_to_cpup(p++); |
| 5156 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5157 | |
| 5158 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5159 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5160 | if (dummy != SP4_NONE) |
| 5161 | return -EIO; |
| 5162 | |
| 5163 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5164 | p = xdr_inline_decode(xdr, 8); |
| 5165 | if (unlikely(!p)) |
| 5166 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5167 | |
| 5168 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5169 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5170 | if (unlikely(status)) |
| 5171 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5172 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5173 | /* Save server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5174 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5175 | if (unlikely(status)) |
| 5176 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5177 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5178 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5179 | return -EIO; |
| 5180 | |
| 5181 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5182 | res->server_scope->server_scope_sz = dummy; |
| 5183 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5184 | /* Implementation Id */ |
| 5185 | p = xdr_inline_decode(xdr, 4); |
| 5186 | if (unlikely(!p)) |
| 5187 | goto out_overflow; |
| 5188 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5189 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5190 | if (impl_id_count) { |
| 5191 | /* nii_domain */ |
| 5192 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5193 | if (unlikely(status)) |
| 5194 | return status; |
| 5195 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5196 | return -EIO; |
| 5197 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5198 | |
| 5199 | /* nii_name */ |
| 5200 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5201 | if (unlikely(status)) |
| 5202 | return status; |
| 5203 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5204 | return -EIO; |
| 5205 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5206 | |
| 5207 | /* nii_date */ |
| 5208 | p = xdr_inline_decode(xdr, 12); |
| 5209 | if (unlikely(!p)) |
| 5210 | goto out_overflow; |
| 5211 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5212 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5213 | |
| 5214 | /* if there's more than one entry, ignore the rest */ |
| 5215 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5216 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5217 | out_overflow: |
| 5218 | print_overflow_msg(__func__, xdr); |
| 5219 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5220 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5221 | |
| 5222 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5223 | struct nfs4_channel_attrs *attrs) |
| 5224 | { |
| 5225 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5226 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5227 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5228 | p = xdr_inline_decode(xdr, 28); |
| 5229 | if (unlikely(!p)) |
| 5230 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5231 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5232 | if (val) |
| 5233 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5234 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5235 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5236 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5237 | attrs->max_ops = be32_to_cpup(p++); |
| 5238 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5239 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5240 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5241 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5242 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5243 | return -EINVAL; |
| 5244 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5245 | if (nr_attrs == 1) { |
| 5246 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5247 | if (unlikely(!p)) |
| 5248 | goto out_overflow; |
| 5249 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5250 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5251 | out_overflow: |
| 5252 | print_overflow_msg(__func__, xdr); |
| 5253 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5254 | } |
| 5255 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5256 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5257 | { |
| 5258 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5259 | } |
| 5260 | |
| 5261 | static int decode_create_session(struct xdr_stream *xdr, |
| 5262 | struct nfs41_create_session_res *res) |
| 5263 | { |
| 5264 | __be32 *p; |
| 5265 | int status; |
| 5266 | struct nfs_client *clp = res->client; |
| 5267 | struct nfs4_session *session = clp->cl_session; |
| 5268 | |
| 5269 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5270 | if (!status) |
| 5271 | status = decode_sessionid(xdr, &session->sess_id); |
| 5272 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5273 | return status; |
| 5274 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5275 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5276 | p = xdr_inline_decode(xdr, 8); |
| 5277 | if (unlikely(!p)) |
| 5278 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5279 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5280 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5281 | |
| 5282 | /* Channel attributes */ |
| 5283 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5284 | if (!status) |
| 5285 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5286 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5287 | out_overflow: |
| 5288 | print_overflow_msg(__func__, xdr); |
| 5289 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5290 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5291 | |
| 5292 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5293 | { |
| 5294 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5295 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5296 | |
| 5297 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5298 | { |
| 5299 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5300 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5301 | #endif /* CONFIG_NFS_V4_1 */ |
| 5302 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5303 | static int decode_sequence(struct xdr_stream *xdr, |
| 5304 | struct nfs4_sequence_res *res, |
| 5305 | struct rpc_rqst *rqstp) |
| 5306 | { |
| 5307 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5308 | struct nfs4_sessionid id; |
| 5309 | u32 dummy; |
| 5310 | int status; |
| 5311 | __be32 *p; |
| 5312 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5313 | if (!res->sr_session) |
| 5314 | return 0; |
| 5315 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5316 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5317 | if (!status) |
| 5318 | status = decode_sessionid(xdr, &id); |
| 5319 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5320 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5321 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5322 | /* |
| 5323 | * If the server returns different values for sessionID, slotID or |
| 5324 | * sequence number, the server is looney tunes. |
| 5325 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5326 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5327 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5328 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 5329 | NFS4_MAX_SESSIONID_LEN)) { |
| 5330 | dprintk("%s Invalid session id\n", __func__); |
| 5331 | goto out_err; |
| 5332 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5333 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5334 | p = xdr_inline_decode(xdr, 20); |
| 5335 | if (unlikely(!p)) |
| 5336 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5337 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5338 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5339 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5340 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5341 | dprintk("%s Invalid sequence number\n", __func__); |
| 5342 | goto out_err; |
| 5343 | } |
| 5344 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5345 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5346 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5347 | dprintk("%s Invalid slot id\n", __func__); |
| 5348 | goto out_err; |
| 5349 | } |
| 5350 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5351 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5352 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5353 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5354 | /* result flags */ |
| 5355 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5356 | status = 0; |
| 5357 | out_err: |
| 5358 | res->sr_status = status; |
| 5359 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5360 | out_overflow: |
| 5361 | print_overflow_msg(__func__, xdr); |
| 5362 | status = -EIO; |
| 5363 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5364 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5365 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5366 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5367 | } |
| 5368 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5369 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5370 | /* |
| 5371 | * TODO: Need to handle case when EOF != true; |
| 5372 | */ |
| 5373 | static int decode_getdevicelist(struct xdr_stream *xdr, |
| 5374 | struct pnfs_devicelist *res) |
| 5375 | { |
| 5376 | __be32 *p; |
| 5377 | int status, i; |
| 5378 | struct nfs_writeverf verftemp; |
| 5379 | |
| 5380 | status = decode_op_hdr(xdr, OP_GETDEVICELIST); |
| 5381 | if (status) |
| 5382 | return status; |
| 5383 | |
| 5384 | p = xdr_inline_decode(xdr, 8 + 8 + 4); |
| 5385 | if (unlikely(!p)) |
| 5386 | goto out_overflow; |
| 5387 | |
| 5388 | /* TODO: Skip cookie for now */ |
| 5389 | p += 2; |
| 5390 | |
| 5391 | /* Read verifier */ |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5392 | p = xdr_decode_opaque_fixed(p, verftemp.verifier, NFS4_VERIFIER_SIZE); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5393 | |
| 5394 | res->num_devs = be32_to_cpup(p); |
| 5395 | |
| 5396 | dprintk("%s: num_dev %d\n", __func__, res->num_devs); |
| 5397 | |
| 5398 | if (res->num_devs > NFS4_PNFS_GETDEVLIST_MAXNUM) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5399 | printk(KERN_ERR "NFS: %s too many result dev_num %u\n", |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5400 | __func__, res->num_devs); |
| 5401 | return -EIO; |
| 5402 | } |
| 5403 | |
| 5404 | p = xdr_inline_decode(xdr, |
| 5405 | res->num_devs * NFS4_DEVICEID4_SIZE + 4); |
| 5406 | if (unlikely(!p)) |
| 5407 | goto out_overflow; |
| 5408 | for (i = 0; i < res->num_devs; i++) |
| 5409 | p = xdr_decode_opaque_fixed(p, res->dev_id[i].data, |
| 5410 | NFS4_DEVICEID4_SIZE); |
| 5411 | res->eof = be32_to_cpup(p); |
| 5412 | return 0; |
| 5413 | out_overflow: |
| 5414 | print_overflow_msg(__func__, xdr); |
| 5415 | return -EIO; |
| 5416 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5417 | |
| 5418 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5419 | struct pnfs_device *pdev) |
| 5420 | { |
| 5421 | __be32 *p; |
| 5422 | uint32_t len, type; |
| 5423 | int status; |
| 5424 | |
| 5425 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5426 | if (status) { |
| 5427 | if (status == -ETOOSMALL) { |
| 5428 | p = xdr_inline_decode(xdr, 4); |
| 5429 | if (unlikely(!p)) |
| 5430 | goto out_overflow; |
| 5431 | pdev->mincount = be32_to_cpup(p); |
| 5432 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5433 | __func__, pdev->mincount); |
| 5434 | } |
| 5435 | return status; |
| 5436 | } |
| 5437 | |
| 5438 | p = xdr_inline_decode(xdr, 8); |
| 5439 | if (unlikely(!p)) |
| 5440 | goto out_overflow; |
| 5441 | type = be32_to_cpup(p++); |
| 5442 | if (type != pdev->layout_type) { |
| 5443 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5444 | __func__, pdev->layout_type, type); |
| 5445 | return -EINVAL; |
| 5446 | } |
| 5447 | /* |
| 5448 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5449 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5450 | * and places the remaining xdr data in xdr_buf->tail |
| 5451 | */ |
| 5452 | pdev->mincount = be32_to_cpup(p); |
| 5453 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ |
| 5454 | |
| 5455 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5456 | p = xdr_inline_decode(xdr, 4); |
| 5457 | if (unlikely(!p)) |
| 5458 | goto out_overflow; |
| 5459 | len = be32_to_cpup(p); |
| 5460 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5461 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5462 | |
| 5463 | p = xdr_inline_decode(xdr, 4 * len); |
| 5464 | if (unlikely(!p)) |
| 5465 | goto out_overflow; |
| 5466 | for (i = 0; i < len; i++, p++) { |
| 5467 | if (be32_to_cpup(p)) { |
| 5468 | dprintk("%s: notifications not supported\n", |
| 5469 | __func__); |
| 5470 | return -EIO; |
| 5471 | } |
| 5472 | } |
| 5473 | } |
| 5474 | return 0; |
| 5475 | out_overflow: |
| 5476 | print_overflow_msg(__func__, xdr); |
| 5477 | return -EIO; |
| 5478 | } |
| 5479 | |
| 5480 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5481 | struct nfs4_layoutget_res *res) |
| 5482 | { |
| 5483 | __be32 *p; |
| 5484 | int status; |
| 5485 | u32 layout_count; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5486 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 5487 | struct kvec *iov = rcvbuf->head; |
| 5488 | u32 hdrlen, recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5489 | |
| 5490 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5491 | if (status) |
| 5492 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5493 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5494 | if (unlikely(!p)) |
| 5495 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5496 | res->return_on_close = be32_to_cpup(p); |
| 5497 | decode_stateid(xdr, &res->stateid); |
| 5498 | p = xdr_inline_decode(xdr, 4); |
| 5499 | if (unlikely(!p)) |
| 5500 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5501 | layout_count = be32_to_cpup(p); |
| 5502 | if (!layout_count) { |
| 5503 | dprintk("%s: server responded with empty layout array\n", |
| 5504 | __func__); |
| 5505 | return -EINVAL; |
| 5506 | } |
| 5507 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5508 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5509 | if (unlikely(!p)) |
| 5510 | goto out_overflow; |
| 5511 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5512 | p = xdr_decode_hyper(p, &res->range.length); |
| 5513 | res->range.iomode = be32_to_cpup(p++); |
| 5514 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5515 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5516 | |
| 5517 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5518 | __func__, |
| 5519 | (unsigned long)res->range.offset, |
| 5520 | (unsigned long)res->range.length, |
| 5521 | res->range.iomode, |
| 5522 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5523 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5524 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5525 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
| 5526 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5527 | if (res->layoutp->len > recvd) { |
| 5528 | dprintk("NFS: server cheating in layoutget reply: " |
| 5529 | "layout len %u > recvd %u\n", |
| 5530 | res->layoutp->len, recvd); |
| 5531 | return -EINVAL; |
| 5532 | } |
| 5533 | |
| 5534 | xdr_read_pages(xdr, res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5535 | |
| 5536 | if (layout_count > 1) { |
| 5537 | /* We only handle a length one array at the moment. Any |
| 5538 | * further entries are just ignored. Note that this means |
| 5539 | * the client may see a response that is less than the |
| 5540 | * minimum it requested. |
| 5541 | */ |
| 5542 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5543 | __func__, layout_count); |
| 5544 | } |
| 5545 | |
| 5546 | return 0; |
| 5547 | out_overflow: |
| 5548 | print_overflow_msg(__func__, xdr); |
| 5549 | return -EIO; |
| 5550 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5551 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5552 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5553 | struct nfs4_layoutreturn_res *res) |
| 5554 | { |
| 5555 | __be32 *p; |
| 5556 | int status; |
| 5557 | |
| 5558 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5559 | if (status) |
| 5560 | return status; |
| 5561 | p = xdr_inline_decode(xdr, 4); |
| 5562 | if (unlikely(!p)) |
| 5563 | goto out_overflow; |
| 5564 | res->lrs_present = be32_to_cpup(p); |
| 5565 | if (res->lrs_present) |
| 5566 | status = decode_stateid(xdr, &res->stateid); |
| 5567 | return status; |
| 5568 | out_overflow: |
| 5569 | print_overflow_msg(__func__, xdr); |
| 5570 | return -EIO; |
| 5571 | } |
| 5572 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5573 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5574 | struct rpc_rqst *req, |
| 5575 | struct nfs4_layoutcommit_res *res) |
| 5576 | { |
| 5577 | __be32 *p; |
| 5578 | __u32 sizechanged; |
| 5579 | int status; |
| 5580 | |
| 5581 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5582 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5583 | if (status) |
| 5584 | return status; |
| 5585 | |
| 5586 | p = xdr_inline_decode(xdr, 4); |
| 5587 | if (unlikely(!p)) |
| 5588 | goto out_overflow; |
| 5589 | sizechanged = be32_to_cpup(p); |
| 5590 | |
| 5591 | if (sizechanged) { |
| 5592 | /* throw away new size */ |
| 5593 | p = xdr_inline_decode(xdr, 8); |
| 5594 | if (unlikely(!p)) |
| 5595 | goto out_overflow; |
| 5596 | } |
| 5597 | return 0; |
| 5598 | out_overflow: |
| 5599 | print_overflow_msg(__func__, xdr); |
| 5600 | return -EIO; |
| 5601 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5602 | |
| 5603 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5604 | struct nfs41_test_stateid_res *res) |
| 5605 | { |
| 5606 | __be32 *p; |
| 5607 | int status; |
| 5608 | int num_res; |
| 5609 | |
| 5610 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5611 | if (status) |
| 5612 | return status; |
| 5613 | |
| 5614 | p = xdr_inline_decode(xdr, 4); |
| 5615 | if (unlikely(!p)) |
| 5616 | goto out_overflow; |
| 5617 | num_res = be32_to_cpup(p++); |
| 5618 | if (num_res != 1) |
| 5619 | goto out; |
| 5620 | |
| 5621 | p = xdr_inline_decode(xdr, 4); |
| 5622 | if (unlikely(!p)) |
| 5623 | goto out_overflow; |
| 5624 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5625 | |
| 5626 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5627 | out_overflow: |
| 5628 | print_overflow_msg(__func__, xdr); |
| 5629 | out: |
| 5630 | return -EIO; |
| 5631 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5632 | |
| 5633 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5634 | struct nfs41_free_stateid_res *res) |
| 5635 | { |
| 5636 | __be32 *p; |
| 5637 | int status; |
| 5638 | |
| 5639 | status = decode_op_hdr(xdr, OP_FREE_STATEID); |
| 5640 | if (status) |
| 5641 | return status; |
| 5642 | |
| 5643 | p = xdr_inline_decode(xdr, 4); |
| 5644 | if (unlikely(!p)) |
| 5645 | goto out_overflow; |
| 5646 | res->status = be32_to_cpup(p++); |
| 5647 | return res->status; |
| 5648 | out_overflow: |
| 5649 | print_overflow_msg(__func__, xdr); |
| 5650 | return -EIO; |
| 5651 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5652 | #endif /* CONFIG_NFS_V4_1 */ |
| 5653 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5654 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5655 | * END OF "GENERIC" DECODE ROUTINES. |
| 5656 | */ |
| 5657 | |
| 5658 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5659 | * Decode OPEN_DOWNGRADE response |
| 5660 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5661 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5662 | struct xdr_stream *xdr, |
| 5663 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5664 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5665 | struct compound_hdr hdr; |
| 5666 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5667 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5668 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5669 | if (status) |
| 5670 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5671 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5672 | if (status) |
| 5673 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5674 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5675 | if (status) |
| 5676 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5677 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5678 | if (status != 0) |
| 5679 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5680 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5681 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5682 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5683 | } |
| 5684 | |
| 5685 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5686 | * Decode ACCESS response |
| 5687 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5688 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5689 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5690 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5691 | struct compound_hdr hdr; |
| 5692 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5693 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5694 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5695 | if (status) |
| 5696 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5697 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5698 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5699 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5700 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5701 | if (status != 0) |
| 5702 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5703 | status = decode_access(xdr, res); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5704 | if (status != 0) |
| 5705 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5706 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5707 | out: |
| 5708 | return status; |
| 5709 | } |
| 5710 | |
| 5711 | /* |
| 5712 | * Decode LOOKUP response |
| 5713 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5714 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5715 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5716 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5717 | struct compound_hdr hdr; |
| 5718 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5719 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5720 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5721 | if (status) |
| 5722 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5723 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5724 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5725 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5726 | status = decode_putfh(xdr); |
| 5727 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5728 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5729 | status = decode_lookup(xdr); |
| 5730 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5731 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5732 | status = decode_getfh(xdr, res->fh); |
| 5733 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5734 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5735 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5736 | out: |
| 5737 | return status; |
| 5738 | } |
| 5739 | |
| 5740 | /* |
| 5741 | * Decode LOOKUP_ROOT response |
| 5742 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5743 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 5744 | struct xdr_stream *xdr, |
| 5745 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5746 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5747 | struct compound_hdr hdr; |
| 5748 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5749 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5750 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5751 | if (status) |
| 5752 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5753 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5754 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5755 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5756 | status = decode_putrootfh(xdr); |
| 5757 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5758 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5759 | status = decode_getfh(xdr, res->fh); |
| 5760 | if (status == 0) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5761 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5762 | out: |
| 5763 | return status; |
| 5764 | } |
| 5765 | |
| 5766 | /* |
| 5767 | * Decode REMOVE response |
| 5768 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5769 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5770 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5771 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5772 | struct compound_hdr hdr; |
| 5773 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5774 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5775 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5776 | if (status) |
| 5777 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5778 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5779 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5780 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5781 | status = decode_putfh(xdr); |
| 5782 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5783 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5784 | status = decode_remove(xdr, &res->cinfo); |
| 5785 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5786 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5787 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5788 | out: |
| 5789 | return status; |
| 5790 | } |
| 5791 | |
| 5792 | /* |
| 5793 | * Decode RENAME response |
| 5794 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5795 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5796 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5797 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5798 | struct compound_hdr hdr; |
| 5799 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5800 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5801 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5802 | if (status) |
| 5803 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5804 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5805 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5806 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5807 | status = decode_putfh(xdr); |
| 5808 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5809 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5810 | status = decode_savefh(xdr); |
| 5811 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5812 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5813 | status = decode_putfh(xdr); |
| 5814 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5815 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5816 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
| 5817 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5818 | goto out; |
| 5819 | /* Current FH is target directory */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5820 | if (decode_getfattr(xdr, res->new_fattr, res->server)) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5821 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5822 | status = decode_restorefh(xdr); |
| 5823 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5824 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5825 | decode_getfattr(xdr, res->old_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5826 | out: |
| 5827 | return status; |
| 5828 | } |
| 5829 | |
| 5830 | /* |
| 5831 | * Decode LINK response |
| 5832 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5833 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5834 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5835 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5836 | struct compound_hdr hdr; |
| 5837 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5838 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5839 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5840 | if (status) |
| 5841 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5842 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5843 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5844 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5845 | status = decode_putfh(xdr); |
| 5846 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5847 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5848 | status = decode_savefh(xdr); |
| 5849 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5850 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5851 | status = decode_putfh(xdr); |
| 5852 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5853 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5854 | status = decode_link(xdr, &res->cinfo); |
| 5855 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5856 | goto out; |
| 5857 | /* |
| 5858 | * Note order: OP_LINK leaves the directory as the current |
| 5859 | * filehandle. |
| 5860 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5861 | if (decode_getfattr(xdr, res->dir_attr, res->server)) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5862 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5863 | status = decode_restorefh(xdr); |
| 5864 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5865 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5866 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5867 | out: |
| 5868 | return status; |
| 5869 | } |
| 5870 | |
| 5871 | /* |
| 5872 | * Decode CREATE response |
| 5873 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5874 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5875 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5876 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5877 | struct compound_hdr hdr; |
| 5878 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5879 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5880 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5881 | if (status) |
| 5882 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5883 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5884 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5885 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5886 | status = decode_putfh(xdr); |
| 5887 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5888 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5889 | status = decode_create(xdr, &res->dir_cinfo); |
| 5890 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5891 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5892 | status = decode_getfh(xdr, res->fh); |
| 5893 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5894 | goto out; |
Trond Myklebust | 7c317fc | 2012-04-27 13:48:18 -0400 | [diff] [blame^] | 5895 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5896 | out: |
| 5897 | return status; |
| 5898 | } |
| 5899 | |
| 5900 | /* |
| 5901 | * Decode SYMLINK response |
| 5902 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5903 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5904 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5905 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5906 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5907 | } |
| 5908 | |
| 5909 | /* |
| 5910 | * Decode GETATTR response |
| 5911 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5912 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5913 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5914 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5915 | struct compound_hdr hdr; |
| 5916 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5917 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5918 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5919 | if (status) |
| 5920 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5921 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5922 | if (status) |
| 5923 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5924 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5925 | if (status) |
| 5926 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5927 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5928 | out: |
| 5929 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5930 | } |
| 5931 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5932 | /* |
| 5933 | * Encode an SETACL request |
| 5934 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 5935 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 5936 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5937 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5938 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 5939 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5940 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5941 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 5942 | encode_compound_hdr(xdr, req, &hdr); |
| 5943 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 5944 | encode_putfh(xdr, args->fh, &hdr); |
| 5945 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 5946 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5947 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5948 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5949 | /* |
| 5950 | * Decode SETACL response |
| 5951 | */ |
| 5952 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5953 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 5954 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5955 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5956 | struct compound_hdr hdr; |
| 5957 | int status; |
| 5958 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5959 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [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) |
| 5964 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5965 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5966 | if (status) |
| 5967 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5968 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5969 | out: |
| 5970 | return status; |
| 5971 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5972 | |
| 5973 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5974 | * Decode GETACL response |
| 5975 | */ |
| 5976 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5977 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 5978 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5979 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5980 | struct compound_hdr hdr; |
| 5981 | int status; |
| 5982 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 5983 | if (res->acl_scratch != NULL) { |
| 5984 | void *p = page_address(res->acl_scratch); |
| 5985 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 5986 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5987 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5988 | if (status) |
| 5989 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5990 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5991 | if (status) |
| 5992 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5993 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5994 | if (status) |
| 5995 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5996 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5997 | |
| 5998 | out: |
| 5999 | return status; |
| 6000 | } |
| 6001 | |
| 6002 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6003 | * Decode CLOSE response |
| 6004 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6005 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6006 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6007 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6008 | struct compound_hdr hdr; |
| 6009 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6010 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6011 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6012 | if (status) |
| 6013 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6014 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6015 | if (status) |
| 6016 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6017 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6018 | if (status) |
| 6019 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6020 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6021 | if (status != 0) |
| 6022 | goto out; |
| 6023 | /* |
| 6024 | * Note: Server may do delete on close for this file |
| 6025 | * in which case the getattr call will fail with |
| 6026 | * an ESTALE error. Shouldn't be a problem, |
| 6027 | * though, since fattr->valid will remain unset. |
| 6028 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6029 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6030 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6031 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6032 | } |
| 6033 | |
| 6034 | /* |
| 6035 | * Decode OPEN response |
| 6036 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6037 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6038 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6039 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6040 | struct compound_hdr hdr; |
| 6041 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6042 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6043 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6044 | if (status) |
| 6045 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6046 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6047 | if (status) |
| 6048 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6049 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6050 | if (status) |
| 6051 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6052 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6053 | if (status) |
| 6054 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6055 | if (decode_getfh(xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6056 | goto out; |
Trond Myklebust | 90ff0c5 | 2012-04-27 13:48:18 -0400 | [diff] [blame] | 6057 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6058 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6059 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6060 | } |
| 6061 | |
| 6062 | /* |
| 6063 | * Decode OPEN_CONFIRM response |
| 6064 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6065 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6066 | struct xdr_stream *xdr, |
| 6067 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6068 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6069 | struct compound_hdr hdr; |
| 6070 | int status; |
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 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6073 | if (status) |
| 6074 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6075 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6076 | if (status) |
| 6077 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6078 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6079 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6080 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6081 | } |
| 6082 | |
| 6083 | /* |
| 6084 | * Decode OPEN response |
| 6085 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6086 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6087 | struct xdr_stream *xdr, |
| 6088 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6089 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6090 | struct compound_hdr hdr; |
| 6091 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6092 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6093 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6094 | if (status) |
| 6095 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6096 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6097 | if (status) |
| 6098 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6099 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6100 | if (status) |
| 6101 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6102 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6103 | if (status) |
| 6104 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6105 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6106 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6107 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6108 | } |
| 6109 | |
| 6110 | /* |
| 6111 | * Decode SETATTR response |
| 6112 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6113 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6114 | struct xdr_stream *xdr, |
| 6115 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6116 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6117 | struct compound_hdr hdr; |
| 6118 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6119 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6120 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6121 | if (status) |
| 6122 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6123 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6124 | if (status) |
| 6125 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6126 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6127 | if (status) |
| 6128 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6129 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6130 | if (status) |
| 6131 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6132 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6133 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6134 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6135 | } |
| 6136 | |
| 6137 | /* |
| 6138 | * Decode LOCK response |
| 6139 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6140 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6141 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | struct compound_hdr hdr; |
| 6144 | int status; |
| 6145 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6146 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6147 | if (status) |
| 6148 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6149 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6150 | if (status) |
| 6151 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6152 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6153 | if (status) |
| 6154 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6155 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6156 | out: |
| 6157 | return status; |
| 6158 | } |
| 6159 | |
| 6160 | /* |
| 6161 | * Decode LOCKT response |
| 6162 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6163 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6164 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6166 | struct compound_hdr hdr; |
| 6167 | int status; |
| 6168 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6169 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6170 | if (status) |
| 6171 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6172 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6173 | if (status) |
| 6174 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6175 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6176 | if (status) |
| 6177 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6178 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6179 | out: |
| 6180 | return status; |
| 6181 | } |
| 6182 | |
| 6183 | /* |
| 6184 | * Decode LOCKU response |
| 6185 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6186 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6187 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6188 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6189 | struct compound_hdr hdr; |
| 6190 | int status; |
| 6191 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6192 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6193 | if (status) |
| 6194 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6195 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6196 | if (status) |
| 6197 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6198 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6199 | if (status) |
| 6200 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6201 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | out: |
| 6203 | return status; |
| 6204 | } |
| 6205 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6206 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6207 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6208 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6209 | struct compound_hdr hdr; |
| 6210 | int status; |
| 6211 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6212 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6213 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6214 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6215 | return status; |
| 6216 | } |
| 6217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6218 | /* |
| 6219 | * Decode READLINK response |
| 6220 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6221 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6222 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6223 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6224 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6225 | struct compound_hdr hdr; |
| 6226 | int status; |
| 6227 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6228 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | if (status) |
| 6230 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6231 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6232 | if (status) |
| 6233 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6234 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6235 | if (status) |
| 6236 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6237 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6238 | out: |
| 6239 | return status; |
| 6240 | } |
| 6241 | |
| 6242 | /* |
| 6243 | * Decode READDIR response |
| 6244 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6245 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6246 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6247 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6248 | struct compound_hdr hdr; |
| 6249 | int status; |
| 6250 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6251 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6252 | if (status) |
| 6253 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6254 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6255 | if (status) |
| 6256 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6257 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6258 | if (status) |
| 6259 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6260 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6261 | out: |
| 6262 | return status; |
| 6263 | } |
| 6264 | |
| 6265 | /* |
| 6266 | * Decode Read response |
| 6267 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6268 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6269 | struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6271 | struct compound_hdr hdr; |
| 6272 | int status; |
| 6273 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6274 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6275 | if (status) |
| 6276 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6277 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6278 | if (status) |
| 6279 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6280 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6281 | if (status) |
| 6282 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6283 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6284 | if (!status) |
| 6285 | status = res->count; |
| 6286 | out: |
| 6287 | return status; |
| 6288 | } |
| 6289 | |
| 6290 | /* |
| 6291 | * Decode WRITE response |
| 6292 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6294 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6295 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6296 | struct compound_hdr hdr; |
| 6297 | int status; |
| 6298 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6299 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6300 | if (status) |
| 6301 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6302 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6303 | if (status) |
| 6304 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6305 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | if (status) |
| 6307 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6308 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6309 | if (status) |
| 6310 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6311 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6312 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6313 | if (!status) |
| 6314 | status = res->count; |
| 6315 | out: |
| 6316 | return status; |
| 6317 | } |
| 6318 | |
| 6319 | /* |
| 6320 | * Decode COMMIT response |
| 6321 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6322 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 6323 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6324 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6325 | struct compound_hdr hdr; |
| 6326 | int status; |
| 6327 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6328 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6329 | if (status) |
| 6330 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6332 | if (status) |
| 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6335 | if (status) |
| 6336 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6337 | status = decode_commit(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6338 | if (status) |
| 6339 | goto out; |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 6340 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6341 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6342 | out: |
| 6343 | return status; |
| 6344 | } |
| 6345 | |
| 6346 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6347 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6348 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6349 | 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] | 6350 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6351 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6352 | struct compound_hdr hdr; |
| 6353 | int status; |
| 6354 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6355 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6356 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6357 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6358 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6359 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6360 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6361 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | return status; |
| 6363 | } |
| 6364 | |
| 6365 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6366 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6367 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6368 | 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] | 6369 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | struct compound_hdr hdr; |
| 6372 | int status; |
| 6373 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6374 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6376 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6377 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6378 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6379 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6380 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | return status; |
| 6382 | } |
| 6383 | |
| 6384 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6385 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6386 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6387 | 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] | 6388 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6389 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6390 | struct compound_hdr hdr; |
| 6391 | int status; |
| 6392 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6393 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6394 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6395 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6396 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6397 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6399 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6400 | return status; |
| 6401 | } |
| 6402 | |
| 6403 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6404 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6405 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6406 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6407 | struct xdr_stream *xdr, |
| 6408 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6409 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6410 | struct compound_hdr hdr; |
| 6411 | int status; |
| 6412 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6413 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6414 | if (status) |
| 6415 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6416 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6417 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6418 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6419 | status = decode_putfh(xdr); |
| 6420 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6421 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6422 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6423 | out: |
| 6424 | return status; |
| 6425 | } |
| 6426 | |
| 6427 | /* |
| 6428 | * Decode RENEW response |
| 6429 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6430 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6431 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6432 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6433 | struct compound_hdr hdr; |
| 6434 | int status; |
| 6435 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6436 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6437 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6438 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6439 | return status; |
| 6440 | } |
| 6441 | |
| 6442 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6443 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6444 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6445 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6446 | struct xdr_stream *xdr, |
| 6447 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6448 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6449 | struct compound_hdr hdr; |
| 6450 | int status; |
| 6451 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6452 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6453 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6454 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6455 | return status; |
| 6456 | } |
| 6457 | |
| 6458 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6459 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6460 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6461 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
| 6462 | struct xdr_stream *xdr, |
| 6463 | struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6464 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6465 | struct compound_hdr hdr; |
| 6466 | int status; |
| 6467 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6468 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6469 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6470 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6472 | status = decode_putrootfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6473 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6474 | status = decode_fsinfo(xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | return status; |
| 6476 | } |
| 6477 | |
| 6478 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6479 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6480 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6481 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6482 | struct xdr_stream *xdr, |
| 6483 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6484 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6485 | struct compound_hdr hdr; |
| 6486 | int status; |
| 6487 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6488 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6489 | if (status) |
| 6490 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6491 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6492 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6493 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6494 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6495 | if (status != 0) |
| 6496 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6497 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6498 | if (status != 0) |
| 6499 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6500 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6501 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | return status; |
| 6503 | } |
| 6504 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6505 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6506 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6507 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6508 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6509 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6510 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6511 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6512 | struct compound_hdr hdr; |
| 6513 | int status; |
| 6514 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6515 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6516 | if (status) |
| 6517 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6518 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6519 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6520 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6521 | status = decode_putfh(xdr); |
| 6522 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6523 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6524 | status = decode_lookup(xdr); |
| 6525 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6526 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6527 | xdr_enter_page(xdr, PAGE_SIZE); |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6528 | status = decode_getfattr_generic(xdr, &res->fs_locations->fattr, |
| 6529 | NULL, res->fs_locations, |
| 6530 | res->fs_locations->server); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6531 | out: |
| 6532 | return status; |
| 6533 | } |
| 6534 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6535 | /* |
| 6536 | * Decode SECINFO response |
| 6537 | */ |
| 6538 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6539 | struct xdr_stream *xdr, |
| 6540 | struct nfs4_secinfo_res *res) |
| 6541 | { |
| 6542 | struct compound_hdr hdr; |
| 6543 | int status; |
| 6544 | |
| 6545 | status = decode_compound_hdr(xdr, &hdr); |
| 6546 | if (status) |
| 6547 | goto out; |
| 6548 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6549 | if (status) |
| 6550 | goto out; |
| 6551 | status = decode_putfh(xdr); |
| 6552 | if (status) |
| 6553 | goto out; |
| 6554 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6555 | out: |
| 6556 | return status; |
| 6557 | } |
| 6558 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6559 | #if defined(CONFIG_NFS_V4_1) |
| 6560 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6561 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6562 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6563 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6564 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6565 | void *res) |
| 6566 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6567 | struct compound_hdr hdr; |
| 6568 | int status; |
| 6569 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6570 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6571 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6572 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6573 | return status; |
| 6574 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6575 | |
| 6576 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6577 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6578 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6579 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6580 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6581 | struct nfs41_create_session_res *res) |
| 6582 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [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 | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6587 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6588 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6589 | return status; |
| 6590 | } |
| 6591 | |
| 6592 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6593 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6594 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6595 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6596 | struct xdr_stream *xdr, |
| 6597 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6598 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6599 | struct compound_hdr hdr; |
| 6600 | int status; |
| 6601 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6602 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6603 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6604 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6605 | return status; |
| 6606 | } |
| 6607 | |
| 6608 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6609 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6610 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6611 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6612 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6613 | struct nfs4_sequence_res *res) |
| 6614 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6615 | struct compound_hdr hdr; |
| 6616 | int status; |
| 6617 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6618 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6619 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6620 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6621 | return status; |
| 6622 | } |
| 6623 | |
| 6624 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6625 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6626 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6627 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6628 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6629 | struct nfs4_get_lease_time_res *res) |
| 6630 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6631 | struct compound_hdr hdr; |
| 6632 | int status; |
| 6633 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6634 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6635 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6636 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6637 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6638 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6639 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6640 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6641 | return status; |
| 6642 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6643 | |
| 6644 | /* |
| 6645 | * Decode RECLAIM_COMPLETE response |
| 6646 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6647 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 6648 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6649 | struct nfs41_reclaim_complete_res *res) |
| 6650 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6651 | struct compound_hdr hdr; |
| 6652 | int status; |
| 6653 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6654 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6655 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6656 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6657 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6658 | status = decode_reclaim_complete(xdr, (void *)NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6659 | return status; |
| 6660 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6661 | |
| 6662 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 6663 | * Decode GETDEVICELIST response |
| 6664 | */ |
| 6665 | static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst *rqstp, |
| 6666 | struct xdr_stream *xdr, |
| 6667 | struct nfs4_getdevicelist_res *res) |
| 6668 | { |
| 6669 | struct compound_hdr hdr; |
| 6670 | int status; |
| 6671 | |
| 6672 | dprintk("encoding getdevicelist!\n"); |
| 6673 | |
| 6674 | status = decode_compound_hdr(xdr, &hdr); |
| 6675 | if (status != 0) |
| 6676 | goto out; |
| 6677 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6678 | if (status != 0) |
| 6679 | goto out; |
| 6680 | status = decode_putfh(xdr); |
| 6681 | if (status != 0) |
| 6682 | goto out; |
| 6683 | status = decode_getdevicelist(xdr, res->devlist); |
| 6684 | out: |
| 6685 | return status; |
| 6686 | } |
| 6687 | |
| 6688 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6689 | * Decode GETDEVINFO response |
| 6690 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6691 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 6692 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6693 | struct nfs4_getdeviceinfo_res *res) |
| 6694 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6695 | struct compound_hdr hdr; |
| 6696 | int status; |
| 6697 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6698 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6699 | if (status != 0) |
| 6700 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6701 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6702 | if (status != 0) |
| 6703 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6704 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6705 | out: |
| 6706 | return status; |
| 6707 | } |
| 6708 | |
| 6709 | /* |
| 6710 | * Decode LAYOUTGET response |
| 6711 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6712 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 6713 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6714 | struct nfs4_layoutget_res *res) |
| 6715 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6716 | struct compound_hdr hdr; |
| 6717 | int status; |
| 6718 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6719 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6720 | if (status) |
| 6721 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6722 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6723 | if (status) |
| 6724 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6725 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6726 | if (status) |
| 6727 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6728 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6729 | out: |
| 6730 | return status; |
| 6731 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6732 | |
| 6733 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6734 | * Decode LAYOUTRETURN response |
| 6735 | */ |
| 6736 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 6737 | struct xdr_stream *xdr, |
| 6738 | struct nfs4_layoutreturn_res *res) |
| 6739 | { |
| 6740 | struct compound_hdr hdr; |
| 6741 | int status; |
| 6742 | |
| 6743 | status = decode_compound_hdr(xdr, &hdr); |
| 6744 | if (status) |
| 6745 | goto out; |
| 6746 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6747 | if (status) |
| 6748 | goto out; |
| 6749 | status = decode_putfh(xdr); |
| 6750 | if (status) |
| 6751 | goto out; |
| 6752 | status = decode_layoutreturn(xdr, res); |
| 6753 | out: |
| 6754 | return status; |
| 6755 | } |
| 6756 | |
| 6757 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6758 | * Decode LAYOUTCOMMIT response |
| 6759 | */ |
| 6760 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 6761 | struct xdr_stream *xdr, |
| 6762 | struct nfs4_layoutcommit_res *res) |
| 6763 | { |
| 6764 | struct compound_hdr hdr; |
| 6765 | int status; |
| 6766 | |
| 6767 | status = decode_compound_hdr(xdr, &hdr); |
| 6768 | if (status) |
| 6769 | goto out; |
| 6770 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6771 | if (status) |
| 6772 | goto out; |
| 6773 | status = decode_putfh(xdr); |
| 6774 | if (status) |
| 6775 | goto out; |
| 6776 | status = decode_layoutcommit(xdr, rqstp, res); |
| 6777 | if (status) |
| 6778 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6779 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6780 | out: |
| 6781 | return status; |
| 6782 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6783 | |
| 6784 | /* |
| 6785 | * Decode SECINFO_NO_NAME response |
| 6786 | */ |
| 6787 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 6788 | struct xdr_stream *xdr, |
| 6789 | struct nfs4_secinfo_res *res) |
| 6790 | { |
| 6791 | struct compound_hdr hdr; |
| 6792 | int status; |
| 6793 | |
| 6794 | status = decode_compound_hdr(xdr, &hdr); |
| 6795 | if (status) |
| 6796 | goto out; |
| 6797 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6798 | if (status) |
| 6799 | goto out; |
| 6800 | status = decode_putrootfh(xdr); |
| 6801 | if (status) |
| 6802 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 6803 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6804 | out: |
| 6805 | return status; |
| 6806 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6807 | |
| 6808 | /* |
| 6809 | * Decode TEST_STATEID response |
| 6810 | */ |
| 6811 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 6812 | struct xdr_stream *xdr, |
| 6813 | struct nfs41_test_stateid_res *res) |
| 6814 | { |
| 6815 | struct compound_hdr hdr; |
| 6816 | int status; |
| 6817 | |
| 6818 | status = decode_compound_hdr(xdr, &hdr); |
| 6819 | if (status) |
| 6820 | goto out; |
| 6821 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6822 | if (status) |
| 6823 | goto out; |
| 6824 | status = decode_test_stateid(xdr, res); |
| 6825 | out: |
| 6826 | return status; |
| 6827 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6828 | |
| 6829 | /* |
| 6830 | * Decode FREE_STATEID response |
| 6831 | */ |
| 6832 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 6833 | struct xdr_stream *xdr, |
| 6834 | struct nfs41_free_stateid_res *res) |
| 6835 | { |
| 6836 | struct compound_hdr hdr; |
| 6837 | int status; |
| 6838 | |
| 6839 | status = decode_compound_hdr(xdr, &hdr); |
| 6840 | if (status) |
| 6841 | goto out; |
| 6842 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6843 | if (status) |
| 6844 | goto out; |
| 6845 | status = decode_free_stateid(xdr, res); |
| 6846 | out: |
| 6847 | return status; |
| 6848 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6849 | #endif /* CONFIG_NFS_V4_1 */ |
| 6850 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6851 | /** |
| 6852 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 6853 | * the local page cache. |
| 6854 | * @xdr: XDR stream where entry resides |
| 6855 | * @entry: buffer to fill in with entry data |
| 6856 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 6857 | * |
| 6858 | * Returns zero if successful, otherwise a negative errno value is |
| 6859 | * returned. |
| 6860 | * |
| 6861 | * This function is not invoked during READDIR reply decoding, but |
| 6862 | * rather whenever an application invokes the getdents(2) system call |
| 6863 | * on a directory already in our cache. |
| 6864 | */ |
| 6865 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 6866 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6867 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 6868 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6869 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6870 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 6871 | if (unlikely(!p)) |
| 6872 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6873 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6874 | p = xdr_inline_decode(xdr, 4); |
| 6875 | if (unlikely(!p)) |
| 6876 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6877 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6878 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6879 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6880 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6881 | } |
| 6882 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6883 | p = xdr_inline_decode(xdr, 12); |
| 6884 | if (unlikely(!p)) |
| 6885 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6886 | entry->prev_cookie = entry->cookie; |
| 6887 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6888 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6889 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6890 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6891 | if (unlikely(!p)) |
| 6892 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6893 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6894 | |
| 6895 | /* |
| 6896 | * In case the server doesn't return an inode number, |
| 6897 | * we fake one here. (We don't use inode number 0, |
| 6898 | * since glibc seems to choke on it...) |
| 6899 | */ |
| 6900 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 6901 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6902 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6903 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6904 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6905 | |
| 6906 | if (decode_attr_length(xdr, &len, &p) < 0) |
| 6907 | goto out_overflow; |
| 6908 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6909 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6910 | NULL, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6911 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 6912 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 6913 | entry->ino = entry->fattr->mounted_on_fileid; |
| 6914 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6915 | entry->ino = entry->fattr->fileid; |
| 6916 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 6917 | entry->d_type = DT_UNKNOWN; |
| 6918 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 6919 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 6920 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6921 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6922 | |
| 6923 | out_overflow: |
| 6924 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6925 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6926 | } |
| 6927 | |
| 6928 | /* |
| 6929 | * We need to translate between nfs status return values and |
| 6930 | * the local errno values which may not be the same. |
| 6931 | */ |
| 6932 | static struct { |
| 6933 | int stat; |
| 6934 | int errno; |
| 6935 | } nfs_errtbl[] = { |
| 6936 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6937 | { NFS4ERR_PERM, -EPERM }, |
| 6938 | { NFS4ERR_NOENT, -ENOENT }, |
| 6939 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 6940 | { NFS4ERR_NXIO, -ENXIO }, |
| 6941 | { NFS4ERR_ACCESS, -EACCES }, |
| 6942 | { NFS4ERR_EXIST, -EEXIST }, |
| 6943 | { NFS4ERR_XDEV, -EXDEV }, |
| 6944 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 6945 | { NFS4ERR_ISDIR, -EISDIR }, |
| 6946 | { NFS4ERR_INVAL, -EINVAL }, |
| 6947 | { NFS4ERR_FBIG, -EFBIG }, |
| 6948 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 6949 | { NFS4ERR_ROFS, -EROFS }, |
| 6950 | { NFS4ERR_MLINK, -EMLINK }, |
| 6951 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 6952 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 6953 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 6954 | { NFS4ERR_STALE, -ESTALE }, |
| 6955 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6956 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 6957 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 6958 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 6959 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6960 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 6961 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6962 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 6963 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 6964 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6965 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6966 | }; |
| 6967 | |
| 6968 | /* |
| 6969 | * Convert an NFS error code to a local one. |
| 6970 | * This one is used jointly by NFSv2 and NFSv3. |
| 6971 | */ |
| 6972 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 6973 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6974 | { |
| 6975 | int i; |
| 6976 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 6977 | if (nfs_errtbl[i].stat == stat) |
| 6978 | return nfs_errtbl[i].errno; |
| 6979 | } |
| 6980 | if (stat <= 10000 || stat > 10100) { |
| 6981 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 6982 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6983 | } |
| 6984 | /* If we cannot translate the error, the recovery routines should |
| 6985 | * handle it. |
| 6986 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 6987 | * not conflict with native Linux error codes. |
| 6988 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6989 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6990 | } |
| 6991 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6992 | #define PROC(proc, argtype, restype) \ |
| 6993 | [NFSPROC4_CLNT_##proc] = { \ |
| 6994 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6995 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6996 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 6997 | .p_arglen = NFS4_##argtype##_sz, \ |
| 6998 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 6999 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7000 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7001 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7002 | |
| 7003 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7004 | PROC(READ, enc_read, dec_read), |
| 7005 | PROC(WRITE, enc_write, dec_write), |
| 7006 | PROC(COMMIT, enc_commit, dec_commit), |
| 7007 | PROC(OPEN, enc_open, dec_open), |
| 7008 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7009 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7010 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7011 | PROC(CLOSE, enc_close, dec_close), |
| 7012 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7013 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7014 | PROC(RENEW, enc_renew, dec_renew), |
| 7015 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7016 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7017 | PROC(LOCK, enc_lock, dec_lock), |
| 7018 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7019 | PROC(LOCKU, enc_locku, dec_locku), |
| 7020 | PROC(ACCESS, enc_access, dec_access), |
| 7021 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7022 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7023 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7024 | PROC(REMOVE, enc_remove, dec_remove), |
| 7025 | PROC(RENAME, enc_rename, dec_rename), |
| 7026 | PROC(LINK, enc_link, dec_link), |
| 7027 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7028 | PROC(CREATE, enc_create, dec_create), |
| 7029 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7030 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7031 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7032 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7033 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7034 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7035 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7036 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7037 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7038 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7039 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7040 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7041 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7042 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7043 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7044 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7045 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7046 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7047 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7048 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7049 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7050 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7051 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7052 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7053 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 7054 | PROC(GETDEVICELIST, enc_getdevicelist, dec_getdevicelist), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7055 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7056 | }; |
| 7057 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7058 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7059 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7060 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7061 | .procs = nfs4_procedures |
| 7062 | }; |
| 7063 | |
| 7064 | /* |
| 7065 | * Local variables: |
| 7066 | * c-basic-offset: 8 |
| 7067 | * End: |
| 7068 | */ |