Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * fs/nfs/nfs4xdr.c |
| 3 | * |
| 4 | * Client-side XDR for NFSv4. |
| 5 | * |
| 6 | * Copyright (c) 2002 The Regents of the University of Michigan. |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Kendrick Smith <kmsmith@umich.edu> |
| 10 | * Andy Adamson <andros@umich.edu> |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * |
| 16 | * 1. Redistributions of source code must retain the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer. |
| 18 | * 2. Redistributions in binary form must reproduce the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer in the |
| 20 | * documentation and/or other materials provided with the distribution. |
| 21 | * 3. Neither the name of the University nor the names of its |
| 22 | * contributors may be used to endorse or promote products derived |
| 23 | * from this software without specific prior written permission. |
| 24 | * |
| 25 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 26 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 28 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ |
| 37 | |
| 38 | #include <linux/param.h> |
| 39 | #include <linux/time.h> |
| 40 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/errno.h> |
| 42 | #include <linux/string.h> |
| 43 | #include <linux/in.h> |
| 44 | #include <linux/pagemap.h> |
| 45 | #include <linux/proc_fs.h> |
| 46 | #include <linux/kdev_t.h> |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 47 | #include <linux/module.h> |
| 48 | #include <linux/utsname.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/sunrpc/clnt.h> |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 50 | #include <linux/sunrpc/msg_prot.h> |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 51 | #include <linux/sunrpc/gss_api.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/nfs.h> |
| 53 | #include <linux/nfs4.h> |
| 54 | #include <linux/nfs_fs.h> |
| 55 | #include <linux/nfs_idmap.h> |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 56 | #include "nfs4_fs.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 57 | #include "internal.h" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 58 | #include "pnfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 61 | |
| 62 | /* Mapping from NFS error code to "errno" error code. */ |
| 63 | #define errno_NFSERR_IO EIO |
| 64 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 65 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 68 | #ifdef DEBUG |
| 69 | #define NFS4_MAXTAGLEN 20 |
| 70 | #else |
| 71 | #define NFS4_MAXTAGLEN 0 |
| 72 | #endif |
| 73 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 74 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 75 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | */ |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 77 | #define open_owner_id_maxsz (1 + 1 + 4) |
| 78 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 79 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 81 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 82 | #define op_encode_hdr_maxsz (1) |
| 83 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 84 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 85 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 86 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 87 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 89 | (NFS4_FHSIZE >> 2)) |
| 90 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 91 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 92 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 93 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 94 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 95 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 96 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 97 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 99 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 100 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 101 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 102 | /* This is based on getfattr, which uses the most attributes: */ |
| 103 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 104 | 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 105 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 106 | nfs4_fattr_value_maxsz) |
| 107 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 108 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 109 | 1 + 2 + 1 + \ |
| 110 | nfs4_owner_maxsz + \ |
| 111 | nfs4_group_maxsz + \ |
| 112 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 114 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 115 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 116 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 117 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 118 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 119 | * layout types will be returned. |
| 120 | */ |
| 121 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 122 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 124 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 125 | #define encode_setclientid_maxsz \ |
| 126 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 127 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 128 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 129 | 1 /* sc_prog */ + \ |
| 130 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 131 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
| 132 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | #define decode_setclientid_maxsz \ |
| 134 | (op_decode_hdr_maxsz + \ |
| 135 | 2 + \ |
| 136 | 1024) /* large value for CLID_INUSE */ |
| 137 | #define encode_setclientid_confirm_maxsz \ |
| 138 | (op_encode_hdr_maxsz + \ |
| 139 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 140 | #define decode_setclientid_confirm_maxsz \ |
| 141 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 142 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 143 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 144 | #define encode_share_access_maxsz \ |
| 145 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 146 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 147 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 148 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 149 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 150 | 2 + encode_share_access_maxsz + 2 + \ |
| 151 | open_owner_id_maxsz + \ |
| 152 | encode_opentype_maxsz + \ |
| 153 | encode_claim_null_maxsz) |
| 154 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 155 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 156 | decode_ace_maxsz) |
| 157 | #define decode_change_info_maxsz (5) |
| 158 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 159 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 160 | decode_change_info_maxsz + 1 + \ |
| 161 | nfs4_fattr_bitmap_maxsz + \ |
| 162 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 163 | #define encode_open_confirm_maxsz \ |
| 164 | (op_encode_hdr_maxsz + \ |
| 165 | encode_stateid_maxsz + 1) |
| 166 | #define decode_open_confirm_maxsz \ |
| 167 | (op_decode_hdr_maxsz + \ |
| 168 | decode_stateid_maxsz) |
| 169 | #define encode_open_downgrade_maxsz \ |
| 170 | (op_encode_hdr_maxsz + \ |
| 171 | encode_stateid_maxsz + 1 + \ |
| 172 | encode_share_access_maxsz) |
| 173 | #define decode_open_downgrade_maxsz \ |
| 174 | (op_decode_hdr_maxsz + \ |
| 175 | decode_stateid_maxsz) |
| 176 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 177 | 1 + encode_stateid_maxsz) |
| 178 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 179 | decode_stateid_maxsz) |
| 180 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 181 | encode_stateid_maxsz + \ |
| 182 | encode_attrs_maxsz) |
| 183 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 184 | nfs4_fattr_bitmap_maxsz) |
| 185 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 186 | encode_stateid_maxsz + 3) |
| 187 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 188 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
| 189 | 2 + encode_verifier_maxsz + 5) |
| 190 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
| 191 | decode_verifier_maxsz) |
| 192 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 193 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 194 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 195 | encode_stateid_maxsz + 4) |
| 196 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 197 | 2 + decode_verifier_maxsz) |
| 198 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 199 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 200 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 202 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 203 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 204 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 206 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 207 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 208 | decode_change_info_maxsz + \ |
| 209 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 211 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 212 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 213 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 214 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 215 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 216 | 1 + encode_stateid_maxsz + 1 + \ |
| 217 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 218 | #define decode_lock_denied_maxsz \ |
| 219 | (8 + decode_lockowner_maxsz) |
| 220 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 221 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 222 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 223 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 224 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 225 | decode_lock_denied_maxsz) |
| 226 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 227 | encode_stateid_maxsz + \ |
| 228 | 4) |
| 229 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 230 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 231 | #define encode_release_lockowner_maxsz \ |
| 232 | (op_encode_hdr_maxsz + \ |
| 233 | encode_lockowner_maxsz) |
| 234 | #define decode_release_lockowner_maxsz \ |
| 235 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 236 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 237 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 239 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 240 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 241 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 243 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 244 | 1 + 2 + nfs4_name_maxsz + \ |
| 245 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 246 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 247 | decode_change_info_maxsz + \ |
| 248 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 249 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 250 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 252 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 253 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 254 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 255 | nfs4_fattr_bitmap_maxsz + 1) |
| 256 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 257 | encode_stateid_maxsz + 3) |
| 258 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 259 | #define encode_fs_locations_maxsz \ |
| 260 | (encode_getattr_maxsz) |
| 261 | #define decode_fs_locations_maxsz \ |
| 262 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 263 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 264 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 265 | |
| 266 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 267 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
| 268 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 269 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 270 | encode_verifier_maxsz + \ |
| 271 | 1 /* co_ownerid.len */ + \ |
| 272 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 273 | 1 /* flags */ + \ |
| 274 | 1 /* spa_how */ + \ |
| 275 | 0 /* SP4_NONE (for now) */ + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 276 | 1 /* implementation id array of size 1 */ + \ |
| 277 | 1 /* nii_domain */ + \ |
| 278 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 279 | 1 /* nii_name */ + \ |
| 280 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 281 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 282 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 283 | 2 /* eir_clientid */ + \ |
| 284 | 1 /* eir_sequenceid */ + \ |
| 285 | 1 /* eir_flags */ + \ |
| 286 | 1 /* spr_how */ + \ |
| 287 | 0 /* SP4_NONE (for now) */ + \ |
| 288 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 289 | /* eir_server_owner.so_major_id<> */ \ |
| 290 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 291 | /* eir_server_scope<> */ \ |
| 292 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 293 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 294 | 1 /* nii_domain */ + \ |
| 295 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 296 | 1 /* nii_name */ + \ |
| 297 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 298 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 299 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 300 | #define decode_channel_attrs_maxsz (6 + \ |
| 301 | 1 /* ca_rdma_ird.len */ + \ |
| 302 | 1 /* ca_rdma_ird */) |
| 303 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 304 | 2 /* csa_clientid */ + \ |
| 305 | 1 /* csa_sequence */ + \ |
| 306 | 1 /* csa_flags */ + \ |
| 307 | encode_channel_attrs_maxsz + \ |
| 308 | encode_channel_attrs_maxsz + \ |
| 309 | 1 /* csa_cb_program */ + \ |
| 310 | 1 /* csa_sec_parms.len (1) */ + \ |
| 311 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 312 | 1 /* stamp */ + \ |
| 313 | 1 /* machinename.len */ + \ |
| 314 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 315 | 1 /* uid */ + \ |
| 316 | 1 /* gid */ + \ |
| 317 | 1 /* gids.len (0) */) |
| 318 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 319 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 320 | 1 /* csr_sequence */ + \ |
| 321 | 1 /* csr_flags */ + \ |
| 322 | decode_channel_attrs_maxsz + \ |
| 323 | decode_channel_attrs_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 324 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 325 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 326 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 327 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 328 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 329 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 330 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 331 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 332 | #define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 333 | encode_verifier_maxsz) |
| 334 | #define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \ |
| 335 | 2 /* nfs_cookie4 gdlr_cookie */ + \ |
| 336 | decode_verifier_maxsz \ |
| 337 | /* verifier4 gdlr_verifier */ + \ |
| 338 | 1 /* gdlr_deviceid_list count */ + \ |
| 339 | XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ |
| 340 | NFS4_DEVICEID4_SIZE) \ |
| 341 | /* gdlr_deviceid_list */ + \ |
| 342 | 1 /* bool gdlr_eof */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 343 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 344 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE)) |
| 345 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 346 | 1 /* layout type */ + \ |
| 347 | 1 /* opaque devaddr4 length */ + \ |
| 348 | /* devaddr4 payload is read into page */ \ |
| 349 | 1 /* notification bitmap length */ + \ |
| 350 | 1 /* notification bitmap */) |
| 351 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 352 | encode_stateid_maxsz) |
| 353 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 354 | decode_stateid_maxsz + \ |
| 355 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 356 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 357 | 2 /* offset */ + \ |
| 358 | 2 /* length */ + \ |
| 359 | 1 /* reclaim */ + \ |
| 360 | encode_stateid_maxsz + \ |
| 361 | 1 /* new offset (true) */ + \ |
| 362 | 2 /* last byte written */ + \ |
| 363 | 1 /* nt_timechanged (false) */ + \ |
| 364 | 1 /* layoutupdate4 layout type */ + \ |
| 365 | 1 /* NULL filelayout layoutupdate4 payload */) |
| 366 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 367 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 368 | encode_stateid_maxsz + \ |
| 369 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 370 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 371 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 372 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 373 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 374 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 375 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 376 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 377 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 378 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 379 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz + 1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 380 | #else /* CONFIG_NFS_V4_1 */ |
| 381 | #define encode_sequence_maxsz 0 |
| 382 | #define decode_sequence_maxsz 0 |
| 383 | #endif /* CONFIG_NFS_V4_1 */ |
| 384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 386 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 387 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 388 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 390 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 392 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 394 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 396 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 398 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 400 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 402 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 404 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 406 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 408 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 410 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 412 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 414 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 415 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 417 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 419 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 420 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 422 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 424 | encode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 425 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 427 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 429 | decode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 430 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 432 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 433 | encode_putfh_maxsz + \ |
| 434 | encode_savefh_maxsz + \ |
| 435 | encode_open_maxsz + \ |
| 436 | encode_getfh_maxsz + \ |
| 437 | encode_getattr_maxsz + \ |
| 438 | encode_restorefh_maxsz + \ |
| 439 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 441 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 442 | decode_putfh_maxsz + \ |
| 443 | decode_savefh_maxsz + \ |
| 444 | decode_open_maxsz + \ |
| 445 | decode_getfh_maxsz + \ |
| 446 | decode_getattr_maxsz + \ |
| 447 | decode_restorefh_maxsz + \ |
| 448 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 449 | #define NFS4_enc_open_confirm_sz \ |
| 450 | (compound_encode_hdr_maxsz + \ |
| 451 | encode_putfh_maxsz + \ |
| 452 | encode_open_confirm_maxsz) |
| 453 | #define NFS4_dec_open_confirm_sz \ |
| 454 | (compound_decode_hdr_maxsz + \ |
| 455 | decode_putfh_maxsz + \ |
| 456 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 458 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 460 | encode_open_maxsz + \ |
| 461 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 465 | decode_open_maxsz + \ |
| 466 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define NFS4_enc_open_downgrade_sz \ |
| 468 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 469 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 470 | encode_putfh_maxsz + \ |
| 471 | encode_open_downgrade_maxsz + \ |
| 472 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | #define NFS4_dec_open_downgrade_sz \ |
| 474 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 475 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 476 | decode_putfh_maxsz + \ |
| 477 | decode_open_downgrade_maxsz + \ |
| 478 | decode_getattr_maxsz) |
| 479 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 480 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 481 | encode_putfh_maxsz + \ |
| 482 | encode_close_maxsz + \ |
| 483 | encode_getattr_maxsz) |
| 484 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 485 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 486 | decode_putfh_maxsz + \ |
| 487 | decode_close_maxsz + \ |
| 488 | decode_getattr_maxsz) |
| 489 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 490 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 491 | encode_putfh_maxsz + \ |
| 492 | encode_setattr_maxsz + \ |
| 493 | encode_getattr_maxsz) |
| 494 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 495 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 496 | decode_putfh_maxsz + \ |
| 497 | decode_setattr_maxsz + \ |
| 498 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 500 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | encode_putfh_maxsz + \ |
| 502 | encode_fsinfo_maxsz) |
| 503 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 504 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | decode_putfh_maxsz + \ |
| 506 | decode_fsinfo_maxsz) |
| 507 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 508 | encode_renew_maxsz) |
| 509 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 510 | decode_renew_maxsz) |
| 511 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 512 | encode_setclientid_maxsz) |
| 513 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 514 | decode_setclientid_maxsz) |
| 515 | #define NFS4_enc_setclientid_confirm_sz \ |
| 516 | (compound_encode_hdr_maxsz + \ |
| 517 | encode_setclientid_confirm_maxsz + \ |
| 518 | encode_putrootfh_maxsz + \ |
| 519 | encode_fsinfo_maxsz) |
| 520 | #define NFS4_dec_setclientid_confirm_sz \ |
| 521 | (compound_decode_hdr_maxsz + \ |
| 522 | decode_setclientid_confirm_maxsz + \ |
| 523 | decode_putrootfh_maxsz + \ |
| 524 | decode_fsinfo_maxsz) |
| 525 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 526 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 528 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 532 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 534 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 536 | encode_lockt_maxsz) |
| 537 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 538 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 539 | decode_putfh_maxsz + \ |
| 540 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 542 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 544 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 546 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 548 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 549 | #define NFS4_enc_release_lockowner_sz \ |
| 550 | (compound_encode_hdr_maxsz + \ |
| 551 | encode_lockowner_maxsz) |
| 552 | #define NFS4_dec_release_lockowner_sz \ |
| 553 | (compound_decode_hdr_maxsz + \ |
| 554 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 556 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 558 | encode_access_maxsz + \ |
| 559 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 561 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 563 | decode_access_maxsz + \ |
| 564 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 566 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | encode_putfh_maxsz + \ |
| 568 | encode_getattr_maxsz) |
| 569 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 570 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | decode_putfh_maxsz + \ |
| 572 | decode_getattr_maxsz) |
| 573 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 574 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | encode_putfh_maxsz + \ |
| 576 | encode_lookup_maxsz + \ |
| 577 | encode_getattr_maxsz + \ |
| 578 | encode_getfh_maxsz) |
| 579 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 580 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 582 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | decode_getattr_maxsz + \ |
| 584 | decode_getfh_maxsz) |
| 585 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 586 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | encode_putrootfh_maxsz + \ |
| 588 | encode_getattr_maxsz + \ |
| 589 | encode_getfh_maxsz) |
| 590 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 591 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | decode_putrootfh_maxsz + \ |
| 593 | decode_getattr_maxsz + \ |
| 594 | decode_getfh_maxsz) |
| 595 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 596 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | encode_putfh_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 598 | encode_remove_maxsz + \ |
| 599 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 601 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | decode_putfh_maxsz + \ |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 603 | decode_remove_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 604 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 606 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | encode_putfh_maxsz + \ |
| 608 | encode_savefh_maxsz + \ |
| 609 | encode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 610 | encode_rename_maxsz + \ |
| 611 | encode_getattr_maxsz + \ |
| 612 | encode_restorefh_maxsz + \ |
| 613 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 615 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | decode_putfh_maxsz + \ |
| 617 | decode_savefh_maxsz + \ |
| 618 | decode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 619 | decode_rename_maxsz + \ |
| 620 | decode_getattr_maxsz + \ |
| 621 | decode_restorefh_maxsz + \ |
| 622 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 624 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | encode_putfh_maxsz + \ |
| 626 | encode_savefh_maxsz + \ |
| 627 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 628 | encode_link_maxsz + \ |
| 629 | decode_getattr_maxsz + \ |
| 630 | encode_restorefh_maxsz + \ |
| 631 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 633 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | decode_putfh_maxsz + \ |
| 635 | decode_savefh_maxsz + \ |
| 636 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 637 | decode_link_maxsz + \ |
| 638 | decode_getattr_maxsz + \ |
| 639 | decode_restorefh_maxsz + \ |
| 640 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 642 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | encode_putfh_maxsz + \ |
| 644 | encode_symlink_maxsz + \ |
| 645 | encode_getattr_maxsz + \ |
| 646 | encode_getfh_maxsz) |
| 647 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 648 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | decode_putfh_maxsz + \ |
| 650 | decode_symlink_maxsz + \ |
| 651 | decode_getattr_maxsz + \ |
| 652 | decode_getfh_maxsz) |
| 653 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 654 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | encode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 656 | encode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 658 | encode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | encode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 660 | encode_restorefh_maxsz + \ |
| 661 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 663 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | decode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 665 | decode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 667 | decode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | decode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 669 | decode_restorefh_maxsz + \ |
| 670 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 672 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | encode_putfh_maxsz + \ |
| 674 | encode_getattr_maxsz) |
| 675 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 676 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | decode_putfh_maxsz + \ |
| 678 | decode_getattr_maxsz) |
| 679 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 680 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 682 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 686 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 689 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | encode_getattr_maxsz) |
| 691 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 692 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 693 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | decode_getattr_maxsz) |
| 695 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 696 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 698 | encode_delegreturn_maxsz + \ |
| 699 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 701 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 702 | decode_delegreturn_maxsz + \ |
| 703 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 704 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 705 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 706 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 707 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 708 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 709 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 710 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 711 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 712 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 713 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 714 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 715 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 716 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 717 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 718 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 719 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 720 | #define NFS4_enc_fs_locations_sz \ |
| 721 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 722 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 723 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 724 | encode_lookup_maxsz + \ |
| 725 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 726 | #define NFS4_dec_fs_locations_sz \ |
| 727 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 728 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 729 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 730 | decode_lookup_maxsz + \ |
| 731 | decode_fs_locations_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 732 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 733 | encode_sequence_maxsz + \ |
| 734 | encode_putfh_maxsz + \ |
| 735 | encode_secinfo_maxsz) |
| 736 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 737 | decode_sequence_maxsz + \ |
| 738 | decode_putfh_maxsz + \ |
| 739 | decode_secinfo_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 740 | #if defined(CONFIG_NFS_V4_1) |
| 741 | #define NFS4_enc_exchange_id_sz \ |
| 742 | (compound_encode_hdr_maxsz + \ |
| 743 | encode_exchange_id_maxsz) |
| 744 | #define NFS4_dec_exchange_id_sz \ |
| 745 | (compound_decode_hdr_maxsz + \ |
| 746 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 747 | #define NFS4_enc_create_session_sz \ |
| 748 | (compound_encode_hdr_maxsz + \ |
| 749 | encode_create_session_maxsz) |
| 750 | #define NFS4_dec_create_session_sz \ |
| 751 | (compound_decode_hdr_maxsz + \ |
| 752 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 753 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 754 | encode_destroy_session_maxsz) |
| 755 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 756 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 757 | #define NFS4_enc_sequence_sz \ |
| 758 | (compound_decode_hdr_maxsz + \ |
| 759 | encode_sequence_maxsz) |
| 760 | #define NFS4_dec_sequence_sz \ |
| 761 | (compound_decode_hdr_maxsz + \ |
| 762 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 763 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 764 | encode_sequence_maxsz + \ |
| 765 | encode_putrootfh_maxsz + \ |
| 766 | encode_fsinfo_maxsz) |
| 767 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 768 | decode_sequence_maxsz + \ |
| 769 | decode_putrootfh_maxsz + \ |
| 770 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 771 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 772 | encode_sequence_maxsz + \ |
| 773 | encode_reclaim_complete_maxsz) |
| 774 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 775 | decode_sequence_maxsz + \ |
| 776 | decode_reclaim_complete_maxsz) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 777 | #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \ |
| 778 | encode_sequence_maxsz + \ |
| 779 | encode_putfh_maxsz + \ |
| 780 | encode_getdevicelist_maxsz) |
| 781 | #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \ |
| 782 | decode_sequence_maxsz + \ |
| 783 | decode_putfh_maxsz + \ |
| 784 | decode_getdevicelist_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 785 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 786 | encode_sequence_maxsz +\ |
| 787 | encode_getdeviceinfo_maxsz) |
| 788 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 789 | decode_sequence_maxsz + \ |
| 790 | decode_getdeviceinfo_maxsz) |
| 791 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 792 | encode_sequence_maxsz + \ |
| 793 | encode_putfh_maxsz + \ |
| 794 | encode_layoutget_maxsz) |
| 795 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 796 | decode_sequence_maxsz + \ |
| 797 | decode_putfh_maxsz + \ |
| 798 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 799 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 800 | encode_sequence_maxsz +\ |
| 801 | encode_putfh_maxsz + \ |
| 802 | encode_layoutcommit_maxsz + \ |
| 803 | encode_getattr_maxsz) |
| 804 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 805 | decode_sequence_maxsz + \ |
| 806 | decode_putfh_maxsz + \ |
| 807 | decode_layoutcommit_maxsz + \ |
| 808 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 809 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 810 | encode_sequence_maxsz + \ |
| 811 | encode_putfh_maxsz + \ |
| 812 | encode_layoutreturn_maxsz) |
| 813 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 814 | decode_sequence_maxsz + \ |
| 815 | decode_putfh_maxsz + \ |
| 816 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 817 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 818 | encode_sequence_maxsz + \ |
| 819 | encode_putrootfh_maxsz +\ |
| 820 | encode_secinfo_no_name_maxsz) |
| 821 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 822 | decode_sequence_maxsz + \ |
| 823 | decode_putrootfh_maxsz + \ |
| 824 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 825 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 826 | encode_sequence_maxsz + \ |
| 827 | encode_test_stateid_maxsz) |
| 828 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 829 | decode_sequence_maxsz + \ |
| 830 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 831 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 832 | encode_sequence_maxsz + \ |
| 833 | encode_free_stateid_maxsz) |
| 834 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 835 | decode_sequence_maxsz + \ |
| 836 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 837 | |
| 838 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 839 | compound_encode_hdr_maxsz + |
| 840 | encode_sequence_maxsz + |
| 841 | encode_putfh_maxsz + |
| 842 | encode_getattr_maxsz) * |
| 843 | XDR_UNIT); |
| 844 | |
| 845 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 846 | compound_decode_hdr_maxsz + |
| 847 | decode_sequence_maxsz + |
| 848 | decode_putfh_maxsz) * |
| 849 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 850 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 852 | static unsigned short send_implementation_id = 1; |
| 853 | |
| 854 | module_param(send_implementation_id, ushort, 0644); |
| 855 | MODULE_PARM_DESC(send_implementation_id, |
| 856 | "Send implementation ID with NFSv4.1 exchange_id"); |
| 857 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 858 | static const umode_t nfs_type2fmt[] = { |
| 859 | [NF4BAD] = 0, |
| 860 | [NF4REG] = S_IFREG, |
| 861 | [NF4DIR] = S_IFDIR, |
| 862 | [NF4BLK] = S_IFBLK, |
| 863 | [NF4CHR] = S_IFCHR, |
| 864 | [NF4LNK] = S_IFLNK, |
| 865 | [NF4SOCK] = S_IFSOCK, |
| 866 | [NF4FIFO] = S_IFIFO, |
| 867 | [NF4ATTRDIR] = 0, |
| 868 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | }; |
| 870 | |
| 871 | struct compound_hdr { |
| 872 | int32_t status; |
| 873 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 874 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | uint32_t taglen; |
| 876 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 877 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 878 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | }; |
| 880 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 881 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 882 | { |
| 883 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 884 | BUG_ON(!p); |
| 885 | return p; |
| 886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 888 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 889 | { |
| 890 | __be32 *p; |
| 891 | |
| 892 | p = xdr_reserve_space(xdr, len); |
| 893 | xdr_encode_opaque_fixed(p, buf, len); |
| 894 | } |
| 895 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 897 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 898 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 900 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | xdr_encode_opaque(p, str, len); |
| 902 | } |
| 903 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 904 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 905 | { |
| 906 | __be32 *p; |
| 907 | |
| 908 | p = reserve_space(xdr, 4); |
| 909 | *p = cpu_to_be32(n); |
| 910 | } |
| 911 | |
| 912 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 913 | const struct nfs_seqid *seqid) |
| 914 | { |
| 915 | encode_uint32(xdr, seqid->sequence->counter); |
| 916 | } |
| 917 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 918 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 919 | struct rpc_rqst *req, |
| 920 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 922 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 923 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 924 | |
| 925 | /* initialize running count of expected bytes in reply. |
| 926 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 927 | * but this is not required as a MUST for the server to do so. */ |
| 928 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 931 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 932 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 933 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 934 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 935 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 936 | } |
| 937 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 938 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 939 | uint32_t replen, |
| 940 | struct compound_hdr *hdr) |
| 941 | { |
| 942 | encode_uint32(xdr, op); |
| 943 | hdr->nops++; |
| 944 | hdr->replen += replen; |
| 945 | } |
| 946 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 947 | static void encode_nops(struct compound_hdr *hdr) |
| 948 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 949 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 950 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | } |
| 952 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 953 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 954 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 955 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 956 | } |
| 957 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 959 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 960 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | } |
| 962 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 963 | 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] | 964 | { |
| 965 | char owner_name[IDMAP_NAMESZ]; |
| 966 | char owner_group[IDMAP_NAMESZ]; |
| 967 | int owner_namelen = 0; |
| 968 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 969 | __be32 *p; |
| 970 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | int len; |
| 972 | uint32_t bmval0 = 0; |
| 973 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | |
| 975 | /* |
| 976 | * We reserve enough space to write the entire attribute buffer at once. |
| 977 | * In the worst-case, this would be |
| 978 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 979 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 980 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | */ |
| 982 | len = 16; |
| 983 | |
| 984 | /* Sigh */ |
| 985 | if (iap->ia_valid & ATTR_SIZE) |
| 986 | len += 8; |
| 987 | if (iap->ia_valid & ATTR_MODE) |
| 988 | len += 4; |
| 989 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 990 | 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] | 991 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 992 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 993 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | /* XXX */ |
| 995 | strcpy(owner_name, "nobody"); |
| 996 | owner_namelen = sizeof("nobody") - 1; |
| 997 | /* goto out; */ |
| 998 | } |
| 999 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1000 | } |
| 1001 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1002 | 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] | 1003 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1004 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 1005 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | strcpy(owner_group, "nobody"); |
| 1007 | owner_grouplen = sizeof("nobody") - 1; |
| 1008 | /* goto out; */ |
| 1009 | } |
| 1010 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1011 | } |
| 1012 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 1013 | len += 16; |
| 1014 | else if (iap->ia_valid & ATTR_ATIME) |
| 1015 | len += 4; |
| 1016 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 1017 | len += 16; |
| 1018 | else if (iap->ia_valid & ATTR_MTIME) |
| 1019 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1020 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | |
| 1022 | /* |
| 1023 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 1024 | * buffer length to be backfilled at the end of this routine. |
| 1025 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1026 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | q = p; |
| 1028 | p += 3; |
| 1029 | |
| 1030 | if (iap->ia_valid & ATTR_SIZE) { |
| 1031 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1032 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | } |
| 1034 | if (iap->ia_valid & ATTR_MODE) { |
| 1035 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1036 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | } |
| 1038 | if (iap->ia_valid & ATTR_UID) { |
| 1039 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1040 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | } |
| 1042 | if (iap->ia_valid & ATTR_GID) { |
| 1043 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1044 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | } |
| 1046 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1047 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1048 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1049 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 1050 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 1051 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | } |
| 1053 | else if (iap->ia_valid & ATTR_ATIME) { |
| 1054 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1055 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | } |
| 1057 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1058 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1059 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1060 | *p++ = cpu_to_be32(0); |
| 1061 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 1062 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
| 1064 | else if (iap->ia_valid & ATTR_MTIME) { |
| 1065 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1066 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1068 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | /* |
| 1070 | * Now we backfill the bitmap and the attribute buffer length. |
| 1071 | */ |
| 1072 | if (len != ((char *)p - (char *)q) + 4) { |
Weston Andros Adamson | f9fd2d9 | 2012-01-26 13:32:22 -0500 | [diff] [blame] | 1073 | printk(KERN_ERR "NFS: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | len, ((char *)p - (char *)q) + 4); |
| 1075 | BUG(); |
| 1076 | } |
| 1077 | len = (char *)p - (char *)q - 12; |
| 1078 | *q++ = htonl(bmval0); |
| 1079 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1080 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1085 | 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] | 1086 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1087 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1089 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1090 | *p++ = cpu_to_be32(OP_ACCESS); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1091 | *p = cpu_to_be32(access); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1092 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1093 | hdr->replen += decode_access_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | } |
| 1095 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1096 | 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] | 1097 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1098 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1099 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1100 | encode_nfs4_stateid(xdr, arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | } |
| 1102 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1103 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1105 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1106 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1107 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1108 | *p++ = cpu_to_be32(OP_COMMIT); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1109 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1110 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1111 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1112 | hdr->replen += decode_commit_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | } |
| 1114 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1115 | 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] | 1116 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1117 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1118 | |
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(OP_CREATE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1121 | *p = cpu_to_be32(create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | |
| 1123 | switch (create->ftype) { |
| 1124 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1125 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1126 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1127 | 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] | 1128 | break; |
| 1129 | |
| 1130 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1131 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1132 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1133 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | break; |
| 1135 | |
| 1136 | default: |
| 1137 | break; |
| 1138 | } |
| 1139 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1140 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1141 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1142 | hdr->replen += decode_create_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1144 | encode_attrs(xdr, create->attrs, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | } |
| 1146 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1147 | 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] | 1148 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1149 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1151 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1152 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1153 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1154 | *p = cpu_to_be32(bitmap); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1155 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1156 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1159 | 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] | 1160 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1161 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1163 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1164 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1165 | *p++ = cpu_to_be32(2); |
| 1166 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1167 | *p = cpu_to_be32(bm1); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1168 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1169 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1172 | static void |
| 1173 | encode_getattr_three(struct xdr_stream *xdr, |
| 1174 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1175 | struct compound_hdr *hdr) |
| 1176 | { |
| 1177 | __be32 *p; |
| 1178 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1179 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1180 | if (bm2) { |
| 1181 | p = reserve_space(xdr, 16); |
| 1182 | *p++ = cpu_to_be32(3); |
| 1183 | *p++ = cpu_to_be32(bm0); |
| 1184 | *p++ = cpu_to_be32(bm1); |
| 1185 | *p = cpu_to_be32(bm2); |
| 1186 | } else if (bm1) { |
| 1187 | p = reserve_space(xdr, 12); |
| 1188 | *p++ = cpu_to_be32(2); |
| 1189 | *p++ = cpu_to_be32(bm0); |
| 1190 | *p = cpu_to_be32(bm1); |
| 1191 | } else { |
| 1192 | p = reserve_space(xdr, 8); |
| 1193 | *p++ = cpu_to_be32(1); |
| 1194 | *p = cpu_to_be32(bm0); |
| 1195 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1196 | } |
| 1197 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1198 | 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] | 1199 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1200 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1201 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1204 | 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] | 1205 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1206 | encode_getattr_three(xdr, |
| 1207 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1208 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1209 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1210 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1213 | 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] | 1214 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1215 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1216 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1217 | } |
| 1218 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1219 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1221 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1224 | 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] | 1225 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1226 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1227 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1230 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1231 | { |
| 1232 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1233 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1234 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1235 | } |
| 1236 | |
| 1237 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1238 | { |
| 1239 | if (fl->fl_end == OFFSET_MAX) |
| 1240 | return ~(uint64_t)0; |
| 1241 | return fl->fl_end - fl->fl_start + 1; |
| 1242 | } |
| 1243 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1244 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1245 | { |
| 1246 | __be32 *p; |
| 1247 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1248 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1249 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1250 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1251 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1252 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1253 | xdr_encode_hyper(p, lowner->id); |
| 1254 | } |
| 1255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | /* |
| 1257 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1258 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1259 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1260 | 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] | 1261 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1262 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1264 | p = reserve_space(xdr, 32); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1265 | *p++ = cpu_to_be32(OP_LOCK); |
| 1266 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1267 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1268 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1269 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1270 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1271 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1272 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1273 | encode_nfs4_stateid(xdr, args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1274 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1275 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | } |
| 1277 | else { |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1278 | encode_nfs4_stateid(xdr, args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1279 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1281 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1282 | hdr->replen += decode_lock_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | } |
| 1284 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1285 | static void encode_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] | 1286 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1287 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1289 | p = reserve_space(xdr, 24); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1290 | *p++ = cpu_to_be32(OP_LOCKT); |
| 1291 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1292 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1293 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1294 | encode_lockowner(xdr, &args->lock_owner); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1295 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1296 | hdr->replen += decode_lockt_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | } |
| 1298 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1299 | 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] | 1300 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1301 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1303 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1304 | *p++ = cpu_to_be32(OP_LOCKU); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1305 | *p = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
| 1306 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1307 | encode_nfs4_stateid(xdr, args->stateid); |
| 1308 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1309 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1310 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1311 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1312 | hdr->replen += decode_locku_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | } |
| 1314 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1315 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1316 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1317 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1318 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1319 | } |
| 1320 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1321 | 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] | 1322 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1323 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1324 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | } |
| 1326 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1327 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1329 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1331 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1332 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1333 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1334 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1335 | break; |
| 1336 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1337 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1338 | break; |
| 1339 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1340 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1341 | break; |
| 1342 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1343 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1345 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | } |
| 1347 | |
| 1348 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1349 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1350 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | /* |
| 1352 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1353 | * owner 4 = 32 |
| 1354 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1355 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1356 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1357 | p = reserve_space(xdr, 32); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1358 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1359 | *p++ = cpu_to_be32(20); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1360 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1361 | *p++ = cpu_to_be32(arg->server->s_dev); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1362 | xdr_encode_hyper(p, arg->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1366 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1367 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1368 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1370 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1371 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1372 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1373 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1374 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1375 | break; |
| 1376 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1377 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1378 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1379 | if (nfs4_has_persistent_session(clp)) { |
| 1380 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1381 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1382 | } else { |
| 1383 | struct iattr dummy; |
| 1384 | |
| 1385 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1386 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1387 | dummy.ia_valid = 0; |
| 1388 | encode_attrs(xdr, &dummy, arg->server); |
| 1389 | } |
| 1390 | } else { |
| 1391 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1392 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1393 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1398 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1399 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1400 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1401 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1403 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1404 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1405 | break; |
| 1406 | default: |
| 1407 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1408 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1409 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | } |
| 1411 | } |
| 1412 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1413 | 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] | 1414 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1415 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1417 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1419 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1420 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1421 | break; |
| 1422 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1423 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1424 | break; |
| 1425 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1426 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1427 | break; |
| 1428 | default: |
| 1429 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | } |
| 1431 | } |
| 1432 | |
| 1433 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1434 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1435 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1437 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1438 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | encode_string(xdr, name->len, name->name); |
| 1440 | } |
| 1441 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1442 | 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] | 1443 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1444 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1446 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1447 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | encode_delegation_type(xdr, type); |
| 1449 | } |
| 1450 | |
| 1451 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1452 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1453 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1455 | p = reserve_space(xdr, 4); |
| 1456 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1457 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | encode_string(xdr, name->len, name->name); |
| 1459 | } |
| 1460 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1461 | 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] | 1462 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1463 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | encode_openhdr(xdr, arg); |
| 1465 | encode_opentype(xdr, arg); |
| 1466 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1467 | case NFS4_OPEN_CLAIM_NULL: |
| 1468 | encode_claim_null(xdr, arg->name); |
| 1469 | break; |
| 1470 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1471 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1472 | break; |
| 1473 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1474 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1475 | break; |
| 1476 | default: |
| 1477 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | } |
| 1480 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1481 | 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] | 1482 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1483 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1484 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1485 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | } |
| 1487 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1488 | 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] | 1489 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1490 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1491 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1492 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1493 | encode_share_access(xdr, arg->fmode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | } |
| 1495 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1496 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1497 | 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] | 1498 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1499 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1500 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1503 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
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_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | } |
| 1507 | |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1508 | static void encode_open_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, int zero_seqid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | nfs4_stateid stateid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | if (ctx->state != NULL) { |
Trond Myklebust | 1e3987c | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1513 | nfs4_select_rw_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1514 | if (zero_seqid) |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1515 | stateid.seqid = 0; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1516 | encode_nfs4_stateid(xdr, &stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | } else |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1518 | encode_nfs4_stateid(xdr, &zero_stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1521 | static void encode_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] | 1522 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1523 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1525 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1526 | encode_open_stateid(xdr, args->context, args->lock_context, |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1527 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1529 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1530 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1531 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | } |
| 1533 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1534 | static void encode_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] | 1535 | { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1536 | uint32_t attrs[2] = { |
| 1537 | FATTR4_WORD0_RDATTR_ERROR, |
| 1538 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1539 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1540 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1541 | __be32 *p, verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1543 | if (readdir->plus) { |
| 1544 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1545 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1546 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1547 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1548 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1549 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1550 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1551 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1552 | /* Use mounted_on_fileid only if the server supports it */ |
| 1553 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1554 | attrs[0] |= FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1555 | |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1556 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1557 | *p++ = cpu_to_be32(OP_READDIR); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1558 | p = xdr_encode_hyper(p, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1559 | encode_nfs4_verifier(xdr, &readdir->verifier); |
| 1560 | p = reserve_space(xdr, 20); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1561 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1562 | *p++ = cpu_to_be32(readdir->count); |
| 1563 | *p++ = cpu_to_be32(2); |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1564 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1565 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1566 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1567 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1568 | hdr->replen += decode_readdir_maxsz; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1569 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1570 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1571 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1572 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1573 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1574 | attrs[0] & readdir->bitmask[0], |
| 1575 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1578 | 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] | 1579 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1580 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | } |
| 1582 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1583 | 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] | 1584 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1585 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1586 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | } |
| 1588 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1589 | 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] | 1590 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1591 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1592 | encode_string(xdr, oldname->len, oldname->name); |
| 1593 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1596 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1597 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1599 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1600 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1601 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1602 | *p++ = cpu_to_be32(OP_RENEW); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1603 | xdr_encode_hyper(p, clid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1604 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1605 | hdr->replen += decode_renew_maxsz; |
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 |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1609 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1610 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1611 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1612 | } |
| 1613 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1614 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1615 | 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] | 1616 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1617 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1618 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1619 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1620 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1621 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1622 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1623 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1624 | BUG_ON(arg->acl_len % 4); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1625 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1626 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1627 | 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] | 1628 | } |
| 1629 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1630 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1631 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1633 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | } |
| 1635 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1636 | static void encode_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] | 1637 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1638 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1639 | encode_nfs4_stateid(xdr, &arg->stateid); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1640 | encode_attrs(xdr, arg->iap, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | } |
| 1642 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1643 | 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] | 1644 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1645 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1647 | p = reserve_space(xdr, 4); |
| 1648 | *p = cpu_to_be32(OP_SETCLIENTID); |
| 1649 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | |
| 1651 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1652 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1653 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1655 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1656 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1657 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1658 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1659 | hdr->replen += decode_setclientid_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1662 | 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] | 1663 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1664 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1666 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1667 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1668 | p = xdr_encode_hyper(p, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1669 | encode_nfs4_verifier(xdr, &arg->confirm); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1670 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1671 | hdr->replen += decode_setclientid_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | } |
| 1673 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1674 | 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] | 1675 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1676 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1678 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1679 | encode_open_stateid(xdr, args->context, args->lock_context, |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1680 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1682 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1683 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1684 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1685 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | |
| 1687 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | } |
| 1689 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1690 | 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] | 1691 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1692 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1693 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1695 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1696 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1697 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1698 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1699 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1700 | } |
| 1701 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1702 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1703 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1704 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1705 | struct nfs41_exchange_id_args *args, |
| 1706 | struct compound_hdr *hdr) |
| 1707 | { |
| 1708 | __be32 *p; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1709 | char impl_name[NFS4_OPAQUE_LIMIT]; |
| 1710 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1711 | |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 1712 | p = reserve_space(xdr, 4); |
| 1713 | *p = cpu_to_be32(OP_EXCHANGE_ID); |
| 1714 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1715 | |
| 1716 | encode_string(xdr, args->id_len, args->id); |
| 1717 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1718 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1719 | *p++ = cpu_to_be32(args->flags); |
| 1720 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1721 | |
| 1722 | if (send_implementation_id && |
| 1723 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1724 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
| 1725 | <= NFS4_OPAQUE_LIMIT + 1) |
| 1726 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1727 | utsname()->sysname, utsname()->release, |
| 1728 | utsname()->version, utsname()->machine); |
| 1729 | |
| 1730 | if (len > 0) { |
| 1731 | *p = cpu_to_be32(1); /* implementation id array length=1 */ |
| 1732 | |
| 1733 | encode_string(xdr, |
| 1734 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1735 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1736 | encode_string(xdr, len, impl_name); |
| 1737 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1738 | p = reserve_space(xdr, 12); |
| 1739 | p = xdr_encode_hyper(p, 0); |
| 1740 | *p = cpu_to_be32(0); |
| 1741 | } else |
| 1742 | *p = cpu_to_be32(0); /* implementation id array length=0 */ |
| 1743 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1744 | hdr->nops++; |
| 1745 | hdr->replen += decode_exchange_id_maxsz; |
| 1746 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1747 | |
| 1748 | static void encode_create_session(struct xdr_stream *xdr, |
| 1749 | struct nfs41_create_session_args *args, |
| 1750 | struct compound_hdr *hdr) |
| 1751 | { |
| 1752 | __be32 *p; |
| 1753 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1754 | uint32_t len; |
| 1755 | struct nfs_client *clp = args->client; |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1756 | u32 max_resp_sz_cached; |
| 1757 | |
| 1758 | /* |
| 1759 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1760 | * 2 is the verifier. |
| 1761 | */ |
| 1762 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1763 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1764 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1765 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1766 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1767 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1768 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1769 | *p++ = cpu_to_be32(OP_CREATE_SESSION); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1770 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1771 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1772 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1773 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1774 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1775 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1776 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1777 | *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] | 1778 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1779 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1780 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1781 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1782 | |
| 1783 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1784 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1785 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1786 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1787 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1788 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1789 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1790 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1791 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1792 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1793 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1794 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1795 | |
| 1796 | /* authsys_parms rfc1831 */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1797 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1798 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1799 | *p++ = cpu_to_be32(0); /* UID */ |
| 1800 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1801 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1802 | hdr->nops++; |
| 1803 | hdr->replen += decode_create_session_maxsz; |
| 1804 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1805 | |
| 1806 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1807 | struct nfs4_session *session, |
| 1808 | struct compound_hdr *hdr) |
| 1809 | { |
| 1810 | __be32 *p; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1811 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1812 | *p++ = cpu_to_be32(OP_DESTROY_SESSION); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1813 | xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1814 | hdr->nops++; |
| 1815 | hdr->replen += decode_destroy_session_maxsz; |
| 1816 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1817 | |
| 1818 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1819 | struct nfs41_reclaim_complete_args *args, |
| 1820 | struct compound_hdr *hdr) |
| 1821 | { |
| 1822 | __be32 *p; |
| 1823 | |
| 1824 | p = reserve_space(xdr, 8); |
| 1825 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); |
| 1826 | *p++ = cpu_to_be32(args->one_fs); |
| 1827 | hdr->nops++; |
| 1828 | hdr->replen += decode_reclaim_complete_maxsz; |
| 1829 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1830 | #endif /* CONFIG_NFS_V4_1 */ |
| 1831 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1832 | static void encode_sequence(struct xdr_stream *xdr, |
| 1833 | const struct nfs4_sequence_args *args, |
| 1834 | struct compound_hdr *hdr) |
| 1835 | { |
| 1836 | #if defined(CONFIG_NFS_V4_1) |
| 1837 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1838 | struct nfs4_slot_table *tp; |
| 1839 | struct nfs4_slot *slot; |
| 1840 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1841 | |
| 1842 | if (!session) |
| 1843 | return; |
| 1844 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1845 | tp = &session->fc_slot_table; |
| 1846 | |
| 1847 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1848 | slot = tp->slots + args->sa_slotid; |
| 1849 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1850 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1851 | *p++ = cpu_to_be32(OP_SEQUENCE); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1852 | |
| 1853 | /* |
| 1854 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1855 | */ |
| 1856 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1857 | "max_slotid=%d cache_this=%d\n", |
| 1858 | __func__, |
| 1859 | ((u32 *)session->sess_id.data)[0], |
| 1860 | ((u32 *)session->sess_id.data)[1], |
| 1861 | ((u32 *)session->sess_id.data)[2], |
| 1862 | ((u32 *)session->sess_id.data)[3], |
| 1863 | slot->seq_nr, args->sa_slotid, |
| 1864 | tp->highest_used_slotid, args->sa_cache_this); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1865 | 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] | 1866 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1867 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1868 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1869 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1870 | hdr->nops++; |
| 1871 | hdr->replen += decode_sequence_maxsz; |
| 1872 | #endif /* CONFIG_NFS_V4_1 */ |
| 1873 | } |
| 1874 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1875 | #ifdef CONFIG_NFS_V4_1 |
| 1876 | static void |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1877 | encode_getdevicelist(struct xdr_stream *xdr, |
| 1878 | const struct nfs4_getdevicelist_args *args, |
| 1879 | struct compound_hdr *hdr) |
| 1880 | { |
| 1881 | __be32 *p; |
| 1882 | nfs4_verifier dummy = { |
| 1883 | .data = "dummmmmy", |
| 1884 | }; |
| 1885 | |
| 1886 | p = reserve_space(xdr, 20); |
| 1887 | *p++ = cpu_to_be32(OP_GETDEVICELIST); |
| 1888 | *p++ = cpu_to_be32(args->layoutclass); |
| 1889 | *p++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM); |
| 1890 | xdr_encode_hyper(p, 0ULL); /* cookie */ |
| 1891 | encode_nfs4_verifier(xdr, &dummy); |
| 1892 | hdr->nops++; |
| 1893 | hdr->replen += decode_getdevicelist_maxsz; |
| 1894 | } |
| 1895 | |
| 1896 | static void |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1897 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1898 | const struct nfs4_getdeviceinfo_args *args, |
| 1899 | struct compound_hdr *hdr) |
| 1900 | { |
| 1901 | __be32 *p; |
| 1902 | |
| 1903 | p = reserve_space(xdr, 16 + NFS4_DEVICEID4_SIZE); |
| 1904 | *p++ = cpu_to_be32(OP_GETDEVICEINFO); |
| 1905 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1906 | NFS4_DEVICEID4_SIZE); |
| 1907 | *p++ = cpu_to_be32(args->pdev->layout_type); |
| 1908 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ |
| 1909 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ |
| 1910 | hdr->nops++; |
| 1911 | hdr->replen += decode_getdeviceinfo_maxsz; |
| 1912 | } |
| 1913 | |
| 1914 | static void |
| 1915 | encode_layoutget(struct xdr_stream *xdr, |
| 1916 | const struct nfs4_layoutget_args *args, |
| 1917 | struct compound_hdr *hdr) |
| 1918 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1919 | __be32 *p; |
| 1920 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1921 | p = reserve_space(xdr, 40); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1922 | *p++ = cpu_to_be32(OP_LAYOUTGET); |
| 1923 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1924 | *p++ = cpu_to_be32(args->type); |
| 1925 | *p++ = cpu_to_be32(args->range.iomode); |
| 1926 | p = xdr_encode_hyper(p, args->range.offset); |
| 1927 | p = xdr_encode_hyper(p, args->range.length); |
| 1928 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1929 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1930 | p = reserve_space(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1931 | *p = cpu_to_be32(args->maxcount); |
| 1932 | |
| 1933 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1934 | __func__, |
| 1935 | args->type, |
| 1936 | args->range.iomode, |
| 1937 | (unsigned long)args->range.offset, |
| 1938 | (unsigned long)args->range.length, |
| 1939 | args->maxcount); |
| 1940 | hdr->nops++; |
| 1941 | hdr->replen += decode_layoutget_maxsz; |
| 1942 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1943 | |
| 1944 | static int |
| 1945 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1946 | struct inode *inode, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1947 | const struct nfs4_layoutcommit_args *args, |
| 1948 | struct compound_hdr *hdr) |
| 1949 | { |
| 1950 | __be32 *p; |
| 1951 | |
| 1952 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1953 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1954 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1955 | p = reserve_space(xdr, 24); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1956 | *p++ = cpu_to_be32(OP_LAYOUTCOMMIT); |
| 1957 | /* Only whole file layouts */ |
| 1958 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1959 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1960 | *p = cpu_to_be32(0); /* reclaim */ |
| 1961 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1962 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1963 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1964 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1965 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1966 | *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] | 1967 | |
| 1968 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) |
| 1969 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1970 | NFS_I(inode)->layout, xdr, args); |
| 1971 | else { |
| 1972 | p = reserve_space(xdr, 4); |
| 1973 | *p = cpu_to_be32(0); /* no layout-type payload */ |
| 1974 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1975 | |
| 1976 | hdr->nops++; |
| 1977 | hdr->replen += decode_layoutcommit_maxsz; |
| 1978 | return 0; |
| 1979 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1980 | |
| 1981 | static void |
| 1982 | encode_layoutreturn(struct xdr_stream *xdr, |
| 1983 | const struct nfs4_layoutreturn_args *args, |
| 1984 | struct compound_hdr *hdr) |
| 1985 | { |
| 1986 | __be32 *p; |
| 1987 | |
| 1988 | p = reserve_space(xdr, 20); |
| 1989 | *p++ = cpu_to_be32(OP_LAYOUTRETURN); |
| 1990 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 1991 | *p++ = cpu_to_be32(args->layout_type); |
| 1992 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 1993 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1994 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1995 | p = xdr_encode_hyper(p, 0); |
| 1996 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 1997 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1998 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1999 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2000 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2001 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2002 | NFS_I(args->inode)->layout, xdr, args); |
| 2003 | } else { |
| 2004 | p = reserve_space(xdr, 4); |
| 2005 | *p = cpu_to_be32(0); |
| 2006 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2007 | hdr->nops++; |
| 2008 | hdr->replen += decode_layoutreturn_maxsz; |
| 2009 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2010 | |
| 2011 | static int |
| 2012 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2013 | const struct nfs41_secinfo_no_name_args *args, |
| 2014 | struct compound_hdr *hdr) |
| 2015 | { |
| 2016 | __be32 *p; |
| 2017 | p = reserve_space(xdr, 8); |
| 2018 | *p++ = cpu_to_be32(OP_SECINFO_NO_NAME); |
| 2019 | *p++ = cpu_to_be32(args->style); |
| 2020 | hdr->nops++; |
| 2021 | hdr->replen += decode_secinfo_no_name_maxsz; |
| 2022 | return 0; |
| 2023 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2024 | |
| 2025 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2026 | struct nfs41_test_stateid_args *args, |
| 2027 | struct compound_hdr *hdr) |
| 2028 | { |
| 2029 | __be32 *p; |
| 2030 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2031 | p = reserve_space(xdr, 8); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2032 | *p++ = cpu_to_be32(OP_TEST_STATEID); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2033 | *p = cpu_to_be32(1); |
| 2034 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2035 | hdr->nops++; |
| 2036 | hdr->replen += decode_test_stateid_maxsz; |
| 2037 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2038 | |
| 2039 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2040 | struct nfs41_free_stateid_args *args, |
| 2041 | struct compound_hdr *hdr) |
| 2042 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2043 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2044 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2045 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2046 | #endif /* CONFIG_NFS_V4_1 */ |
| 2047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2048 | /* |
| 2049 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2050 | */ |
| 2051 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2052 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2053 | { |
| 2054 | #if defined(CONFIG_NFS_V4_1) |
| 2055 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2056 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2057 | #endif /* CONFIG_NFS_V4_1 */ |
| 2058 | return 0; |
| 2059 | } |
| 2060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | /* |
| 2062 | * Encode an ACCESS request |
| 2063 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2064 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2065 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2068 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2071 | encode_compound_hdr(xdr, req, &hdr); |
| 2072 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2073 | encode_putfh(xdr, args->fh, &hdr); |
| 2074 | encode_access(xdr, args->access, &hdr); |
| 2075 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2076 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | } |
| 2078 | |
| 2079 | /* |
| 2080 | * Encode LOOKUP request |
| 2081 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2082 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2083 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2086 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2088 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2089 | encode_compound_hdr(xdr, req, &hdr); |
| 2090 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2091 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2092 | encode_lookup(xdr, args->name, &hdr); |
| 2093 | encode_getfh(xdr, &hdr); |
| 2094 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2095 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | } |
| 2097 | |
| 2098 | /* |
| 2099 | * Encode LOOKUP_ROOT request |
| 2100 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2101 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2102 | struct xdr_stream *xdr, |
| 2103 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2104 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2106 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2109 | encode_compound_hdr(xdr, req, &hdr); |
| 2110 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2111 | encode_putrootfh(xdr, &hdr); |
| 2112 | encode_getfh(xdr, &hdr); |
| 2113 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2114 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | /* |
| 2118 | * Encode REMOVE request |
| 2119 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2120 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2121 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2124 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2127 | encode_compound_hdr(xdr, req, &hdr); |
| 2128 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2129 | encode_putfh(xdr, args->fh, &hdr); |
| 2130 | encode_remove(xdr, &args->name, &hdr); |
| 2131 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2132 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | } |
| 2134 | |
| 2135 | /* |
| 2136 | * Encode RENAME request |
| 2137 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2138 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2139 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2142 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2145 | encode_compound_hdr(xdr, req, &hdr); |
| 2146 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2147 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2148 | encode_savefh(xdr, &hdr); |
| 2149 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2150 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
| 2151 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2152 | encode_restorefh(xdr, &hdr); |
| 2153 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2154 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | } |
| 2156 | |
| 2157 | /* |
| 2158 | * Encode LINK request |
| 2159 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2160 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2161 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2164 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2167 | encode_compound_hdr(xdr, req, &hdr); |
| 2168 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2169 | encode_putfh(xdr, args->fh, &hdr); |
| 2170 | encode_savefh(xdr, &hdr); |
| 2171 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2172 | encode_link(xdr, args->name, &hdr); |
| 2173 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2174 | encode_restorefh(xdr, &hdr); |
| 2175 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2176 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | } |
| 2178 | |
| 2179 | /* |
| 2180 | * Encode CREATE request |
| 2181 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2182 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2183 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2185 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2186 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2188 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2189 | encode_compound_hdr(xdr, req, &hdr); |
| 2190 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2191 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2192 | encode_savefh(xdr, &hdr); |
| 2193 | encode_create(xdr, args, &hdr); |
| 2194 | encode_getfh(xdr, &hdr); |
| 2195 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2196 | encode_restorefh(xdr, &hdr); |
| 2197 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2198 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | } |
| 2200 | |
| 2201 | /* |
| 2202 | * Encode SYMLINK request |
| 2203 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2204 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2205 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2207 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | } |
| 2209 | |
| 2210 | /* |
| 2211 | * Encode GETATTR request |
| 2212 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2213 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2214 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2217 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2219 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2220 | encode_compound_hdr(xdr, req, &hdr); |
| 2221 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2222 | encode_putfh(xdr, args->fh, &hdr); |
| 2223 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2224 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | } |
| 2226 | |
| 2227 | /* |
| 2228 | * Encode a CLOSE request |
| 2229 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2230 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2231 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2233 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2234 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2235 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2237 | encode_compound_hdr(xdr, req, &hdr); |
| 2238 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2239 | encode_putfh(xdr, args->fh, &hdr); |
| 2240 | encode_close(xdr, args, &hdr); |
| 2241 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2242 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | /* |
| 2246 | * Encode an OPEN request |
| 2247 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2248 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2249 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2252 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2255 | encode_compound_hdr(xdr, req, &hdr); |
| 2256 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2257 | encode_putfh(xdr, args->fh, &hdr); |
| 2258 | encode_savefh(xdr, &hdr); |
| 2259 | encode_open(xdr, args, &hdr); |
| 2260 | encode_getfh(xdr, &hdr); |
| 2261 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2262 | encode_restorefh(xdr, &hdr); |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 2263 | encode_getfattr(xdr, args->dir_bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2264 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | /* |
| 2268 | * Encode an OPEN_CONFIRM request |
| 2269 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2270 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2271 | struct xdr_stream *xdr, |
| 2272 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2275 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2278 | encode_compound_hdr(xdr, req, &hdr); |
| 2279 | encode_putfh(xdr, args->fh, &hdr); |
| 2280 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2281 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | } |
| 2283 | |
| 2284 | /* |
| 2285 | * Encode an OPEN request with no attributes. |
| 2286 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2287 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2288 | struct xdr_stream *xdr, |
| 2289 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2292 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2295 | encode_compound_hdr(xdr, req, &hdr); |
| 2296 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2297 | encode_putfh(xdr, args->fh, &hdr); |
| 2298 | encode_open(xdr, args, &hdr); |
| 2299 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2300 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | } |
| 2302 | |
| 2303 | /* |
| 2304 | * Encode an OPEN_DOWNGRADE request |
| 2305 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2306 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2307 | struct xdr_stream *xdr, |
| 2308 | struct nfs_closeargs *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_open_downgrade(xdr, args, &hdr); |
| 2318 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2319 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | } |
| 2321 | |
| 2322 | /* |
| 2323 | * Encode a LOCK request |
| 2324 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2325 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2326 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2327 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2329 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2332 | encode_compound_hdr(xdr, req, &hdr); |
| 2333 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2334 | encode_putfh(xdr, args->fh, &hdr); |
| 2335 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2336 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2337 | } |
| 2338 | |
| 2339 | /* |
| 2340 | * Encode a LOCKT request |
| 2341 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2342 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2343 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2346 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2349 | encode_compound_hdr(xdr, req, &hdr); |
| 2350 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2351 | encode_putfh(xdr, args->fh, &hdr); |
| 2352 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2353 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | } |
| 2355 | |
| 2356 | /* |
| 2357 | * Encode a LOCKU request |
| 2358 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2359 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2360 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2363 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2364 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2366 | encode_compound_hdr(xdr, req, &hdr); |
| 2367 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2368 | encode_putfh(xdr, args->fh, &hdr); |
| 2369 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2370 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | } |
| 2372 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2373 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2374 | struct xdr_stream *xdr, |
| 2375 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2376 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2377 | struct compound_hdr hdr = { |
| 2378 | .minorversion = 0, |
| 2379 | }; |
| 2380 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2381 | encode_compound_hdr(xdr, req, &hdr); |
| 2382 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2383 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2384 | } |
| 2385 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2386 | /* |
| 2387 | * Encode a READLINK request |
| 2388 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2389 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2390 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [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), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2394 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2395 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2396 | encode_compound_hdr(xdr, req, &hdr); |
| 2397 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2398 | encode_putfh(xdr, args->fh, &hdr); |
| 2399 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2400 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2401 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2402 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2403 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2404 | } |
| 2405 | |
| 2406 | /* |
| 2407 | * Encode a READDIR request |
| 2408 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2409 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2410 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2413 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2416 | encode_compound_hdr(xdr, req, &hdr); |
| 2417 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2418 | encode_putfh(xdr, args->fh, &hdr); |
| 2419 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2420 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2421 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2422 | args->pgbase, args->count); |
| 2423 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2424 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2425 | args->pgbase, args->count); |
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 | * Encode a READ request |
| 2431 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2432 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2433 | struct nfs_readargs *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_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2443 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2444 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2446 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2447 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 | } |
| 2449 | |
| 2450 | /* |
| 2451 | * Encode an SETATTR request |
| 2452 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2453 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2454 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2456 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2457 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2458 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2459 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2460 | encode_compound_hdr(xdr, req, &hdr); |
| 2461 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2462 | encode_putfh(xdr, args->fh, &hdr); |
| 2463 | encode_setattr(xdr, args, args->server, &hdr); |
| 2464 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2465 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2466 | } |
| 2467 | |
| 2468 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2469 | * Encode a GETACL request |
| 2470 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2471 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2472 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2473 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2474 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2475 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2476 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2477 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2478 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2479 | encode_compound_hdr(xdr, req, &hdr); |
| 2480 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2481 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2482 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2483 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2484 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2485 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2486 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2487 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2488 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2489 | } |
| 2490 | |
| 2491 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | * Encode a WRITE request |
| 2493 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2494 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2495 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2498 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2500 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2501 | encode_compound_hdr(xdr, req, &hdr); |
| 2502 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2503 | encode_putfh(xdr, args->fh, &hdr); |
| 2504 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2505 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2506 | if (args->bitmask) |
| 2507 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2508 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | } |
| 2510 | |
| 2511 | /* |
| 2512 | * a COMMIT request |
| 2513 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2514 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2515 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2518 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2519 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2521 | encode_compound_hdr(xdr, req, &hdr); |
| 2522 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2523 | encode_putfh(xdr, args->fh, &hdr); |
| 2524 | encode_commit(xdr, args, &hdr); |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 2525 | if (args->bitmask) |
| 2526 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2527 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | } |
| 2529 | |
| 2530 | /* |
| 2531 | * FSINFO request |
| 2532 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2533 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2534 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2535 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2537 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2540 | encode_compound_hdr(xdr, req, &hdr); |
| 2541 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2542 | encode_putfh(xdr, args->fh, &hdr); |
| 2543 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2544 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | } |
| 2546 | |
| 2547 | /* |
| 2548 | * a PATHCONF request |
| 2549 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2550 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2551 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2552 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2553 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2554 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2556 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2557 | encode_compound_hdr(xdr, req, &hdr); |
| 2558 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2559 | encode_putfh(xdr, args->fh, &hdr); |
| 2560 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2561 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2562 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | } |
| 2564 | |
| 2565 | /* |
| 2566 | * a STATFS request |
| 2567 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2568 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2569 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2572 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2573 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2575 | encode_compound_hdr(xdr, req, &hdr); |
| 2576 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2577 | encode_putfh(xdr, args->fh, &hdr); |
| 2578 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2579 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2580 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | } |
| 2582 | |
| 2583 | /* |
| 2584 | * GETATTR_BITMAP request |
| 2585 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2586 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2587 | struct xdr_stream *xdr, |
| 2588 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2591 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2594 | encode_compound_hdr(xdr, req, &hdr); |
| 2595 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2596 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2597 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2598 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2599 | FATTR4_WORD0_LINK_SUPPORT| |
| 2600 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2601 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2602 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2603 | } |
| 2604 | |
| 2605 | /* |
| 2606 | * a RENEW request |
| 2607 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2608 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2609 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2612 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | }; |
| 2614 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2615 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2616 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2617 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | } |
| 2619 | |
| 2620 | /* |
| 2621 | * a SETCLIENTID request |
| 2622 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2623 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2624 | struct xdr_stream *xdr, |
| 2625 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2627 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2628 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | }; |
| 2630 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2631 | encode_compound_hdr(xdr, req, &hdr); |
| 2632 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2633 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2634 | } |
| 2635 | |
| 2636 | /* |
| 2637 | * a SETCLIENTID_CONFIRM request |
| 2638 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2639 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2640 | struct xdr_stream *xdr, |
| 2641 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2642 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2644 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2645 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2646 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2648 | encode_compound_hdr(xdr, req, &hdr); |
| 2649 | encode_setclientid_confirm(xdr, arg, &hdr); |
| 2650 | encode_putrootfh(xdr, &hdr); |
| 2651 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2652 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | /* |
| 2656 | * DELEGRETURN request |
| 2657 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2658 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2659 | struct xdr_stream *xdr, |
| 2660 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2663 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2666 | encode_compound_hdr(xdr, req, &hdr); |
| 2667 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2668 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2669 | encode_delegreturn(xdr, args->stateid, &hdr); |
| 2670 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2671 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2672 | } |
| 2673 | |
| 2674 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2675 | * Encode FS_LOCATIONS request |
| 2676 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2677 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2678 | struct xdr_stream *xdr, |
| 2679 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2680 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2681 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2682 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2683 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2684 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2685 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2686 | encode_compound_hdr(xdr, req, &hdr); |
| 2687 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2688 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2689 | encode_lookup(xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2690 | replen = hdr.replen; /* get the attribute into args->page */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2691 | encode_fs_locations(xdr, args->bitmask, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2692 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2693 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2694 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2695 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2696 | } |
| 2697 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2698 | /* |
| 2699 | * Encode SECINFO request |
| 2700 | */ |
| 2701 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2702 | struct xdr_stream *xdr, |
| 2703 | struct nfs4_secinfo_arg *args) |
| 2704 | { |
| 2705 | struct compound_hdr hdr = { |
| 2706 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2707 | }; |
| 2708 | |
| 2709 | encode_compound_hdr(xdr, req, &hdr); |
| 2710 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2711 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2712 | encode_secinfo(xdr, args->name, &hdr); |
| 2713 | encode_nops(&hdr); |
| 2714 | } |
| 2715 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2716 | #if defined(CONFIG_NFS_V4_1) |
| 2717 | /* |
| 2718 | * EXCHANGE_ID request |
| 2719 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2720 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2721 | struct xdr_stream *xdr, |
| 2722 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2723 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2724 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2725 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2726 | }; |
| 2727 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2728 | encode_compound_hdr(xdr, req, &hdr); |
| 2729 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2730 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2731 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2732 | |
| 2733 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2734 | * a CREATE_SESSION request |
| 2735 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2736 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2737 | struct xdr_stream *xdr, |
| 2738 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2739 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2740 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2741 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2742 | }; |
| 2743 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2744 | encode_compound_hdr(xdr, req, &hdr); |
| 2745 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2746 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2747 | } |
| 2748 | |
| 2749 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2750 | * a DESTROY_SESSION request |
| 2751 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2752 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2753 | struct xdr_stream *xdr, |
| 2754 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2755 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2756 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2757 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2758 | }; |
| 2759 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2760 | encode_compound_hdr(xdr, req, &hdr); |
| 2761 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2762 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2766 | * a SEQUENCE request |
| 2767 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2768 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2769 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2770 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2771 | struct compound_hdr hdr = { |
| 2772 | .minorversion = nfs4_xdr_minorversion(args), |
| 2773 | }; |
| 2774 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2775 | encode_compound_hdr(xdr, req, &hdr); |
| 2776 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2777 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2778 | } |
| 2779 | |
| 2780 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2781 | * a GET_LEASE_TIME request |
| 2782 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2783 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2784 | struct xdr_stream *xdr, |
| 2785 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2786 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2787 | struct compound_hdr hdr = { |
| 2788 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2789 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2790 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2791 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2792 | encode_compound_hdr(xdr, req, &hdr); |
| 2793 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2794 | encode_putrootfh(xdr, &hdr); |
| 2795 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2796 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2797 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2798 | |
| 2799 | /* |
| 2800 | * a RECLAIM_COMPLETE request |
| 2801 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2802 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2803 | struct xdr_stream *xdr, |
| 2804 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2805 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2806 | struct compound_hdr hdr = { |
| 2807 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2808 | }; |
| 2809 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2810 | encode_compound_hdr(xdr, req, &hdr); |
| 2811 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2812 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2813 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2814 | } |
| 2815 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2816 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 2817 | * Encode GETDEVICELIST request |
| 2818 | */ |
| 2819 | static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst *req, |
| 2820 | struct xdr_stream *xdr, |
| 2821 | struct nfs4_getdevicelist_args *args) |
| 2822 | { |
| 2823 | struct compound_hdr hdr = { |
| 2824 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2825 | }; |
| 2826 | |
| 2827 | encode_compound_hdr(xdr, req, &hdr); |
| 2828 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2829 | encode_putfh(xdr, args->fh, &hdr); |
| 2830 | encode_getdevicelist(xdr, args, &hdr); |
| 2831 | encode_nops(&hdr); |
| 2832 | } |
| 2833 | |
| 2834 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2835 | * Encode GETDEVICEINFO request |
| 2836 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2837 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2838 | struct xdr_stream *xdr, |
| 2839 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2840 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2841 | struct compound_hdr hdr = { |
| 2842 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2843 | }; |
| 2844 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2845 | encode_compound_hdr(xdr, req, &hdr); |
| 2846 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2847 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2848 | |
| 2849 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2850 | * so that notification bitmap is put in xdr_buf tail */ |
| 2851 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2852 | args->pdev->pages, args->pdev->pgbase, |
| 2853 | args->pdev->pglen); |
| 2854 | |
| 2855 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2856 | } |
| 2857 | |
| 2858 | /* |
| 2859 | * Encode LAYOUTGET request |
| 2860 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2861 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2862 | struct xdr_stream *xdr, |
| 2863 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2864 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2865 | struct compound_hdr hdr = { |
| 2866 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2867 | }; |
| 2868 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2869 | encode_compound_hdr(xdr, req, &hdr); |
| 2870 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2871 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2872 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2873 | |
| 2874 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2875 | args->layout.pages, 0, args->layout.pglen); |
| 2876 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2877 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2878 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2879 | |
| 2880 | /* |
| 2881 | * Encode LAYOUTCOMMIT request |
| 2882 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2883 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2884 | struct xdr_stream *xdr, |
| 2885 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2886 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2887 | struct nfs4_layoutcommit_data *data = |
| 2888 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2889 | struct compound_hdr hdr = { |
| 2890 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2891 | }; |
| 2892 | |
| 2893 | encode_compound_hdr(xdr, req, &hdr); |
| 2894 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2895 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2896 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2897 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2898 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2899 | } |
| 2900 | |
| 2901 | /* |
| 2902 | * Encode LAYOUTRETURN request |
| 2903 | */ |
| 2904 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2905 | struct xdr_stream *xdr, |
| 2906 | struct nfs4_layoutreturn_args *args) |
| 2907 | { |
| 2908 | struct compound_hdr hdr = { |
| 2909 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2910 | }; |
| 2911 | |
| 2912 | encode_compound_hdr(xdr, req, &hdr); |
| 2913 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2914 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2915 | encode_layoutreturn(xdr, args, &hdr); |
| 2916 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2917 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2918 | |
| 2919 | /* |
| 2920 | * Encode SECINFO_NO_NAME request |
| 2921 | */ |
| 2922 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2923 | struct xdr_stream *xdr, |
| 2924 | struct nfs41_secinfo_no_name_args *args) |
| 2925 | { |
| 2926 | struct compound_hdr hdr = { |
| 2927 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2928 | }; |
| 2929 | |
| 2930 | encode_compound_hdr(xdr, req, &hdr); |
| 2931 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2932 | encode_putrootfh(xdr, &hdr); |
| 2933 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2934 | encode_nops(&hdr); |
| 2935 | return 0; |
| 2936 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2937 | |
| 2938 | /* |
| 2939 | * Encode TEST_STATEID request |
| 2940 | */ |
| 2941 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2942 | struct xdr_stream *xdr, |
| 2943 | struct nfs41_test_stateid_args *args) |
| 2944 | { |
| 2945 | struct compound_hdr hdr = { |
| 2946 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2947 | }; |
| 2948 | |
| 2949 | encode_compound_hdr(xdr, req, &hdr); |
| 2950 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2951 | encode_test_stateid(xdr, args, &hdr); |
| 2952 | encode_nops(&hdr); |
| 2953 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2954 | |
| 2955 | /* |
| 2956 | * Encode FREE_STATEID request |
| 2957 | */ |
| 2958 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2959 | struct xdr_stream *xdr, |
| 2960 | struct nfs41_free_stateid_args *args) |
| 2961 | { |
| 2962 | struct compound_hdr hdr = { |
| 2963 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2964 | }; |
| 2965 | |
| 2966 | encode_compound_hdr(xdr, req, &hdr); |
| 2967 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2968 | encode_free_stateid(xdr, args, &hdr); |
| 2969 | encode_nops(&hdr); |
| 2970 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2971 | #endif /* CONFIG_NFS_V4_1 */ |
| 2972 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 2973 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 2974 | { |
| 2975 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 2976 | "Remaining buffer length is %tu words.\n", |
| 2977 | func, xdr->end - xdr->p); |
| 2978 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2979 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2980 | 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] | 2981 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 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 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2988 | p = xdr_inline_decode(xdr, *len); |
| 2989 | if (unlikely(!p)) |
| 2990 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2991 | *string = (char *)p; |
| 2992 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2993 | out_overflow: |
| 2994 | print_overflow_msg(__func__, xdr); |
| 2995 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2996 | } |
| 2997 | |
| 2998 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 2999 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3000 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3002 | p = xdr_inline_decode(xdr, 8); |
| 3003 | if (unlikely(!p)) |
| 3004 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3005 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3006 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3007 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3008 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3009 | if (unlikely(!p)) |
| 3010 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3011 | hdr->tag = (char *)p; |
| 3012 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3013 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3014 | if (unlikely(hdr->nops < 1)) |
| 3015 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3023 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3024 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3025 | uint32_t opnum; |
| 3026 | int32_t nfserr; |
| 3027 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3028 | p = xdr_inline_decode(xdr, 8); |
| 3029 | if (unlikely(!p)) |
| 3030 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3031 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3032 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3033 | dprintk("nfs: Server returned operation" |
| 3034 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3035 | opnum, expected); |
| 3036 | return -EIO; |
| 3037 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3038 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3039 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 3040 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3042 | out_overflow: |
| 3043 | print_overflow_msg(__func__, xdr); |
| 3044 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | } |
| 3046 | |
| 3047 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3048 | 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] | 3049 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3050 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3051 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | char *str; |
| 3053 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3054 | p = xdr_inline_decode(xdr, 12); |
| 3055 | if (likely(p)) |
| 3056 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3057 | print_overflow_msg(__func__, xdr); |
| 3058 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | } |
| 3060 | |
| 3061 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3062 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3063 | uint32_t bmlen; |
| 3064 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3065 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3066 | p = xdr_inline_decode(xdr, 4); |
| 3067 | if (unlikely(!p)) |
| 3068 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3069 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3070 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3071 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3072 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3073 | if (unlikely(!p)) |
| 3074 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3075 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3076 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3077 | if (bmlen > 1) { |
| 3078 | bitmap[1] = be32_to_cpup(p++); |
| 3079 | if (bmlen > 2) |
| 3080 | bitmap[2] = be32_to_cpup(p); |
| 3081 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | } |
| 3083 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3084 | out_overflow: |
| 3085 | print_overflow_msg(__func__, xdr); |
| 3086 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | } |
| 3088 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3089 | 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] | 3090 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3091 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3093 | p = xdr_inline_decode(xdr, 4); |
| 3094 | if (unlikely(!p)) |
| 3095 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3096 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3097 | *savep = xdr->p; |
| 3098 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3099 | out_overflow: |
| 3100 | print_overflow_msg(__func__, xdr); |
| 3101 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3105 | { |
| 3106 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3107 | int ret; |
| 3108 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3109 | if (unlikely(ret < 0)) |
| 3110 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3111 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3112 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3113 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3114 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3115 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | return 0; |
| 3117 | } |
| 3118 | |
| 3119 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3120 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3121 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3122 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3123 | |
| 3124 | *type = 0; |
| 3125 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3126 | return -EIO; |
| 3127 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3128 | p = xdr_inline_decode(xdr, 4); |
| 3129 | if (unlikely(!p)) |
| 3130 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3131 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3132 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3133 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3134 | return -EIO; |
| 3135 | } |
| 3136 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3137 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3138 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3139 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3140 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3141 | out_overflow: |
| 3142 | print_overflow_msg(__func__, xdr); |
| 3143 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3144 | } |
| 3145 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3146 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3147 | uint32_t *bitmap, uint32_t *type) |
| 3148 | { |
| 3149 | __be32 *p; |
| 3150 | |
| 3151 | *type = 0; |
| 3152 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3153 | return -EIO; |
| 3154 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3155 | p = xdr_inline_decode(xdr, 4); |
| 3156 | if (unlikely(!p)) |
| 3157 | goto out_overflow; |
| 3158 | *type = be32_to_cpup(p); |
| 3159 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3160 | } |
| 3161 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3162 | return 0; |
| 3163 | out_overflow: |
| 3164 | print_overflow_msg(__func__, xdr); |
| 3165 | return -EIO; |
| 3166 | } |
| 3167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3168 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3169 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3170 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3171 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | |
| 3173 | *change = 0; |
| 3174 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3175 | return -EIO; |
| 3176 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3177 | p = xdr_inline_decode(xdr, 8); |
| 3178 | if (unlikely(!p)) |
| 3179 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3180 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3182 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3184 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3186 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3187 | out_overflow: |
| 3188 | print_overflow_msg(__func__, xdr); |
| 3189 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3190 | } |
| 3191 | |
| 3192 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3193 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3194 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3195 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | |
| 3197 | *size = 0; |
| 3198 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3199 | return -EIO; |
| 3200 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3201 | p = xdr_inline_decode(xdr, 8); |
| 3202 | if (unlikely(!p)) |
| 3203 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3204 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3205 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3206 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3208 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3209 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3210 | out_overflow: |
| 3211 | print_overflow_msg(__func__, xdr); |
| 3212 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3213 | } |
| 3214 | |
| 3215 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3216 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3217 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | |
| 3219 | *res = 0; |
| 3220 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3221 | return -EIO; |
| 3222 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3223 | p = xdr_inline_decode(xdr, 4); |
| 3224 | if (unlikely(!p)) |
| 3225 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3226 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3227 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3228 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3229 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3231 | out_overflow: |
| 3232 | print_overflow_msg(__func__, xdr); |
| 3233 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3234 | } |
| 3235 | |
| 3236 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3237 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3238 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | |
| 3240 | *res = 0; |
| 3241 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3242 | return -EIO; |
| 3243 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3244 | p = xdr_inline_decode(xdr, 4); |
| 3245 | if (unlikely(!p)) |
| 3246 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3247 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3248 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3249 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3250 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3251 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3252 | out_overflow: |
| 3253 | print_overflow_msg(__func__, xdr); |
| 3254 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 | } |
| 3256 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3257 | 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] | 3258 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3259 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3260 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
| 3262 | fsid->major = 0; |
| 3263 | fsid->minor = 0; |
| 3264 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3265 | return -EIO; |
| 3266 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3267 | p = xdr_inline_decode(xdr, 16); |
| 3268 | if (unlikely(!p)) |
| 3269 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3270 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3271 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3273 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3275 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | (unsigned long long)fsid->major, |
| 3277 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3278 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3279 | out_overflow: |
| 3280 | print_overflow_msg(__func__, xdr); |
| 3281 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3282 | } |
| 3283 | |
| 3284 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3285 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3286 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3287 | |
| 3288 | *res = 60; |
| 3289 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3290 | return -EIO; |
| 3291 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3292 | p = xdr_inline_decode(xdr, 4); |
| 3293 | if (unlikely(!p)) |
| 3294 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3295 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3297 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3298 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3299 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3300 | out_overflow: |
| 3301 | print_overflow_msg(__func__, xdr); |
| 3302 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3303 | } |
| 3304 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3305 | 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] | 3306 | { |
| 3307 | __be32 *p; |
| 3308 | |
| 3309 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3310 | return -EIO; |
| 3311 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3312 | p = xdr_inline_decode(xdr, 4); |
| 3313 | if (unlikely(!p)) |
| 3314 | goto out_overflow; |
| 3315 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3316 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3317 | } |
| 3318 | return 0; |
| 3319 | out_overflow: |
| 3320 | print_overflow_msg(__func__, xdr); |
| 3321 | return -EIO; |
| 3322 | } |
| 3323 | |
| 3324 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3325 | { |
| 3326 | __be32 *p; |
| 3327 | int len; |
| 3328 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3329 | if (fh != NULL) |
| 3330 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3331 | |
| 3332 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3333 | return -EIO; |
| 3334 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3335 | p = xdr_inline_decode(xdr, 4); |
| 3336 | if (unlikely(!p)) |
| 3337 | goto out_overflow; |
| 3338 | len = be32_to_cpup(p); |
| 3339 | if (len > NFS4_FHSIZE) |
| 3340 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3341 | p = xdr_inline_decode(xdr, len); |
| 3342 | if (unlikely(!p)) |
| 3343 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3344 | if (fh != NULL) { |
| 3345 | memcpy(fh->data, p, len); |
| 3346 | fh->size = len; |
| 3347 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3348 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3349 | } |
| 3350 | return 0; |
| 3351 | out_overflow: |
| 3352 | print_overflow_msg(__func__, xdr); |
| 3353 | return -EIO; |
| 3354 | } |
| 3355 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3356 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3357 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3358 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3359 | |
| 3360 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 3361 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3362 | return -EIO; |
| 3363 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3364 | p = xdr_inline_decode(xdr, 4); |
| 3365 | if (unlikely(!p)) |
| 3366 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3367 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3368 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3369 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3370 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3371 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3372 | out_overflow: |
| 3373 | print_overflow_msg(__func__, xdr); |
| 3374 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3375 | } |
| 3376 | |
| 3377 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3378 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3379 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3380 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3381 | |
| 3382 | *fileid = 0; |
| 3383 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3384 | return -EIO; |
| 3385 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3386 | p = xdr_inline_decode(xdr, 8); |
| 3387 | if (unlikely(!p)) |
| 3388 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3389 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3390 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3391 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3392 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3393 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3394 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3395 | out_overflow: |
| 3396 | print_overflow_msg(__func__, xdr); |
| 3397 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3398 | } |
| 3399 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3400 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3401 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3402 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3403 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3404 | |
| 3405 | *fileid = 0; |
| 3406 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3407 | return -EIO; |
| 3408 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3409 | p = xdr_inline_decode(xdr, 8); |
| 3410 | if (unlikely(!p)) |
| 3411 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3412 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3413 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3414 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3415 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3416 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3417 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3418 | out_overflow: |
| 3419 | print_overflow_msg(__func__, xdr); |
| 3420 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3421 | } |
| 3422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3423 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3424 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3425 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3426 | int status = 0; |
| 3427 | |
| 3428 | *res = 0; |
| 3429 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3430 | return -EIO; |
| 3431 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3432 | p = xdr_inline_decode(xdr, 8); |
| 3433 | if (unlikely(!p)) |
| 3434 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3435 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3437 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3438 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3439 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3440 | out_overflow: |
| 3441 | print_overflow_msg(__func__, xdr); |
| 3442 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3443 | } |
| 3444 | |
| 3445 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3446 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3447 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3448 | int status = 0; |
| 3449 | |
| 3450 | *res = 0; |
| 3451 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3452 | return -EIO; |
| 3453 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3454 | p = xdr_inline_decode(xdr, 8); |
| 3455 | if (unlikely(!p)) |
| 3456 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3457 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3458 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3459 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3460 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3461 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3462 | out_overflow: |
| 3463 | print_overflow_msg(__func__, xdr); |
| 3464 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | } |
| 3466 | |
| 3467 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3468 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3469 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3470 | int status = 0; |
| 3471 | |
| 3472 | *res = 0; |
| 3473 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3474 | return -EIO; |
| 3475 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3476 | p = xdr_inline_decode(xdr, 8); |
| 3477 | if (unlikely(!p)) |
| 3478 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3479 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3480 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3481 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3482 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3483 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3484 | out_overflow: |
| 3485 | print_overflow_msg(__func__, xdr); |
| 3486 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3487 | } |
| 3488 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3489 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3490 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3491 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3492 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3493 | int status = 0; |
| 3494 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3495 | p = xdr_inline_decode(xdr, 4); |
| 3496 | if (unlikely(!p)) |
| 3497 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3498 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3499 | if (n == 0) |
| 3500 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3501 | dprintk("pathname4: "); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3502 | path->ncomponents = 0; |
| 3503 | while (path->ncomponents < n) { |
| 3504 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3505 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3506 | if (unlikely(status != 0)) |
| 3507 | goto out_eio; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3508 | if (unlikely(nfs_debug & NFSDBG_XDR)) |
| 3509 | pr_cont("%s%.*s ", |
| 3510 | (path->ncomponents != n ? "/ " : ""), |
| 3511 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3512 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 3513 | path->ncomponents++; |
| 3514 | else { |
| 3515 | dprintk("cannot parse %d components in path\n", n); |
| 3516 | goto out_eio; |
| 3517 | } |
| 3518 | } |
| 3519 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3520 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3521 | root_path: |
| 3522 | /* a root pathname is sent as a zero component4 */ |
| 3523 | path->ncomponents = 1; |
| 3524 | path->components[0].len=0; |
| 3525 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3526 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3527 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3528 | out_eio: |
| 3529 | dprintk(" status %d", status); |
| 3530 | status = -EIO; |
| 3531 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3532 | out_overflow: |
| 3533 | print_overflow_msg(__func__, xdr); |
| 3534 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3535 | } |
| 3536 | |
| 3537 | 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] | 3538 | { |
| 3539 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3540 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3541 | int status = -EIO; |
| 3542 | |
| 3543 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3544 | goto out; |
| 3545 | status = 0; |
| 3546 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3547 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3548 | status = -EIO; |
| 3549 | /* Ignore borken servers that return unrequested attrs */ |
| 3550 | if (unlikely(res == NULL)) |
| 3551 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3552 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3553 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3554 | if (unlikely(status != 0)) |
| 3555 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3556 | p = xdr_inline_decode(xdr, 4); |
| 3557 | if (unlikely(!p)) |
| 3558 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3559 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3560 | if (n <= 0) |
| 3561 | goto out_eio; |
| 3562 | res->nlocations = 0; |
| 3563 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3564 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3565 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3566 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3567 | p = xdr_inline_decode(xdr, 4); |
| 3568 | if (unlikely(!p)) |
| 3569 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3570 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3571 | |
| 3572 | loc->nservers = 0; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3573 | dprintk("%s: servers:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3574 | while (loc->nservers < m) { |
| 3575 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3576 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3577 | if (unlikely(status != 0)) |
| 3578 | goto out_eio; |
| 3579 | dprintk("%s ", server->data); |
| 3580 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3581 | loc->nservers++; |
| 3582 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3583 | unsigned int i; |
| 3584 | dprintk("%s: using first %u of %u servers " |
| 3585 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3586 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3587 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3588 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3589 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3590 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3591 | char *data; |
| 3592 | status = decode_opaque_inline(xdr, &len, &data); |
| 3593 | if (unlikely(status != 0)) |
| 3594 | goto out_eio; |
| 3595 | } |
| 3596 | } |
| 3597 | } |
| 3598 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3599 | if (unlikely(status != 0)) |
| 3600 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3601 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3602 | res->nlocations++; |
| 3603 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3604 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3605 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3606 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3607 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3608 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3609 | out_overflow: |
| 3610 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3611 | out_eio: |
| 3612 | status = -EIO; |
| 3613 | goto out; |
| 3614 | } |
| 3615 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3616 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3617 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3618 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3619 | int status = 0; |
| 3620 | |
| 3621 | *res = 0; |
| 3622 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3623 | return -EIO; |
| 3624 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3625 | p = xdr_inline_decode(xdr, 8); |
| 3626 | if (unlikely(!p)) |
| 3627 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3628 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3629 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3630 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3631 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3632 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3633 | out_overflow: |
| 3634 | print_overflow_msg(__func__, xdr); |
| 3635 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3636 | } |
| 3637 | |
| 3638 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3639 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3640 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | int status = 0; |
| 3642 | |
| 3643 | *maxlink = 1; |
| 3644 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3645 | return -EIO; |
| 3646 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3647 | p = xdr_inline_decode(xdr, 4); |
| 3648 | if (unlikely(!p)) |
| 3649 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3650 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3651 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3652 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3653 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3654 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3655 | out_overflow: |
| 3656 | print_overflow_msg(__func__, xdr); |
| 3657 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3658 | } |
| 3659 | |
| 3660 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3661 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3662 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3663 | int status = 0; |
| 3664 | |
| 3665 | *maxname = 1024; |
| 3666 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3667 | return -EIO; |
| 3668 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3669 | p = xdr_inline_decode(xdr, 4); |
| 3670 | if (unlikely(!p)) |
| 3671 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3672 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3673 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3674 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3675 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3677 | out_overflow: |
| 3678 | print_overflow_msg(__func__, xdr); |
| 3679 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3680 | } |
| 3681 | |
| 3682 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3683 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3684 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3685 | int status = 0; |
| 3686 | |
| 3687 | *res = 1024; |
| 3688 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3689 | return -EIO; |
| 3690 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3691 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3692 | p = xdr_inline_decode(xdr, 8); |
| 3693 | if (unlikely(!p)) |
| 3694 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3695 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3696 | if (maxread > 0x7FFFFFFF) |
| 3697 | maxread = 0x7FFFFFFF; |
| 3698 | *res = (uint32_t)maxread; |
| 3699 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3700 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3701 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3702 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3703 | out_overflow: |
| 3704 | print_overflow_msg(__func__, xdr); |
| 3705 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3706 | } |
| 3707 | |
| 3708 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3709 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3710 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3711 | int status = 0; |
| 3712 | |
| 3713 | *res = 1024; |
| 3714 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3715 | return -EIO; |
| 3716 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3717 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3718 | p = xdr_inline_decode(xdr, 8); |
| 3719 | if (unlikely(!p)) |
| 3720 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3721 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3722 | if (maxwrite > 0x7FFFFFFF) |
| 3723 | maxwrite = 0x7FFFFFFF; |
| 3724 | *res = (uint32_t)maxwrite; |
| 3725 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3726 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3727 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3728 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3729 | out_overflow: |
| 3730 | print_overflow_msg(__func__, xdr); |
| 3731 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | } |
| 3733 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3734 | 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] | 3735 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3736 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3737 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3738 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3739 | |
| 3740 | *mode = 0; |
| 3741 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3742 | return -EIO; |
| 3743 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3744 | p = xdr_inline_decode(xdr, 4); |
| 3745 | if (unlikely(!p)) |
| 3746 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3747 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3748 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3749 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3750 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3752 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3753 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3754 | out_overflow: |
| 3755 | print_overflow_msg(__func__, xdr); |
| 3756 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3757 | } |
| 3758 | |
| 3759 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3760 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3761 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3762 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3763 | |
| 3764 | *nlink = 1; |
| 3765 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3766 | return -EIO; |
| 3767 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3768 | p = xdr_inline_decode(xdr, 4); |
| 3769 | if (unlikely(!p)) |
| 3770 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3771 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3772 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3773 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3774 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3775 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3776 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3777 | out_overflow: |
| 3778 | print_overflow_msg(__func__, xdr); |
| 3779 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3780 | } |
| 3781 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3782 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3783 | const struct nfs_server *server, uint32_t *uid, |
| 3784 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3785 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3786 | uint32_t len; |
| 3787 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3788 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3789 | |
| 3790 | *uid = -2; |
| 3791 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3792 | return -EIO; |
| 3793 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3794 | p = xdr_inline_decode(xdr, 4); |
| 3795 | if (unlikely(!p)) |
| 3796 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3797 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3798 | p = xdr_inline_decode(xdr, len); |
| 3799 | if (unlikely(!p)) |
| 3800 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3801 | if (owner_name != NULL) { |
| 3802 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3803 | if (owner_name->data != NULL) { |
| 3804 | owner_name->len = len; |
| 3805 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3806 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3807 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3808 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3809 | ret = NFS_ATTR_FATTR_OWNER; |
| 3810 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3811 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3812 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3813 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3814 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3815 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3817 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3818 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3819 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3820 | out_overflow: |
| 3821 | print_overflow_msg(__func__, xdr); |
| 3822 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3823 | } |
| 3824 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3825 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3826 | const struct nfs_server *server, uint32_t *gid, |
| 3827 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3828 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3829 | uint32_t len; |
| 3830 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3831 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3832 | |
| 3833 | *gid = -2; |
| 3834 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3835 | return -EIO; |
| 3836 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3837 | p = xdr_inline_decode(xdr, 4); |
| 3838 | if (unlikely(!p)) |
| 3839 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3840 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3841 | p = xdr_inline_decode(xdr, len); |
| 3842 | if (unlikely(!p)) |
| 3843 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3844 | if (group_name != NULL) { |
| 3845 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3846 | if (group_name->data != NULL) { |
| 3847 | group_name->len = len; |
| 3848 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3849 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3850 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3851 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3852 | ret = NFS_ATTR_FATTR_GROUP; |
| 3853 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3855 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3856 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3857 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3858 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3859 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3860 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3861 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3862 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3863 | out_overflow: |
| 3864 | print_overflow_msg(__func__, xdr); |
| 3865 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3866 | } |
| 3867 | |
| 3868 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3869 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3870 | uint32_t major = 0, minor = 0; |
| 3871 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3872 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3873 | |
| 3874 | *rdev = MKDEV(0,0); |
| 3875 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3876 | return -EIO; |
| 3877 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3878 | dev_t tmp; |
| 3879 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3880 | p = xdr_inline_decode(xdr, 8); |
| 3881 | if (unlikely(!p)) |
| 3882 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3883 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3884 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3885 | tmp = MKDEV(major, minor); |
| 3886 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3887 | *rdev = tmp; |
| 3888 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3889 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3890 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3891 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3892 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3893 | out_overflow: |
| 3894 | print_overflow_msg(__func__, xdr); |
| 3895 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3896 | } |
| 3897 | |
| 3898 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3899 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3900 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | int status = 0; |
| 3902 | |
| 3903 | *res = 0; |
| 3904 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3905 | return -EIO; |
| 3906 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3907 | p = xdr_inline_decode(xdr, 8); |
| 3908 | if (unlikely(!p)) |
| 3909 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3910 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3911 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3912 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3913 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3914 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3915 | out_overflow: |
| 3916 | print_overflow_msg(__func__, xdr); |
| 3917 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3918 | } |
| 3919 | |
| 3920 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3921 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3922 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3923 | int status = 0; |
| 3924 | |
| 3925 | *res = 0; |
| 3926 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3927 | return -EIO; |
| 3928 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3929 | p = xdr_inline_decode(xdr, 8); |
| 3930 | if (unlikely(!p)) |
| 3931 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3932 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3933 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3934 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3935 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3937 | out_overflow: |
| 3938 | print_overflow_msg(__func__, xdr); |
| 3939 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3940 | } |
| 3941 | |
| 3942 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3943 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3944 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3945 | int status = 0; |
| 3946 | |
| 3947 | *res = 0; |
| 3948 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3949 | return -EIO; |
| 3950 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3951 | p = xdr_inline_decode(xdr, 8); |
| 3952 | if (unlikely(!p)) |
| 3953 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3954 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3955 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 3956 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3957 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3959 | out_overflow: |
| 3960 | print_overflow_msg(__func__, xdr); |
| 3961 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3962 | } |
| 3963 | |
| 3964 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 3965 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3966 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3967 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3968 | |
| 3969 | *used = 0; |
| 3970 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 3971 | return -EIO; |
| 3972 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3973 | p = xdr_inline_decode(xdr, 8); |
| 3974 | if (unlikely(!p)) |
| 3975 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3976 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3978 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3979 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3980 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3981 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3982 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3983 | out_overflow: |
| 3984 | print_overflow_msg(__func__, xdr); |
| 3985 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3986 | } |
| 3987 | |
| 3988 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 3989 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3990 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | uint64_t sec; |
| 3992 | uint32_t nsec; |
| 3993 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3994 | p = xdr_inline_decode(xdr, 12); |
| 3995 | if (unlikely(!p)) |
| 3996 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3997 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3998 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3999 | time->tv_sec = (time_t)sec; |
| 4000 | time->tv_nsec = (long)nsec; |
| 4001 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4002 | out_overflow: |
| 4003 | print_overflow_msg(__func__, xdr); |
| 4004 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4005 | } |
| 4006 | |
| 4007 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4008 | { |
| 4009 | int status = 0; |
| 4010 | |
| 4011 | time->tv_sec = 0; |
| 4012 | time->tv_nsec = 0; |
| 4013 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4014 | return -EIO; |
| 4015 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4016 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4017 | if (status == 0) |
| 4018 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4019 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4020 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4021 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4022 | return status; |
| 4023 | } |
| 4024 | |
| 4025 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4026 | { |
| 4027 | int status = 0; |
| 4028 | |
| 4029 | time->tv_sec = 0; |
| 4030 | time->tv_nsec = 0; |
| 4031 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4032 | return -EIO; |
| 4033 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4034 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4035 | if (status == 0) |
| 4036 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4037 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4038 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4039 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4040 | return status; |
| 4041 | } |
| 4042 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4043 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4044 | struct timespec *time) |
| 4045 | { |
| 4046 | int status = 0; |
| 4047 | |
| 4048 | time->tv_sec = 0; |
| 4049 | time->tv_nsec = 0; |
| 4050 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4051 | return -EIO; |
| 4052 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4053 | status = decode_attr_time(xdr, time); |
| 4054 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4055 | } |
| 4056 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4057 | (long)time->tv_nsec); |
| 4058 | return status; |
| 4059 | } |
| 4060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4061 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4062 | { |
| 4063 | int status = 0; |
| 4064 | |
| 4065 | time->tv_sec = 0; |
| 4066 | time->tv_nsec = 0; |
| 4067 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4068 | return -EIO; |
| 4069 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4070 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4071 | if (status == 0) |
| 4072 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4073 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4074 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4075 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4076 | return status; |
| 4077 | } |
| 4078 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4079 | 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] | 4080 | { |
| 4081 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 4082 | unsigned int nwords = xdr->p - savep; |
| 4083 | |
| 4084 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4085 | dprintk("%s: server returned incorrect attribute length: " |
| 4086 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4087 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | attrwords << 2, |
| 4089 | (attrwords < nwords) ? '<' : '>', |
| 4090 | nwords << 2); |
| 4091 | return -EIO; |
| 4092 | } |
| 4093 | return 0; |
| 4094 | } |
| 4095 | |
| 4096 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4097 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4098 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4099 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4100 | p = xdr_inline_decode(xdr, 20); |
| 4101 | if (unlikely(!p)) |
| 4102 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4103 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4104 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4105 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4106 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4107 | out_overflow: |
| 4108 | print_overflow_msg(__func__, xdr); |
| 4109 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | } |
| 4111 | |
| 4112 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 4113 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4114 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4115 | uint32_t supp, acc; |
| 4116 | int status; |
| 4117 | |
| 4118 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4119 | if (status) |
| 4120 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4121 | p = xdr_inline_decode(xdr, 8); |
| 4122 | if (unlikely(!p)) |
| 4123 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4124 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4125 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4126 | access->supported = supp; |
| 4127 | access->access = acc; |
| 4128 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4129 | out_overflow: |
| 4130 | print_overflow_msg(__func__, xdr); |
| 4131 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4132 | } |
| 4133 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4134 | 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] | 4135 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4136 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4137 | |
| 4138 | p = xdr_inline_decode(xdr, len); |
| 4139 | if (likely(p)) { |
| 4140 | memcpy(buf, p, len); |
| 4141 | return 0; |
| 4142 | } |
| 4143 | print_overflow_msg(__func__, xdr); |
| 4144 | return -EIO; |
| 4145 | } |
| 4146 | |
| 4147 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4148 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4149 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4150 | } |
| 4151 | |
| 4152 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4153 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4154 | int status; |
| 4155 | |
| 4156 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4157 | if (status != -EIO) |
| 4158 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4159 | if (!status) |
| 4160 | status = decode_stateid(xdr, &res->stateid); |
| 4161 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | } |
| 4163 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4164 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4165 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 4166 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4167 | } |
| 4168 | |
| 4169 | static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 4170 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4171 | int status; |
| 4172 | |
| 4173 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4174 | if (!status) |
| 4175 | status = decode_verifier(xdr, res->verf->verifier); |
| 4176 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4177 | } |
| 4178 | |
| 4179 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4180 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4181 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4182 | uint32_t bmlen; |
| 4183 | int status; |
| 4184 | |
| 4185 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4186 | if (status) |
| 4187 | return status; |
| 4188 | if ((status = decode_change_info(xdr, cinfo))) |
| 4189 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4190 | p = xdr_inline_decode(xdr, 4); |
| 4191 | if (unlikely(!p)) |
| 4192 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4193 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4194 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4195 | if (likely(p)) |
| 4196 | return 0; |
| 4197 | out_overflow: |
| 4198 | print_overflow_msg(__func__, xdr); |
| 4199 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4200 | } |
| 4201 | |
| 4202 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4203 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4204 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4205 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 | int status; |
| 4207 | |
| 4208 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4209 | goto xdr_error; |
| 4210 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4211 | goto xdr_error; |
| 4212 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4213 | goto xdr_error; |
| 4214 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4215 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4216 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4217 | &res->fh_expire_type)) != 0) |
| 4218 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4219 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4220 | goto xdr_error; |
| 4221 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4222 | goto xdr_error; |
| 4223 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4224 | goto xdr_error; |
| 4225 | status = verify_attr_len(xdr, savep, attrlen); |
| 4226 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4227 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4228 | return status; |
| 4229 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4231 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4232 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4233 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4234 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4235 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4237 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4238 | goto xdr_error; |
| 4239 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4240 | goto xdr_error; |
| 4241 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4242 | goto xdr_error; |
| 4243 | |
| 4244 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4245 | goto xdr_error; |
| 4246 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4247 | goto xdr_error; |
| 4248 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4249 | goto xdr_error; |
| 4250 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4251 | goto xdr_error; |
| 4252 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4253 | goto xdr_error; |
| 4254 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4255 | goto xdr_error; |
| 4256 | |
| 4257 | status = verify_attr_len(xdr, savep, attrlen); |
| 4258 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4259 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4260 | return status; |
| 4261 | } |
| 4262 | |
| 4263 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4264 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4265 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4266 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4267 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4269 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4270 | goto xdr_error; |
| 4271 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4272 | goto xdr_error; |
| 4273 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4274 | goto xdr_error; |
| 4275 | |
| 4276 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4277 | goto xdr_error; |
| 4278 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4279 | goto xdr_error; |
| 4280 | |
| 4281 | status = verify_attr_len(xdr, savep, attrlen); |
| 4282 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4283 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4284 | return status; |
| 4285 | } |
| 4286 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4287 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4288 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4289 | struct nfs4_fs_locations *fs_loc, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4290 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4291 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4292 | int status; |
| 4293 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4294 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4295 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4296 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4297 | status = decode_attr_type(xdr, bitmap, &type); |
| 4298 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4299 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4300 | fattr->mode = 0; |
| 4301 | if (status != 0) { |
| 4302 | fattr->mode |= nfs_type2fmt[type]; |
| 4303 | fattr->valid |= status; |
| 4304 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4305 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4306 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4307 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4308 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4309 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4310 | |
| 4311 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4312 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4313 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4314 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4315 | |
| 4316 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4317 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4318 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4319 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4320 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4321 | err = 0; |
| 4322 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4323 | if (status < 0) |
| 4324 | goto xdr_error; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4325 | if (err == -NFS4ERR_WRONGSEC) |
| 4326 | nfs_fixup_secinfo_attributes(fattr, fh); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4327 | |
| 4328 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4329 | if (status < 0) |
| 4330 | goto xdr_error; |
| 4331 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4332 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4333 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4334 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4335 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4336 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4337 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4338 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4339 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4340 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4341 | |
| 4342 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4343 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4344 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4345 | if (status != 0) { |
| 4346 | fattr->mode |= fmode; |
| 4347 | fattr->valid |= status; |
| 4348 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4349 | |
| 4350 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4351 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4352 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4353 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4354 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4355 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4356 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4357 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4358 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4359 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4360 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4361 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4362 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4363 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4364 | |
| 4365 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4366 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4367 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4368 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4369 | |
| 4370 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4371 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4372 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4373 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4374 | |
| 4375 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4376 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4377 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4378 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4379 | |
| 4380 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4381 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4382 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4383 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4384 | |
| 4385 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4386 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4387 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4388 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4389 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4390 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4391 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4392 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4393 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4394 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4395 | xdr_error: |
| 4396 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4397 | return status; |
| 4398 | } |
| 4399 | |
| 4400 | 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] | 4401 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
| 4402 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4403 | { |
| 4404 | __be32 *savep; |
| 4405 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4406 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4407 | int status; |
| 4408 | |
| 4409 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4410 | if (status < 0) |
| 4411 | goto xdr_error; |
| 4412 | |
| 4413 | status = decode_attr_bitmap(xdr, bitmap); |
| 4414 | if (status < 0) |
| 4415 | goto xdr_error; |
| 4416 | |
| 4417 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4418 | if (status < 0) |
| 4419 | goto xdr_error; |
| 4420 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4421 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4422 | if (status < 0) |
| 4423 | goto xdr_error; |
| 4424 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4425 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4426 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4427 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4428 | return status; |
| 4429 | } |
| 4430 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4431 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4432 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4433 | { |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4434 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4435 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4437 | /* |
| 4438 | * Decode potentially multiple layout types. Currently we only support |
| 4439 | * one layout driver per file system. |
| 4440 | */ |
| 4441 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4442 | uint32_t *layouttype) |
| 4443 | { |
| 4444 | uint32_t *p; |
| 4445 | int num; |
| 4446 | |
| 4447 | p = xdr_inline_decode(xdr, 4); |
| 4448 | if (unlikely(!p)) |
| 4449 | goto out_overflow; |
| 4450 | num = be32_to_cpup(p); |
| 4451 | |
| 4452 | /* pNFS is not supported by the underlying file system */ |
| 4453 | if (num == 0) { |
| 4454 | *layouttype = 0; |
| 4455 | return 0; |
| 4456 | } |
| 4457 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4458 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4459 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4460 | |
| 4461 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4462 | p = xdr_inline_decode(xdr, num * 4); |
| 4463 | if (unlikely(!p)) |
| 4464 | goto out_overflow; |
| 4465 | *layouttype = be32_to_cpup(p); |
| 4466 | return 0; |
| 4467 | out_overflow: |
| 4468 | print_overflow_msg(__func__, xdr); |
| 4469 | return -EIO; |
| 4470 | } |
| 4471 | |
| 4472 | /* |
| 4473 | * The type of file system exported. |
| 4474 | * Note we must ensure that layouttype is set in any non-error case. |
| 4475 | */ |
| 4476 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4477 | uint32_t *layouttype) |
| 4478 | { |
| 4479 | int status = 0; |
| 4480 | |
| 4481 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4482 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4483 | return -EIO; |
| 4484 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4485 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4486 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4487 | } else |
| 4488 | *layouttype = 0; |
| 4489 | return status; |
| 4490 | } |
| 4491 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4492 | /* |
| 4493 | * The prefered block size for layout directed io |
| 4494 | */ |
| 4495 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4496 | uint32_t *res) |
| 4497 | { |
| 4498 | __be32 *p; |
| 4499 | |
| 4500 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4501 | *res = 0; |
| 4502 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4503 | p = xdr_inline_decode(xdr, 4); |
| 4504 | if (unlikely(!p)) { |
| 4505 | print_overflow_msg(__func__, xdr); |
| 4506 | return -EIO; |
| 4507 | } |
| 4508 | *res = be32_to_cpup(p); |
| 4509 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4510 | } |
| 4511 | return 0; |
| 4512 | } |
| 4513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4514 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4515 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4516 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4517 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | int status; |
| 4519 | |
| 4520 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4521 | goto xdr_error; |
| 4522 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4523 | goto xdr_error; |
| 4524 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4525 | goto xdr_error; |
| 4526 | |
| 4527 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4528 | |
| 4529 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4530 | goto xdr_error; |
| 4531 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4532 | goto xdr_error; |
| 4533 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4534 | goto xdr_error; |
| 4535 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4536 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4537 | goto xdr_error; |
| 4538 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4539 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4540 | if (status != 0) |
| 4541 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4542 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4543 | if (status != 0) |
| 4544 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4545 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4546 | if (status) |
| 4547 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4548 | |
| 4549 | status = verify_attr_len(xdr, savep, attrlen); |
| 4550 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4551 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4552 | return status; |
| 4553 | } |
| 4554 | |
| 4555 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4556 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4557 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4558 | uint32_t len; |
| 4559 | int status; |
| 4560 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4561 | /* Zero handle first to allow comparisons */ |
| 4562 | memset(fh, 0, sizeof(*fh)); |
| 4563 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4564 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4565 | if (status) |
| 4566 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4567 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4568 | p = xdr_inline_decode(xdr, 4); |
| 4569 | if (unlikely(!p)) |
| 4570 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4571 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4572 | if (len > NFS4_FHSIZE) |
| 4573 | return -EIO; |
| 4574 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4575 | p = xdr_inline_decode(xdr, len); |
| 4576 | if (unlikely(!p)) |
| 4577 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4578 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4579 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4580 | out_overflow: |
| 4581 | print_overflow_msg(__func__, xdr); |
| 4582 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4583 | } |
| 4584 | |
| 4585 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4586 | { |
| 4587 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4588 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4589 | status = decode_op_hdr(xdr, OP_LINK); |
| 4590 | if (status) |
| 4591 | return status; |
| 4592 | return decode_change_info(xdr, cinfo); |
| 4593 | } |
| 4594 | |
| 4595 | /* |
| 4596 | * We create the owner, so we know a proper owner.id length is 4. |
| 4597 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4598 | 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] | 4599 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4600 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4601 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4602 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4603 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4604 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4605 | if (unlikely(!p)) |
| 4606 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4607 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4608 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4609 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4610 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4611 | fl->fl_start = (loff_t)offset; |
| 4612 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4613 | if (length == ~(uint64_t)0) |
| 4614 | fl->fl_end = OFFSET_MAX; |
| 4615 | fl->fl_type = F_WRLCK; |
| 4616 | if (type & 1) |
| 4617 | fl->fl_type = F_RDLCK; |
| 4618 | fl->fl_pid = 0; |
| 4619 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4620 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4621 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4622 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4623 | if (likely(p)) |
| 4624 | return -NFS4ERR_DENIED; |
| 4625 | out_overflow: |
| 4626 | print_overflow_msg(__func__, xdr); |
| 4627 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4628 | } |
| 4629 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4630 | 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] | 4631 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | int status; |
| 4633 | |
| 4634 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4635 | if (status == -EIO) |
| 4636 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4637 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4638 | status = decode_stateid(xdr, &res->stateid); |
| 4639 | if (unlikely(status)) |
| 4640 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4641 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4642 | status = decode_lock_denied(xdr, NULL); |
| 4643 | if (res->open_seqid != NULL) |
| 4644 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4645 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4646 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4647 | return status; |
| 4648 | } |
| 4649 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4650 | 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] | 4651 | { |
| 4652 | int status; |
| 4653 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4654 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4655 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | return status; |
| 4657 | } |
| 4658 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4659 | 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] | 4660 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4661 | int status; |
| 4662 | |
| 4663 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4664 | if (status != -EIO) |
| 4665 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4666 | if (status == 0) |
| 4667 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4668 | return status; |
| 4669 | } |
| 4670 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4671 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4672 | { |
| 4673 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4674 | } |
| 4675 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4676 | static int decode_lookup(struct xdr_stream *xdr) |
| 4677 | { |
| 4678 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4679 | } |
| 4680 | |
| 4681 | /* This is too sick! */ |
| 4682 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4683 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4684 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4685 | uint32_t limit_type, nblocks, blocksize; |
| 4686 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4687 | p = xdr_inline_decode(xdr, 12); |
| 4688 | if (unlikely(!p)) |
| 4689 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4690 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4691 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4692 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4693 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4694 | break; |
| 4695 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4696 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4697 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4698 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4699 | } |
| 4700 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4701 | out_overflow: |
| 4702 | print_overflow_msg(__func__, xdr); |
| 4703 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4704 | } |
| 4705 | |
| 4706 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4707 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4708 | __be32 *p; |
| 4709 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4710 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4712 | p = xdr_inline_decode(xdr, 4); |
| 4713 | if (unlikely(!p)) |
| 4714 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4715 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4716 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4717 | res->delegation_type = 0; |
| 4718 | return 0; |
| 4719 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4720 | status = decode_stateid(xdr, &res->delegation); |
| 4721 | if (unlikely(status)) |
| 4722 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4723 | p = xdr_inline_decode(xdr, 4); |
| 4724 | if (unlikely(!p)) |
| 4725 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4726 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4728 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4729 | case NFS4_OPEN_DELEGATE_READ: |
| 4730 | res->delegation_type = FMODE_READ; |
| 4731 | break; |
| 4732 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4733 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4734 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4735 | return -EIO; |
| 4736 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4737 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4738 | out_overflow: |
| 4739 | print_overflow_msg(__func__, xdr); |
| 4740 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4741 | } |
| 4742 | |
| 4743 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4744 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4745 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4746 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4747 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4748 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4749 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4750 | if (status != -EIO) |
| 4751 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4752 | if (!status) |
| 4753 | status = decode_stateid(xdr, &res->stateid); |
| 4754 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4755 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4756 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4757 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4758 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4759 | p = xdr_inline_decode(xdr, 8); |
| 4760 | if (unlikely(!p)) |
| 4761 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4762 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4763 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4764 | if (bmlen > 10) |
| 4765 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4766 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4767 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4768 | if (unlikely(!p)) |
| 4769 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4770 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4771 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4772 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4773 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4774 | res->attrset[i] = 0; |
| 4775 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4776 | return decode_delegation(xdr, res); |
| 4777 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4778 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4779 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4780 | out_overflow: |
| 4781 | print_overflow_msg(__func__, xdr); |
| 4782 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4783 | } |
| 4784 | |
| 4785 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4786 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4787 | int status; |
| 4788 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4789 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4790 | if (status != -EIO) |
| 4791 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4792 | if (!status) |
| 4793 | status = decode_stateid(xdr, &res->stateid); |
| 4794 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4798 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4799 | int status; |
| 4800 | |
| 4801 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4802 | if (status != -EIO) |
| 4803 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4804 | if (!status) |
| 4805 | status = decode_stateid(xdr, &res->stateid); |
| 4806 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4807 | } |
| 4808 | |
| 4809 | static int decode_putfh(struct xdr_stream *xdr) |
| 4810 | { |
| 4811 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4812 | } |
| 4813 | |
| 4814 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4815 | { |
| 4816 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4817 | } |
| 4818 | |
| 4819 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4820 | { |
| 4821 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4822 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4823 | uint32_t count, eof, recvd, hdrlen; |
| 4824 | int status; |
| 4825 | |
| 4826 | status = decode_op_hdr(xdr, OP_READ); |
| 4827 | if (status) |
| 4828 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4829 | p = xdr_inline_decode(xdr, 8); |
| 4830 | if (unlikely(!p)) |
| 4831 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4832 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4833 | count = be32_to_cpup(p); |
Chuck Lever | 8111f37 | 2010-12-14 14:58:01 +0000 | [diff] [blame] | 4834 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4835 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4836 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4837 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4838 | "count %u > recvd %u\n", count, recvd); |
| 4839 | count = recvd; |
| 4840 | eof = 0; |
| 4841 | } |
| 4842 | xdr_read_pages(xdr, count); |
| 4843 | res->eof = eof; |
| 4844 | res->count = count; |
| 4845 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4846 | out_overflow: |
| 4847 | print_overflow_msg(__func__, xdr); |
| 4848 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4849 | } |
| 4850 | |
| 4851 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4852 | { |
| 4853 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4854 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4855 | size_t hdrlen; |
| 4856 | u32 recvd, pglen = rcvbuf->page_len; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4857 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 4858 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4859 | |
| 4860 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4861 | if (!status) |
| 4862 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4863 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4864 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 4865 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4866 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 4867 | __func__, verf[0], verf[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4868 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4869 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4870 | recvd = rcvbuf->len - hdrlen; |
| 4871 | if (pglen > recvd) |
| 4872 | pglen = recvd; |
| 4873 | xdr_read_pages(xdr, pglen); |
| 4874 | |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4875 | |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 4876 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4877 | } |
| 4878 | |
| 4879 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4880 | { |
| 4881 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4882 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4883 | size_t hdrlen; |
| 4884 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4885 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4886 | int status; |
| 4887 | |
| 4888 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4889 | if (status) |
| 4890 | return status; |
| 4891 | |
| 4892 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4893 | p = xdr_inline_decode(xdr, 4); |
| 4894 | if (unlikely(!p)) |
| 4895 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4896 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4897 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4898 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4899 | return -ENAMETOOLONG; |
| 4900 | } |
| 4901 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4902 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4903 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4904 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4905 | "count %u > recvd %u\n", len, recvd); |
| 4906 | return -EIO; |
| 4907 | } |
| 4908 | xdr_read_pages(xdr, len); |
| 4909 | /* |
| 4910 | * The XDR encode routine has set things up so that |
| 4911 | * the link text will be copied directly into the |
| 4912 | * buffer. We just have to do overflow-checking, |
| 4913 | * and and null-terminate the text (the VFS expects |
| 4914 | * null-termination). |
| 4915 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 4916 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4917 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4918 | out_overflow: |
| 4919 | print_overflow_msg(__func__, xdr); |
| 4920 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4921 | } |
| 4922 | |
| 4923 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4924 | { |
| 4925 | int status; |
| 4926 | |
| 4927 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 4928 | if (status) |
| 4929 | goto out; |
| 4930 | status = decode_change_info(xdr, cinfo); |
| 4931 | out: |
| 4932 | return status; |
| 4933 | } |
| 4934 | |
| 4935 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 4936 | struct nfs4_change_info *new_cinfo) |
| 4937 | { |
| 4938 | int status; |
| 4939 | |
| 4940 | status = decode_op_hdr(xdr, OP_RENAME); |
| 4941 | if (status) |
| 4942 | goto out; |
| 4943 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 4944 | goto out; |
| 4945 | status = decode_change_info(xdr, new_cinfo); |
| 4946 | out: |
| 4947 | return status; |
| 4948 | } |
| 4949 | |
| 4950 | static int decode_renew(struct xdr_stream *xdr) |
| 4951 | { |
| 4952 | return decode_op_hdr(xdr, OP_RENEW); |
| 4953 | } |
| 4954 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4955 | static int |
| 4956 | decode_restorefh(struct xdr_stream *xdr) |
| 4957 | { |
| 4958 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 4959 | } |
| 4960 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4961 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4962 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4963 | { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4964 | __be32 *savep, *bm_p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4965 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4966 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4967 | struct kvec *iov = req->rq_rcv_buf.head; |
| 4968 | int status; |
| 4969 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4970 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4971 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4972 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4973 | bm_p = xdr->p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4974 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4975 | goto out; |
| 4976 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4977 | goto out; |
| 4978 | |
| 4979 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 4980 | return -EIO; |
| 4981 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4982 | size_t hdrlen; |
| 4983 | u32 recvd; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4984 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4985 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 4986 | * are stored with the acl data to handle the problem of |
| 4987 | * variable length bitmaps.*/ |
| 4988 | xdr->p = bm_p; |
| 4989 | res->acl_data_offset = be32_to_cpup(bm_p) + 2; |
| 4990 | res->acl_data_offset <<= 2; |
| 4991 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4992 | /* We ignore &savep and don't do consistency checks on |
| 4993 | * the attr length. Let userspace figure it out.... */ |
| 4994 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4995 | attrlen += res->acl_data_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4996 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4997 | if (attrlen > recvd) { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4998 | if (res->acl_flags & NFS4_ACL_LEN_REQUEST) { |
| 4999 | /* getxattr interface called with a NULL buf */ |
| 5000 | res->acl_len = attrlen; |
| 5001 | goto out; |
| 5002 | } |
| 5003 | dprintk("NFS: acl reply: attrlen %u > recvd %u\n", |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5004 | attrlen, recvd); |
| 5005 | return -EINVAL; |
| 5006 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 5007 | xdr_read_pages(xdr, attrlen); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5008 | res->acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5009 | } else |
| 5010 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5011 | |
| 5012 | out: |
| 5013 | return status; |
| 5014 | } |
| 5015 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5016 | static int |
| 5017 | decode_savefh(struct xdr_stream *xdr) |
| 5018 | { |
| 5019 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5020 | } |
| 5021 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5022 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5023 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5024 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5025 | uint32_t bmlen; |
| 5026 | int status; |
| 5027 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5028 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5029 | if (status) |
| 5030 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5031 | p = xdr_inline_decode(xdr, 4); |
| 5032 | if (unlikely(!p)) |
| 5033 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5034 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5035 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5036 | if (likely(p)) |
| 5037 | return 0; |
| 5038 | out_overflow: |
| 5039 | print_overflow_msg(__func__, xdr); |
| 5040 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5041 | } |
| 5042 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5043 | 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] | 5044 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5045 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5046 | uint32_t opnum; |
| 5047 | int32_t nfserr; |
| 5048 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5049 | p = xdr_inline_decode(xdr, 8); |
| 5050 | if (unlikely(!p)) |
| 5051 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5052 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5053 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5054 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5055 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5056 | return -EIO; |
| 5057 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5058 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5059 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5060 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5061 | if (unlikely(!p)) |
| 5062 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5063 | p = xdr_decode_hyper(p, &res->clientid); |
| 5064 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5065 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5066 | uint32_t len; |
| 5067 | |
| 5068 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5069 | p = xdr_inline_decode(xdr, 4); |
| 5070 | if (unlikely(!p)) |
| 5071 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5072 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5073 | p = xdr_inline_decode(xdr, len); |
| 5074 | if (unlikely(!p)) |
| 5075 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5076 | |
| 5077 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5078 | p = xdr_inline_decode(xdr, 4); |
| 5079 | if (unlikely(!p)) |
| 5080 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5081 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5082 | p = xdr_inline_decode(xdr, len); |
| 5083 | if (unlikely(!p)) |
| 5084 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5085 | return -NFSERR_CLID_INUSE; |
| 5086 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5087 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5088 | |
| 5089 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5090 | out_overflow: |
| 5091 | print_overflow_msg(__func__, xdr); |
| 5092 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5093 | } |
| 5094 | |
| 5095 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5096 | { |
| 5097 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5098 | } |
| 5099 | |
| 5100 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 5101 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5102 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5103 | int status; |
| 5104 | |
| 5105 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5106 | if (status) |
| 5107 | return status; |
| 5108 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5109 | p = xdr_inline_decode(xdr, 16); |
| 5110 | if (unlikely(!p)) |
| 5111 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5112 | res->count = be32_to_cpup(p++); |
| 5113 | res->verf->committed = be32_to_cpup(p++); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 5114 | memcpy(res->verf->verifier, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5116 | out_overflow: |
| 5117 | print_overflow_msg(__func__, xdr); |
| 5118 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5119 | } |
| 5120 | |
| 5121 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5122 | { |
| 5123 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5124 | } |
| 5125 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5126 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) |
| 5127 | { |
| 5128 | __be32 *p; |
| 5129 | |
| 5130 | p = xdr_inline_decode(xdr, 4); |
| 5131 | if (unlikely(!p)) |
| 5132 | goto out_overflow; |
| 5133 | flavor->gss.sec_oid4.len = be32_to_cpup(p); |
| 5134 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) |
| 5135 | goto out_err; |
| 5136 | |
| 5137 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); |
| 5138 | if (unlikely(!p)) |
| 5139 | goto out_overflow; |
| 5140 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); |
| 5141 | |
| 5142 | p = xdr_inline_decode(xdr, 8); |
| 5143 | if (unlikely(!p)) |
| 5144 | goto out_overflow; |
| 5145 | flavor->gss.qop4 = be32_to_cpup(p++); |
| 5146 | flavor->gss.service = be32_to_cpup(p); |
| 5147 | |
| 5148 | return 0; |
| 5149 | |
| 5150 | out_overflow: |
| 5151 | print_overflow_msg(__func__, xdr); |
| 5152 | return -EIO; |
| 5153 | out_err: |
| 5154 | return -EINVAL; |
| 5155 | } |
| 5156 | |
| 5157 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5158 | { |
| 5159 | struct nfs4_secinfo_flavor *sec_flavor; |
| 5160 | int status; |
| 5161 | __be32 *p; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5162 | int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5163 | |
| 5164 | status = decode_op_hdr(xdr, OP_SECINFO); |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5165 | if (status) |
| 5166 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5167 | p = xdr_inline_decode(xdr, 4); |
| 5168 | if (unlikely(!p)) |
| 5169 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5170 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5171 | res->flavors->num_flavors = 0; |
| 5172 | num_flavors = be32_to_cpup(p); |
| 5173 | |
| 5174 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5175 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5176 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5177 | break; |
| 5178 | |
| 5179 | p = xdr_inline_decode(xdr, 4); |
| 5180 | if (unlikely(!p)) |
| 5181 | goto out_overflow; |
| 5182 | sec_flavor->flavor = be32_to_cpup(p); |
| 5183 | |
| 5184 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5185 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5186 | if (status) |
| 5187 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5188 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5189 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5190 | } |
| 5191 | |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5192 | out: |
| 5193 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5194 | out_overflow: |
| 5195 | print_overflow_msg(__func__, xdr); |
| 5196 | return -EIO; |
| 5197 | } |
| 5198 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5199 | #if defined(CONFIG_NFS_V4_1) |
| 5200 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5201 | struct nfs41_exchange_id_res *res) |
| 5202 | { |
| 5203 | __be32 *p; |
| 5204 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5205 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5206 | int status; |
| 5207 | struct nfs_client *clp = res->client; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5208 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5209 | |
| 5210 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5211 | if (status) |
| 5212 | return status; |
| 5213 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5214 | p = xdr_inline_decode(xdr, 8); |
| 5215 | if (unlikely(!p)) |
| 5216 | goto out_overflow; |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 5217 | xdr_decode_hyper(p, &clp->cl_clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5218 | p = xdr_inline_decode(xdr, 12); |
| 5219 | if (unlikely(!p)) |
| 5220 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5221 | clp->cl_seqid = be32_to_cpup(p++); |
| 5222 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5223 | |
| 5224 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5225 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5226 | if (dummy != SP4_NONE) |
| 5227 | return -EIO; |
| 5228 | |
| 5229 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5230 | p = xdr_inline_decode(xdr, 8); |
| 5231 | if (unlikely(!p)) |
| 5232 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5233 | |
| 5234 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5235 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5236 | if (unlikely(status)) |
| 5237 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5238 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5239 | /* Save server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5240 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5241 | if (unlikely(status)) |
| 5242 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5243 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5244 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5245 | return -EIO; |
| 5246 | |
| 5247 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5248 | res->server_scope->server_scope_sz = dummy; |
| 5249 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5250 | /* Implementation Id */ |
| 5251 | p = xdr_inline_decode(xdr, 4); |
| 5252 | if (unlikely(!p)) |
| 5253 | goto out_overflow; |
| 5254 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5255 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5256 | if (impl_id_count) { |
| 5257 | /* nii_domain */ |
| 5258 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5259 | if (unlikely(status)) |
| 5260 | return status; |
| 5261 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5262 | return -EIO; |
| 5263 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5264 | |
| 5265 | /* nii_name */ |
| 5266 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5267 | if (unlikely(status)) |
| 5268 | return status; |
| 5269 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5270 | return -EIO; |
| 5271 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5272 | |
| 5273 | /* nii_date */ |
| 5274 | p = xdr_inline_decode(xdr, 12); |
| 5275 | if (unlikely(!p)) |
| 5276 | goto out_overflow; |
| 5277 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5278 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5279 | |
| 5280 | /* if there's more than one entry, ignore the rest */ |
| 5281 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5282 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5283 | out_overflow: |
| 5284 | print_overflow_msg(__func__, xdr); |
| 5285 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5286 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5287 | |
| 5288 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5289 | struct nfs4_channel_attrs *attrs) |
| 5290 | { |
| 5291 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5292 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5293 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5294 | p = xdr_inline_decode(xdr, 28); |
| 5295 | if (unlikely(!p)) |
| 5296 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5297 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5298 | if (val) |
| 5299 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5300 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5301 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5302 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5303 | attrs->max_ops = be32_to_cpup(p++); |
| 5304 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5305 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5306 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5307 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5308 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5309 | return -EINVAL; |
| 5310 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5311 | if (nr_attrs == 1) { |
| 5312 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5313 | if (unlikely(!p)) |
| 5314 | goto out_overflow; |
| 5315 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5316 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5317 | out_overflow: |
| 5318 | print_overflow_msg(__func__, xdr); |
| 5319 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5320 | } |
| 5321 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5322 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5323 | { |
| 5324 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5325 | } |
| 5326 | |
| 5327 | static int decode_create_session(struct xdr_stream *xdr, |
| 5328 | struct nfs41_create_session_res *res) |
| 5329 | { |
| 5330 | __be32 *p; |
| 5331 | int status; |
| 5332 | struct nfs_client *clp = res->client; |
| 5333 | struct nfs4_session *session = clp->cl_session; |
| 5334 | |
| 5335 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5336 | if (!status) |
| 5337 | status = decode_sessionid(xdr, &session->sess_id); |
| 5338 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5339 | return status; |
| 5340 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5341 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5342 | p = xdr_inline_decode(xdr, 8); |
| 5343 | if (unlikely(!p)) |
| 5344 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5345 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5346 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5347 | |
| 5348 | /* Channel attributes */ |
| 5349 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5350 | if (!status) |
| 5351 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5352 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5353 | out_overflow: |
| 5354 | print_overflow_msg(__func__, xdr); |
| 5355 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5356 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5357 | |
| 5358 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5359 | { |
| 5360 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5361 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5362 | |
| 5363 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5364 | { |
| 5365 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5366 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5367 | #endif /* CONFIG_NFS_V4_1 */ |
| 5368 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5369 | static int decode_sequence(struct xdr_stream *xdr, |
| 5370 | struct nfs4_sequence_res *res, |
| 5371 | struct rpc_rqst *rqstp) |
| 5372 | { |
| 5373 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5374 | struct nfs4_sessionid id; |
| 5375 | u32 dummy; |
| 5376 | int status; |
| 5377 | __be32 *p; |
| 5378 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5379 | if (!res->sr_session) |
| 5380 | return 0; |
| 5381 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5382 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5383 | if (!status) |
| 5384 | status = decode_sessionid(xdr, &id); |
| 5385 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5386 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5387 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5388 | /* |
| 5389 | * If the server returns different values for sessionID, slotID or |
| 5390 | * sequence number, the server is looney tunes. |
| 5391 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5392 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5393 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5394 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 5395 | NFS4_MAX_SESSIONID_LEN)) { |
| 5396 | dprintk("%s Invalid session id\n", __func__); |
| 5397 | goto out_err; |
| 5398 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5399 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5400 | p = xdr_inline_decode(xdr, 20); |
| 5401 | if (unlikely(!p)) |
| 5402 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5403 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5404 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5405 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5406 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5407 | dprintk("%s Invalid sequence number\n", __func__); |
| 5408 | goto out_err; |
| 5409 | } |
| 5410 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5411 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5412 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5413 | dprintk("%s Invalid slot id\n", __func__); |
| 5414 | goto out_err; |
| 5415 | } |
| 5416 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5417 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5418 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5419 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5420 | /* result flags */ |
| 5421 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5422 | status = 0; |
| 5423 | out_err: |
| 5424 | res->sr_status = status; |
| 5425 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5426 | out_overflow: |
| 5427 | print_overflow_msg(__func__, xdr); |
| 5428 | status = -EIO; |
| 5429 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5430 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5431 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5432 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5433 | } |
| 5434 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5435 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5436 | /* |
| 5437 | * TODO: Need to handle case when EOF != true; |
| 5438 | */ |
| 5439 | static int decode_getdevicelist(struct xdr_stream *xdr, |
| 5440 | struct pnfs_devicelist *res) |
| 5441 | { |
| 5442 | __be32 *p; |
| 5443 | int status, i; |
| 5444 | struct nfs_writeverf verftemp; |
| 5445 | |
| 5446 | status = decode_op_hdr(xdr, OP_GETDEVICELIST); |
| 5447 | if (status) |
| 5448 | return status; |
| 5449 | |
| 5450 | p = xdr_inline_decode(xdr, 8 + 8 + 4); |
| 5451 | if (unlikely(!p)) |
| 5452 | goto out_overflow; |
| 5453 | |
| 5454 | /* TODO: Skip cookie for now */ |
| 5455 | p += 2; |
| 5456 | |
| 5457 | /* Read verifier */ |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame^] | 5458 | p = xdr_decode_opaque_fixed(p, verftemp.verifier, NFS4_VERIFIER_SIZE); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5459 | |
| 5460 | res->num_devs = be32_to_cpup(p); |
| 5461 | |
| 5462 | dprintk("%s: num_dev %d\n", __func__, res->num_devs); |
| 5463 | |
| 5464 | if (res->num_devs > NFS4_PNFS_GETDEVLIST_MAXNUM) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5465 | printk(KERN_ERR "NFS: %s too many result dev_num %u\n", |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5466 | __func__, res->num_devs); |
| 5467 | return -EIO; |
| 5468 | } |
| 5469 | |
| 5470 | p = xdr_inline_decode(xdr, |
| 5471 | res->num_devs * NFS4_DEVICEID4_SIZE + 4); |
| 5472 | if (unlikely(!p)) |
| 5473 | goto out_overflow; |
| 5474 | for (i = 0; i < res->num_devs; i++) |
| 5475 | p = xdr_decode_opaque_fixed(p, res->dev_id[i].data, |
| 5476 | NFS4_DEVICEID4_SIZE); |
| 5477 | res->eof = be32_to_cpup(p); |
| 5478 | return 0; |
| 5479 | out_overflow: |
| 5480 | print_overflow_msg(__func__, xdr); |
| 5481 | return -EIO; |
| 5482 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5483 | |
| 5484 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5485 | struct pnfs_device *pdev) |
| 5486 | { |
| 5487 | __be32 *p; |
| 5488 | uint32_t len, type; |
| 5489 | int status; |
| 5490 | |
| 5491 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5492 | if (status) { |
| 5493 | if (status == -ETOOSMALL) { |
| 5494 | p = xdr_inline_decode(xdr, 4); |
| 5495 | if (unlikely(!p)) |
| 5496 | goto out_overflow; |
| 5497 | pdev->mincount = be32_to_cpup(p); |
| 5498 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5499 | __func__, pdev->mincount); |
| 5500 | } |
| 5501 | return status; |
| 5502 | } |
| 5503 | |
| 5504 | p = xdr_inline_decode(xdr, 8); |
| 5505 | if (unlikely(!p)) |
| 5506 | goto out_overflow; |
| 5507 | type = be32_to_cpup(p++); |
| 5508 | if (type != pdev->layout_type) { |
| 5509 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5510 | __func__, pdev->layout_type, type); |
| 5511 | return -EINVAL; |
| 5512 | } |
| 5513 | /* |
| 5514 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5515 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5516 | * and places the remaining xdr data in xdr_buf->tail |
| 5517 | */ |
| 5518 | pdev->mincount = be32_to_cpup(p); |
| 5519 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ |
| 5520 | |
| 5521 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5522 | p = xdr_inline_decode(xdr, 4); |
| 5523 | if (unlikely(!p)) |
| 5524 | goto out_overflow; |
| 5525 | len = be32_to_cpup(p); |
| 5526 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5527 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5528 | |
| 5529 | p = xdr_inline_decode(xdr, 4 * len); |
| 5530 | if (unlikely(!p)) |
| 5531 | goto out_overflow; |
| 5532 | for (i = 0; i < len; i++, p++) { |
| 5533 | if (be32_to_cpup(p)) { |
| 5534 | dprintk("%s: notifications not supported\n", |
| 5535 | __func__); |
| 5536 | return -EIO; |
| 5537 | } |
| 5538 | } |
| 5539 | } |
| 5540 | return 0; |
| 5541 | out_overflow: |
| 5542 | print_overflow_msg(__func__, xdr); |
| 5543 | return -EIO; |
| 5544 | } |
| 5545 | |
| 5546 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5547 | struct nfs4_layoutget_res *res) |
| 5548 | { |
| 5549 | __be32 *p; |
| 5550 | int status; |
| 5551 | u32 layout_count; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5552 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 5553 | struct kvec *iov = rcvbuf->head; |
| 5554 | u32 hdrlen, recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5555 | |
| 5556 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5557 | if (status) |
| 5558 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5559 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5560 | if (unlikely(!p)) |
| 5561 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5562 | res->return_on_close = be32_to_cpup(p); |
| 5563 | decode_stateid(xdr, &res->stateid); |
| 5564 | p = xdr_inline_decode(xdr, 4); |
| 5565 | if (unlikely(!p)) |
| 5566 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5567 | layout_count = be32_to_cpup(p); |
| 5568 | if (!layout_count) { |
| 5569 | dprintk("%s: server responded with empty layout array\n", |
| 5570 | __func__); |
| 5571 | return -EINVAL; |
| 5572 | } |
| 5573 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5574 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5575 | if (unlikely(!p)) |
| 5576 | goto out_overflow; |
| 5577 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5578 | p = xdr_decode_hyper(p, &res->range.length); |
| 5579 | res->range.iomode = be32_to_cpup(p++); |
| 5580 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5581 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5582 | |
| 5583 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5584 | __func__, |
| 5585 | (unsigned long)res->range.offset, |
| 5586 | (unsigned long)res->range.length, |
| 5587 | res->range.iomode, |
| 5588 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5589 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5590 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5591 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
| 5592 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5593 | if (res->layoutp->len > recvd) { |
| 5594 | dprintk("NFS: server cheating in layoutget reply: " |
| 5595 | "layout len %u > recvd %u\n", |
| 5596 | res->layoutp->len, recvd); |
| 5597 | return -EINVAL; |
| 5598 | } |
| 5599 | |
| 5600 | xdr_read_pages(xdr, res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5601 | |
| 5602 | if (layout_count > 1) { |
| 5603 | /* We only handle a length one array at the moment. Any |
| 5604 | * further entries are just ignored. Note that this means |
| 5605 | * the client may see a response that is less than the |
| 5606 | * minimum it requested. |
| 5607 | */ |
| 5608 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5609 | __func__, layout_count); |
| 5610 | } |
| 5611 | |
| 5612 | return 0; |
| 5613 | out_overflow: |
| 5614 | print_overflow_msg(__func__, xdr); |
| 5615 | return -EIO; |
| 5616 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5617 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5618 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5619 | struct nfs4_layoutreturn_res *res) |
| 5620 | { |
| 5621 | __be32 *p; |
| 5622 | int status; |
| 5623 | |
| 5624 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5625 | if (status) |
| 5626 | return status; |
| 5627 | p = xdr_inline_decode(xdr, 4); |
| 5628 | if (unlikely(!p)) |
| 5629 | goto out_overflow; |
| 5630 | res->lrs_present = be32_to_cpup(p); |
| 5631 | if (res->lrs_present) |
| 5632 | status = decode_stateid(xdr, &res->stateid); |
| 5633 | return status; |
| 5634 | out_overflow: |
| 5635 | print_overflow_msg(__func__, xdr); |
| 5636 | return -EIO; |
| 5637 | } |
| 5638 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5639 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5640 | struct rpc_rqst *req, |
| 5641 | struct nfs4_layoutcommit_res *res) |
| 5642 | { |
| 5643 | __be32 *p; |
| 5644 | __u32 sizechanged; |
| 5645 | int status; |
| 5646 | |
| 5647 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5648 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5649 | if (status) |
| 5650 | return status; |
| 5651 | |
| 5652 | p = xdr_inline_decode(xdr, 4); |
| 5653 | if (unlikely(!p)) |
| 5654 | goto out_overflow; |
| 5655 | sizechanged = be32_to_cpup(p); |
| 5656 | |
| 5657 | if (sizechanged) { |
| 5658 | /* throw away new size */ |
| 5659 | p = xdr_inline_decode(xdr, 8); |
| 5660 | if (unlikely(!p)) |
| 5661 | goto out_overflow; |
| 5662 | } |
| 5663 | return 0; |
| 5664 | out_overflow: |
| 5665 | print_overflow_msg(__func__, xdr); |
| 5666 | return -EIO; |
| 5667 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5668 | |
| 5669 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5670 | struct nfs41_test_stateid_res *res) |
| 5671 | { |
| 5672 | __be32 *p; |
| 5673 | int status; |
| 5674 | int num_res; |
| 5675 | |
| 5676 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5677 | if (status) |
| 5678 | return status; |
| 5679 | |
| 5680 | p = xdr_inline_decode(xdr, 4); |
| 5681 | if (unlikely(!p)) |
| 5682 | goto out_overflow; |
| 5683 | num_res = be32_to_cpup(p++); |
| 5684 | if (num_res != 1) |
| 5685 | goto out; |
| 5686 | |
| 5687 | p = xdr_inline_decode(xdr, 4); |
| 5688 | if (unlikely(!p)) |
| 5689 | goto out_overflow; |
| 5690 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5691 | |
| 5692 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5693 | out_overflow: |
| 5694 | print_overflow_msg(__func__, xdr); |
| 5695 | out: |
| 5696 | return -EIO; |
| 5697 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5698 | |
| 5699 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5700 | struct nfs41_free_stateid_res *res) |
| 5701 | { |
| 5702 | __be32 *p; |
| 5703 | int status; |
| 5704 | |
| 5705 | status = decode_op_hdr(xdr, OP_FREE_STATEID); |
| 5706 | if (status) |
| 5707 | return status; |
| 5708 | |
| 5709 | p = xdr_inline_decode(xdr, 4); |
| 5710 | if (unlikely(!p)) |
| 5711 | goto out_overflow; |
| 5712 | res->status = be32_to_cpup(p++); |
| 5713 | return res->status; |
| 5714 | out_overflow: |
| 5715 | print_overflow_msg(__func__, xdr); |
| 5716 | return -EIO; |
| 5717 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5718 | #endif /* CONFIG_NFS_V4_1 */ |
| 5719 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5720 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5721 | * END OF "GENERIC" DECODE ROUTINES. |
| 5722 | */ |
| 5723 | |
| 5724 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5725 | * Decode OPEN_DOWNGRADE response |
| 5726 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5727 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5728 | struct xdr_stream *xdr, |
| 5729 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5730 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5731 | struct compound_hdr hdr; |
| 5732 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5733 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5734 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5735 | if (status) |
| 5736 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5737 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5738 | if (status) |
| 5739 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5740 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5741 | if (status) |
| 5742 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5743 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5744 | if (status != 0) |
| 5745 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5746 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5747 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5748 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5749 | } |
| 5750 | |
| 5751 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5752 | * Decode ACCESS response |
| 5753 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5754 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5755 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5756 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5757 | struct compound_hdr hdr; |
| 5758 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5759 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5760 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5761 | if (status) |
| 5762 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5763 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5764 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5765 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5766 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5767 | if (status != 0) |
| 5768 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5769 | status = decode_access(xdr, res); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5770 | if (status != 0) |
| 5771 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5772 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5773 | out: |
| 5774 | return status; |
| 5775 | } |
| 5776 | |
| 5777 | /* |
| 5778 | * Decode LOOKUP response |
| 5779 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5780 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5781 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5782 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5783 | struct compound_hdr hdr; |
| 5784 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5785 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5786 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5787 | if (status) |
| 5788 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5789 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5790 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5791 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5792 | status = decode_putfh(xdr); |
| 5793 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5794 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5795 | status = decode_lookup(xdr); |
| 5796 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5797 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5798 | status = decode_getfh(xdr, res->fh); |
| 5799 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5800 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5801 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5802 | out: |
| 5803 | return status; |
| 5804 | } |
| 5805 | |
| 5806 | /* |
| 5807 | * Decode LOOKUP_ROOT response |
| 5808 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5809 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 5810 | struct xdr_stream *xdr, |
| 5811 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5812 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5813 | struct compound_hdr hdr; |
| 5814 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5815 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5816 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5817 | if (status) |
| 5818 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5819 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5820 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5821 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5822 | status = decode_putrootfh(xdr); |
| 5823 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5824 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5825 | status = decode_getfh(xdr, res->fh); |
| 5826 | if (status == 0) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5827 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5828 | out: |
| 5829 | return status; |
| 5830 | } |
| 5831 | |
| 5832 | /* |
| 5833 | * Decode REMOVE response |
| 5834 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5835 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5836 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5837 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5838 | struct compound_hdr hdr; |
| 5839 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5840 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5841 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5842 | if (status) |
| 5843 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5844 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5845 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5846 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5847 | status = decode_putfh(xdr); |
| 5848 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5849 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5850 | status = decode_remove(xdr, &res->cinfo); |
| 5851 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5852 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5853 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5854 | out: |
| 5855 | return status; |
| 5856 | } |
| 5857 | |
| 5858 | /* |
| 5859 | * Decode RENAME response |
| 5860 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5861 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5862 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5863 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5864 | struct compound_hdr hdr; |
| 5865 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5866 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5867 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5868 | if (status) |
| 5869 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5870 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5871 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5872 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5873 | status = decode_putfh(xdr); |
| 5874 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5875 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5876 | status = decode_savefh(xdr); |
| 5877 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5878 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5879 | status = decode_putfh(xdr); |
| 5880 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5881 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5882 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
| 5883 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5884 | goto out; |
| 5885 | /* Current FH is target directory */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5886 | if (decode_getfattr(xdr, res->new_fattr, res->server)) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5887 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5888 | status = decode_restorefh(xdr); |
| 5889 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5890 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5891 | decode_getfattr(xdr, res->old_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | out: |
| 5893 | return status; |
| 5894 | } |
| 5895 | |
| 5896 | /* |
| 5897 | * Decode LINK response |
| 5898 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5899 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5900 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5901 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5902 | struct compound_hdr hdr; |
| 5903 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5904 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5905 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5906 | if (status) |
| 5907 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5908 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5909 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5910 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5911 | status = decode_putfh(xdr); |
| 5912 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5913 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5914 | status = decode_savefh(xdr); |
| 5915 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5917 | status = decode_putfh(xdr); |
| 5918 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5919 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5920 | status = decode_link(xdr, &res->cinfo); |
| 5921 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5922 | goto out; |
| 5923 | /* |
| 5924 | * Note order: OP_LINK leaves the directory as the current |
| 5925 | * filehandle. |
| 5926 | */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5927 | if (decode_getfattr(xdr, res->dir_attr, res->server)) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5928 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5929 | status = decode_restorefh(xdr); |
| 5930 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5931 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5932 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5933 | out: |
| 5934 | return status; |
| 5935 | } |
| 5936 | |
| 5937 | /* |
| 5938 | * Decode CREATE response |
| 5939 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5940 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5941 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5942 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5943 | struct compound_hdr hdr; |
| 5944 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5945 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5946 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5947 | if (status) |
| 5948 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5949 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5950 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5951 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5952 | status = decode_putfh(xdr); |
| 5953 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5954 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5955 | status = decode_savefh(xdr); |
| 5956 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5957 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5958 | status = decode_create(xdr, &res->dir_cinfo); |
| 5959 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5960 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5961 | status = decode_getfh(xdr, res->fh); |
| 5962 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5963 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5964 | if (decode_getfattr(xdr, res->fattr, res->server)) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5965 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5966 | status = decode_restorefh(xdr); |
| 5967 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5968 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5969 | decode_getfattr(xdr, res->dir_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5970 | out: |
| 5971 | return status; |
| 5972 | } |
| 5973 | |
| 5974 | /* |
| 5975 | * Decode SYMLINK response |
| 5976 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5977 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5978 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5979 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5980 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5981 | } |
| 5982 | |
| 5983 | /* |
| 5984 | * Decode GETATTR response |
| 5985 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5986 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5987 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5988 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5989 | struct compound_hdr hdr; |
| 5990 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5991 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5992 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5993 | if (status) |
| 5994 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5995 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5996 | if (status) |
| 5997 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5998 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5999 | if (status) |
| 6000 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6001 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6002 | out: |
| 6003 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6004 | } |
| 6005 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6006 | /* |
| 6007 | * Encode an SETACL request |
| 6008 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6009 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6010 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6011 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6012 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6013 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6014 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6015 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6016 | encode_compound_hdr(xdr, req, &hdr); |
| 6017 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6018 | encode_putfh(xdr, args->fh, &hdr); |
| 6019 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6020 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6021 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6022 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6023 | /* |
| 6024 | * Decode SETACL response |
| 6025 | */ |
| 6026 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6027 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6028 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6029 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6030 | struct compound_hdr hdr; |
| 6031 | int status; |
| 6032 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6033 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6034 | if (status) |
| 6035 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6036 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6037 | if (status) |
| 6038 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6039 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6040 | if (status) |
| 6041 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6042 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6043 | out: |
| 6044 | return status; |
| 6045 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6046 | |
| 6047 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6048 | * Decode GETACL response |
| 6049 | */ |
| 6050 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6051 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6052 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6053 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6054 | struct compound_hdr hdr; |
| 6055 | int status; |
| 6056 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6057 | if (res->acl_scratch != NULL) { |
| 6058 | void *p = page_address(res->acl_scratch); |
| 6059 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6060 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6061 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6062 | if (status) |
| 6063 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6064 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6065 | if (status) |
| 6066 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6067 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6068 | if (status) |
| 6069 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6070 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6071 | |
| 6072 | out: |
| 6073 | return status; |
| 6074 | } |
| 6075 | |
| 6076 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6077 | * Decode CLOSE response |
| 6078 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6079 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6080 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6081 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6082 | struct compound_hdr hdr; |
| 6083 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6084 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6085 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6086 | if (status) |
| 6087 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6088 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6089 | if (status) |
| 6090 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6091 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6092 | if (status) |
| 6093 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6094 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6095 | if (status != 0) |
| 6096 | goto out; |
| 6097 | /* |
| 6098 | * Note: Server may do delete on close for this file |
| 6099 | * in which case the getattr call will fail with |
| 6100 | * an ESTALE error. Shouldn't be a problem, |
| 6101 | * though, since fattr->valid will remain unset. |
| 6102 | */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6103 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6104 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6105 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6106 | } |
| 6107 | |
| 6108 | /* |
| 6109 | * Decode OPEN response |
| 6110 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6111 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6112 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6113 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6114 | struct compound_hdr hdr; |
| 6115 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6116 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6117 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6118 | if (status) |
| 6119 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6120 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6121 | if (status) |
| 6122 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6123 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6124 | if (status) |
| 6125 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6126 | status = decode_savefh(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_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6130 | if (status) |
| 6131 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6132 | if (decode_getfh(xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6133 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6134 | if (decode_getfattr(xdr, res->f_attr, res->server) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6135 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6136 | if (decode_restorefh(xdr) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6137 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6138 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6139 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6140 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6141 | } |
| 6142 | |
| 6143 | /* |
| 6144 | * Decode OPEN_CONFIRM response |
| 6145 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6146 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6147 | struct xdr_stream *xdr, |
| 6148 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6149 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6150 | struct compound_hdr hdr; |
| 6151 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6152 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6153 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6154 | if (status) |
| 6155 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6156 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6157 | if (status) |
| 6158 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6159 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6160 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6161 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6162 | } |
| 6163 | |
| 6164 | /* |
| 6165 | * Decode OPEN response |
| 6166 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6167 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6168 | struct xdr_stream *xdr, |
| 6169 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6170 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6171 | struct compound_hdr hdr; |
| 6172 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6174 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6175 | if (status) |
| 6176 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6177 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6178 | if (status) |
| 6179 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6180 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6181 | if (status) |
| 6182 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6183 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6184 | if (status) |
| 6185 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6186 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6187 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6188 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6189 | } |
| 6190 | |
| 6191 | /* |
| 6192 | * Decode SETATTR response |
| 6193 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6194 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6195 | struct xdr_stream *xdr, |
| 6196 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6198 | struct compound_hdr hdr; |
| 6199 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6200 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6201 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6202 | if (status) |
| 6203 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6204 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6205 | if (status) |
| 6206 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6207 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6208 | if (status) |
| 6209 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6210 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6211 | if (status) |
| 6212 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6213 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6214 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6215 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6216 | } |
| 6217 | |
| 6218 | /* |
| 6219 | * Decode LOCK response |
| 6220 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6221 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6222 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6223 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6224 | struct compound_hdr hdr; |
| 6225 | int status; |
| 6226 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6227 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | if (status) |
| 6229 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6230 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6231 | if (status) |
| 6232 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6233 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6234 | if (status) |
| 6235 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6236 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6237 | out: |
| 6238 | return status; |
| 6239 | } |
| 6240 | |
| 6241 | /* |
| 6242 | * Decode LOCKT response |
| 6243 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6244 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6245 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6246 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6247 | struct compound_hdr hdr; |
| 6248 | int status; |
| 6249 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6250 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6251 | if (status) |
| 6252 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6253 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6254 | if (status) |
| 6255 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6256 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6257 | if (status) |
| 6258 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6259 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6260 | out: |
| 6261 | return status; |
| 6262 | } |
| 6263 | |
| 6264 | /* |
| 6265 | * Decode LOCKU response |
| 6266 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6267 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6268 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6269 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | struct compound_hdr hdr; |
| 6271 | int status; |
| 6272 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6273 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6274 | if (status) |
| 6275 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6276 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6277 | if (status) |
| 6278 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6279 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6280 | if (status) |
| 6281 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6282 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6283 | out: |
| 6284 | return status; |
| 6285 | } |
| 6286 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6287 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6288 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6289 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6290 | struct compound_hdr hdr; |
| 6291 | int status; |
| 6292 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6294 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6295 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6296 | return status; |
| 6297 | } |
| 6298 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6299 | /* |
| 6300 | * Decode READLINK response |
| 6301 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6302 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6303 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6304 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6305 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | struct compound_hdr hdr; |
| 6307 | int status; |
| 6308 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6309 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6310 | if (status) |
| 6311 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6312 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6313 | if (status) |
| 6314 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6315 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6316 | if (status) |
| 6317 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6318 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6319 | out: |
| 6320 | return status; |
| 6321 | } |
| 6322 | |
| 6323 | /* |
| 6324 | * Decode READDIR response |
| 6325 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6326 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6327 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6329 | struct compound_hdr hdr; |
| 6330 | int status; |
| 6331 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6332 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6333 | if (status) |
| 6334 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6335 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6336 | if (status) |
| 6337 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6338 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6339 | if (status) |
| 6340 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6341 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6342 | out: |
| 6343 | return status; |
| 6344 | } |
| 6345 | |
| 6346 | /* |
| 6347 | * Decode Read response |
| 6348 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6349 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6350 | struct nfs_readres *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) |
| 6357 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6358 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6359 | if (status) |
| 6360 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6361 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | if (status) |
| 6363 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6364 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6365 | if (!status) |
| 6366 | status = res->count; |
| 6367 | out: |
| 6368 | return status; |
| 6369 | } |
| 6370 | |
| 6371 | /* |
| 6372 | * Decode WRITE response |
| 6373 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6374 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6375 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6376 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6377 | struct compound_hdr hdr; |
| 6378 | int status; |
| 6379 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6380 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | if (status) |
| 6382 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6383 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6384 | if (status) |
| 6385 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6386 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | if (status) |
| 6388 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6389 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6390 | if (status) |
| 6391 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6392 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6393 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6394 | if (!status) |
| 6395 | status = res->count; |
| 6396 | out: |
| 6397 | return status; |
| 6398 | } |
| 6399 | |
| 6400 | /* |
| 6401 | * Decode COMMIT response |
| 6402 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6403 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6404 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6405 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6406 | struct compound_hdr hdr; |
| 6407 | int status; |
| 6408 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6409 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6410 | if (status) |
| 6411 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6412 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6413 | if (status) |
| 6414 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6415 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6416 | if (status) |
| 6417 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6418 | status = decode_commit(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6419 | if (status) |
| 6420 | goto out; |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 6421 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6422 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6423 | out: |
| 6424 | return status; |
| 6425 | } |
| 6426 | |
| 6427 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6428 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6429 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6430 | 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] | 6431 | struct nfs4_fsinfo_res *res) |
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_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6439 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6440 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6441 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6442 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6443 | return status; |
| 6444 | } |
| 6445 | |
| 6446 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6447 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6448 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6449 | 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] | 6450 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6451 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6452 | struct compound_hdr hdr; |
| 6453 | int status; |
| 6454 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6455 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6456 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6457 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6458 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6459 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6460 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6461 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6462 | return status; |
| 6463 | } |
| 6464 | |
| 6465 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6466 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6467 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6468 | 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] | 6469 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6470 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | struct compound_hdr hdr; |
| 6472 | int status; |
| 6473 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6474 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6476 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6477 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6478 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6480 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6481 | return status; |
| 6482 | } |
| 6483 | |
| 6484 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6485 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6487 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6488 | struct xdr_stream *xdr, |
| 6489 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6490 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | struct compound_hdr hdr; |
| 6492 | int status; |
| 6493 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6494 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6495 | if (status) |
| 6496 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6497 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6498 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6499 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6500 | status = decode_putfh(xdr); |
| 6501 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6503 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6504 | out: |
| 6505 | return status; |
| 6506 | } |
| 6507 | |
| 6508 | /* |
| 6509 | * Decode RENEW response |
| 6510 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6511 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6512 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6513 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6514 | struct compound_hdr hdr; |
| 6515 | int status; |
| 6516 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6517 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6519 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6520 | return status; |
| 6521 | } |
| 6522 | |
| 6523 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6524 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6525 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6526 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6527 | struct xdr_stream *xdr, |
| 6528 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6529 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6530 | struct compound_hdr hdr; |
| 6531 | int status; |
| 6532 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6533 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6534 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6535 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6536 | return status; |
| 6537 | } |
| 6538 | |
| 6539 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6540 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6541 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6542 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
| 6543 | struct xdr_stream *xdr, |
| 6544 | struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6546 | struct compound_hdr hdr; |
| 6547 | int status; |
| 6548 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6549 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6550 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6551 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6552 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6553 | status = decode_putrootfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6555 | status = decode_fsinfo(xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6556 | return status; |
| 6557 | } |
| 6558 | |
| 6559 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6560 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6561 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6562 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6563 | struct xdr_stream *xdr, |
| 6564 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6565 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6566 | struct compound_hdr hdr; |
| 6567 | int status; |
| 6568 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6569 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6570 | if (status) |
| 6571 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6572 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6573 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6574 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6575 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6576 | if (status != 0) |
| 6577 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6578 | status = decode_delegreturn(xdr); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6579 | if (status != 0) |
| 6580 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6581 | decode_getfattr(xdr, res->fattr, res->server); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6582 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6583 | return status; |
| 6584 | } |
| 6585 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6586 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6587 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6588 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6589 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6590 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6591 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6592 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6593 | struct compound_hdr hdr; |
| 6594 | int status; |
| 6595 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6596 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6597 | if (status) |
| 6598 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6599 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6600 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6601 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6602 | status = decode_putfh(xdr); |
| 6603 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6604 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6605 | status = decode_lookup(xdr); |
| 6606 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6607 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6608 | xdr_enter_page(xdr, PAGE_SIZE); |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6609 | status = decode_getfattr_generic(xdr, &res->fs_locations->fattr, |
| 6610 | NULL, res->fs_locations, |
| 6611 | res->fs_locations->server); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6612 | out: |
| 6613 | return status; |
| 6614 | } |
| 6615 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6616 | /* |
| 6617 | * Decode SECINFO response |
| 6618 | */ |
| 6619 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6620 | struct xdr_stream *xdr, |
| 6621 | struct nfs4_secinfo_res *res) |
| 6622 | { |
| 6623 | struct compound_hdr hdr; |
| 6624 | int status; |
| 6625 | |
| 6626 | status = decode_compound_hdr(xdr, &hdr); |
| 6627 | if (status) |
| 6628 | goto out; |
| 6629 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6630 | if (status) |
| 6631 | goto out; |
| 6632 | status = decode_putfh(xdr); |
| 6633 | if (status) |
| 6634 | goto out; |
| 6635 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6636 | out: |
| 6637 | return status; |
| 6638 | } |
| 6639 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6640 | #if defined(CONFIG_NFS_V4_1) |
| 6641 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6642 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6643 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6644 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6645 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6646 | void *res) |
| 6647 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6648 | struct compound_hdr hdr; |
| 6649 | int status; |
| 6650 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6651 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6652 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6653 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6654 | return status; |
| 6655 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6656 | |
| 6657 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6658 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6659 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6660 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6661 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6662 | struct nfs41_create_session_res *res) |
| 6663 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6664 | struct compound_hdr hdr; |
| 6665 | int status; |
| 6666 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6668 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6669 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6670 | return status; |
| 6671 | } |
| 6672 | |
| 6673 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6674 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6675 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6676 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6677 | struct xdr_stream *xdr, |
| 6678 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6679 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6680 | struct compound_hdr hdr; |
| 6681 | int status; |
| 6682 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6683 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6684 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6685 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6686 | return status; |
| 6687 | } |
| 6688 | |
| 6689 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6690 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6691 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6692 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6693 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6694 | struct nfs4_sequence_res *res) |
| 6695 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6696 | struct compound_hdr hdr; |
| 6697 | int status; |
| 6698 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6699 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6700 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6701 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6702 | return status; |
| 6703 | } |
| 6704 | |
| 6705 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6706 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6707 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6708 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6709 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6710 | struct nfs4_get_lease_time_res *res) |
| 6711 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6712 | struct compound_hdr hdr; |
| 6713 | int status; |
| 6714 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6715 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6716 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6717 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6718 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6719 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6720 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6721 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6722 | return status; |
| 6723 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6724 | |
| 6725 | /* |
| 6726 | * Decode RECLAIM_COMPLETE response |
| 6727 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6728 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 6729 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6730 | struct nfs41_reclaim_complete_res *res) |
| 6731 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6732 | struct compound_hdr hdr; |
| 6733 | int status; |
| 6734 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6735 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6736 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6737 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6738 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6739 | status = decode_reclaim_complete(xdr, (void *)NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6740 | return status; |
| 6741 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6742 | |
| 6743 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 6744 | * Decode GETDEVICELIST response |
| 6745 | */ |
| 6746 | static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst *rqstp, |
| 6747 | struct xdr_stream *xdr, |
| 6748 | struct nfs4_getdevicelist_res *res) |
| 6749 | { |
| 6750 | struct compound_hdr hdr; |
| 6751 | int status; |
| 6752 | |
| 6753 | dprintk("encoding getdevicelist!\n"); |
| 6754 | |
| 6755 | status = decode_compound_hdr(xdr, &hdr); |
| 6756 | if (status != 0) |
| 6757 | goto out; |
| 6758 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6759 | if (status != 0) |
| 6760 | goto out; |
| 6761 | status = decode_putfh(xdr); |
| 6762 | if (status != 0) |
| 6763 | goto out; |
| 6764 | status = decode_getdevicelist(xdr, res->devlist); |
| 6765 | out: |
| 6766 | return status; |
| 6767 | } |
| 6768 | |
| 6769 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6770 | * Decode GETDEVINFO response |
| 6771 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6772 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 6773 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6774 | struct nfs4_getdeviceinfo_res *res) |
| 6775 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6776 | struct compound_hdr hdr; |
| 6777 | int status; |
| 6778 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6779 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6780 | if (status != 0) |
| 6781 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6782 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6783 | if (status != 0) |
| 6784 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6785 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6786 | out: |
| 6787 | return status; |
| 6788 | } |
| 6789 | |
| 6790 | /* |
| 6791 | * Decode LAYOUTGET response |
| 6792 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6793 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 6794 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6795 | struct nfs4_layoutget_res *res) |
| 6796 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6797 | struct compound_hdr hdr; |
| 6798 | int status; |
| 6799 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6800 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6801 | if (status) |
| 6802 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6803 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6804 | if (status) |
| 6805 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6806 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6807 | if (status) |
| 6808 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6809 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6810 | out: |
| 6811 | return status; |
| 6812 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6813 | |
| 6814 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6815 | * Decode LAYOUTRETURN response |
| 6816 | */ |
| 6817 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 6818 | struct xdr_stream *xdr, |
| 6819 | struct nfs4_layoutreturn_res *res) |
| 6820 | { |
| 6821 | struct compound_hdr hdr; |
| 6822 | int status; |
| 6823 | |
| 6824 | status = decode_compound_hdr(xdr, &hdr); |
| 6825 | if (status) |
| 6826 | goto out; |
| 6827 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6828 | if (status) |
| 6829 | goto out; |
| 6830 | status = decode_putfh(xdr); |
| 6831 | if (status) |
| 6832 | goto out; |
| 6833 | status = decode_layoutreturn(xdr, res); |
| 6834 | out: |
| 6835 | return status; |
| 6836 | } |
| 6837 | |
| 6838 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6839 | * Decode LAYOUTCOMMIT response |
| 6840 | */ |
| 6841 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 6842 | struct xdr_stream *xdr, |
| 6843 | struct nfs4_layoutcommit_res *res) |
| 6844 | { |
| 6845 | struct compound_hdr hdr; |
| 6846 | int status; |
| 6847 | |
| 6848 | status = decode_compound_hdr(xdr, &hdr); |
| 6849 | if (status) |
| 6850 | goto out; |
| 6851 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6852 | if (status) |
| 6853 | goto out; |
| 6854 | status = decode_putfh(xdr); |
| 6855 | if (status) |
| 6856 | goto out; |
| 6857 | status = decode_layoutcommit(xdr, rqstp, res); |
| 6858 | if (status) |
| 6859 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6860 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6861 | out: |
| 6862 | return status; |
| 6863 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6864 | |
| 6865 | /* |
| 6866 | * Decode SECINFO_NO_NAME response |
| 6867 | */ |
| 6868 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 6869 | struct xdr_stream *xdr, |
| 6870 | struct nfs4_secinfo_res *res) |
| 6871 | { |
| 6872 | struct compound_hdr hdr; |
| 6873 | int status; |
| 6874 | |
| 6875 | status = decode_compound_hdr(xdr, &hdr); |
| 6876 | if (status) |
| 6877 | goto out; |
| 6878 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6879 | if (status) |
| 6880 | goto out; |
| 6881 | status = decode_putrootfh(xdr); |
| 6882 | if (status) |
| 6883 | goto out; |
| 6884 | status = decode_secinfo(xdr, res); |
| 6885 | out: |
| 6886 | return status; |
| 6887 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6888 | |
| 6889 | /* |
| 6890 | * Decode TEST_STATEID response |
| 6891 | */ |
| 6892 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 6893 | struct xdr_stream *xdr, |
| 6894 | struct nfs41_test_stateid_res *res) |
| 6895 | { |
| 6896 | struct compound_hdr hdr; |
| 6897 | int status; |
| 6898 | |
| 6899 | status = decode_compound_hdr(xdr, &hdr); |
| 6900 | if (status) |
| 6901 | goto out; |
| 6902 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6903 | if (status) |
| 6904 | goto out; |
| 6905 | status = decode_test_stateid(xdr, res); |
| 6906 | out: |
| 6907 | return status; |
| 6908 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6909 | |
| 6910 | /* |
| 6911 | * Decode FREE_STATEID response |
| 6912 | */ |
| 6913 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 6914 | struct xdr_stream *xdr, |
| 6915 | struct nfs41_free_stateid_res *res) |
| 6916 | { |
| 6917 | struct compound_hdr hdr; |
| 6918 | int status; |
| 6919 | |
| 6920 | status = decode_compound_hdr(xdr, &hdr); |
| 6921 | if (status) |
| 6922 | goto out; |
| 6923 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6924 | if (status) |
| 6925 | goto out; |
| 6926 | status = decode_free_stateid(xdr, res); |
| 6927 | out: |
| 6928 | return status; |
| 6929 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6930 | #endif /* CONFIG_NFS_V4_1 */ |
| 6931 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6932 | /** |
| 6933 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 6934 | * the local page cache. |
| 6935 | * @xdr: XDR stream where entry resides |
| 6936 | * @entry: buffer to fill in with entry data |
| 6937 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 6938 | * |
| 6939 | * Returns zero if successful, otherwise a negative errno value is |
| 6940 | * returned. |
| 6941 | * |
| 6942 | * This function is not invoked during READDIR reply decoding, but |
| 6943 | * rather whenever an application invokes the getdents(2) system call |
| 6944 | * on a directory already in our cache. |
| 6945 | */ |
| 6946 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 6947 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6948 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 6949 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6950 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6951 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 6952 | if (unlikely(!p)) |
| 6953 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6954 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6955 | p = xdr_inline_decode(xdr, 4); |
| 6956 | if (unlikely(!p)) |
| 6957 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6958 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6959 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6960 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6961 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6962 | } |
| 6963 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6964 | p = xdr_inline_decode(xdr, 12); |
| 6965 | if (unlikely(!p)) |
| 6966 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6967 | entry->prev_cookie = entry->cookie; |
| 6968 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6969 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6970 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6971 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6972 | if (unlikely(!p)) |
| 6973 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6974 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6975 | |
| 6976 | /* |
| 6977 | * In case the server doesn't return an inode number, |
| 6978 | * we fake one here. (We don't use inode number 0, |
| 6979 | * since glibc seems to choke on it...) |
| 6980 | */ |
| 6981 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 6982 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6983 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6984 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6985 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6986 | |
| 6987 | if (decode_attr_length(xdr, &len, &p) < 0) |
| 6988 | goto out_overflow; |
| 6989 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6990 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6991 | NULL, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6992 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 6993 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 6994 | entry->ino = entry->fattr->mounted_on_fileid; |
| 6995 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6996 | entry->ino = entry->fattr->fileid; |
| 6997 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 6998 | entry->d_type = DT_UNKNOWN; |
| 6999 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7000 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7001 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7002 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7003 | |
| 7004 | out_overflow: |
| 7005 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7006 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7007 | } |
| 7008 | |
| 7009 | /* |
| 7010 | * We need to translate between nfs status return values and |
| 7011 | * the local errno values which may not be the same. |
| 7012 | */ |
| 7013 | static struct { |
| 7014 | int stat; |
| 7015 | int errno; |
| 7016 | } nfs_errtbl[] = { |
| 7017 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7018 | { NFS4ERR_PERM, -EPERM }, |
| 7019 | { NFS4ERR_NOENT, -ENOENT }, |
| 7020 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7021 | { NFS4ERR_NXIO, -ENXIO }, |
| 7022 | { NFS4ERR_ACCESS, -EACCES }, |
| 7023 | { NFS4ERR_EXIST, -EEXIST }, |
| 7024 | { NFS4ERR_XDEV, -EXDEV }, |
| 7025 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7026 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7027 | { NFS4ERR_INVAL, -EINVAL }, |
| 7028 | { NFS4ERR_FBIG, -EFBIG }, |
| 7029 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7030 | { NFS4ERR_ROFS, -EROFS }, |
| 7031 | { NFS4ERR_MLINK, -EMLINK }, |
| 7032 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7033 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7034 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7035 | { NFS4ERR_STALE, -ESTALE }, |
| 7036 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7037 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7038 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7039 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7040 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7041 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7042 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7043 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7044 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7045 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7046 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7047 | }; |
| 7048 | |
| 7049 | /* |
| 7050 | * Convert an NFS error code to a local one. |
| 7051 | * This one is used jointly by NFSv2 and NFSv3. |
| 7052 | */ |
| 7053 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7054 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7055 | { |
| 7056 | int i; |
| 7057 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7058 | if (nfs_errtbl[i].stat == stat) |
| 7059 | return nfs_errtbl[i].errno; |
| 7060 | } |
| 7061 | if (stat <= 10000 || stat > 10100) { |
| 7062 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7063 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7064 | } |
| 7065 | /* If we cannot translate the error, the recovery routines should |
| 7066 | * handle it. |
| 7067 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7068 | * not conflict with native Linux error codes. |
| 7069 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7070 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7071 | } |
| 7072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7073 | #define PROC(proc, argtype, restype) \ |
| 7074 | [NFSPROC4_CLNT_##proc] = { \ |
| 7075 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7076 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7077 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7078 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7079 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7080 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7081 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7082 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7083 | |
| 7084 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7085 | PROC(READ, enc_read, dec_read), |
| 7086 | PROC(WRITE, enc_write, dec_write), |
| 7087 | PROC(COMMIT, enc_commit, dec_commit), |
| 7088 | PROC(OPEN, enc_open, dec_open), |
| 7089 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7090 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7091 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7092 | PROC(CLOSE, enc_close, dec_close), |
| 7093 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7094 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7095 | PROC(RENEW, enc_renew, dec_renew), |
| 7096 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7097 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7098 | PROC(LOCK, enc_lock, dec_lock), |
| 7099 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7100 | PROC(LOCKU, enc_locku, dec_locku), |
| 7101 | PROC(ACCESS, enc_access, dec_access), |
| 7102 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7103 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7104 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7105 | PROC(REMOVE, enc_remove, dec_remove), |
| 7106 | PROC(RENAME, enc_rename, dec_rename), |
| 7107 | PROC(LINK, enc_link, dec_link), |
| 7108 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7109 | PROC(CREATE, enc_create, dec_create), |
| 7110 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7111 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7112 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7113 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7114 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7115 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7116 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7117 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7118 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7119 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7120 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7121 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7122 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7123 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7124 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7125 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7126 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7127 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7128 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7129 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7130 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7131 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7132 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7133 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7134 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 7135 | PROC(GETDEVICELIST, enc_getdevicelist, dec_getdevicelist), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7136 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7137 | }; |
| 7138 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7139 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7140 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7141 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7142 | .procs = nfs4_procedures |
| 7143 | }; |
| 7144 | |
| 7145 | /* |
| 7146 | * Local variables: |
| 7147 | * c-basic-offset: 8 |
| 7148 | * End: |
| 7149 | */ |