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> |
| 47 | #include <linux/sunrpc/clnt.h> |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 48 | #include <linux/sunrpc/msg_prot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/nfs.h> |
| 50 | #include <linux/nfs4.h> |
| 51 | #include <linux/nfs_fs.h> |
| 52 | #include <linux/nfs_idmap.h> |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 53 | #include "nfs4_fs.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 54 | #include "internal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 57 | |
| 58 | /* Mapping from NFS error code to "errno" error code. */ |
| 59 | #define errno_NFSERR_IO EIO |
| 60 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 61 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 64 | #ifdef DEBUG |
| 65 | #define NFS4_MAXTAGLEN 20 |
| 66 | #else |
| 67 | #define NFS4_MAXTAGLEN 0 |
| 68 | #endif |
| 69 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 70 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 71 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | */ |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 73 | #define open_owner_id_maxsz (1 + 4) |
| 74 | #define lock_owner_id_maxsz (1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 75 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 77 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 78 | #define op_encode_hdr_maxsz (1) |
| 79 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 80 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 81 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 82 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 83 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 85 | (NFS4_FHSIZE >> 2)) |
| 86 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 87 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 88 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 89 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 90 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 91 | ((3+NFS4_FHSIZE) >> 2)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 92 | #define nfs4_fattr_bitmap_maxsz 3 |
| 93 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 95 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 96 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 97 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 98 | /* This is based on getfattr, which uses the most attributes: */ |
| 99 | #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] | 100 | 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 101 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 102 | nfs4_fattr_value_maxsz) |
| 103 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 104 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 105 | 1 + 2 + 1 + \ |
| 106 | nfs4_owner_maxsz + \ |
| 107 | nfs4_group_maxsz + \ |
| 108 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 110 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 111 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 112 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 113 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) |
| 115 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 116 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 117 | #define encode_setclientid_maxsz \ |
| 118 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 119 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 120 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 121 | 1 /* sc_prog */ + \ |
| 122 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 123 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
| 124 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | #define decode_setclientid_maxsz \ |
| 126 | (op_decode_hdr_maxsz + \ |
| 127 | 2 + \ |
| 128 | 1024) /* large value for CLID_INUSE */ |
| 129 | #define encode_setclientid_confirm_maxsz \ |
| 130 | (op_encode_hdr_maxsz + \ |
| 131 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 132 | #define decode_setclientid_confirm_maxsz \ |
| 133 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 134 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 135 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 136 | #define encode_share_access_maxsz \ |
| 137 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 138 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 139 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 140 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 141 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 142 | 2 + encode_share_access_maxsz + 2 + \ |
| 143 | open_owner_id_maxsz + \ |
| 144 | encode_opentype_maxsz + \ |
| 145 | encode_claim_null_maxsz) |
| 146 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 147 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 148 | decode_ace_maxsz) |
| 149 | #define decode_change_info_maxsz (5) |
| 150 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 151 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 152 | decode_change_info_maxsz + 1 + \ |
| 153 | nfs4_fattr_bitmap_maxsz + \ |
| 154 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 155 | #define encode_open_confirm_maxsz \ |
| 156 | (op_encode_hdr_maxsz + \ |
| 157 | encode_stateid_maxsz + 1) |
| 158 | #define decode_open_confirm_maxsz \ |
| 159 | (op_decode_hdr_maxsz + \ |
| 160 | decode_stateid_maxsz) |
| 161 | #define encode_open_downgrade_maxsz \ |
| 162 | (op_encode_hdr_maxsz + \ |
| 163 | encode_stateid_maxsz + 1 + \ |
| 164 | encode_share_access_maxsz) |
| 165 | #define decode_open_downgrade_maxsz \ |
| 166 | (op_decode_hdr_maxsz + \ |
| 167 | decode_stateid_maxsz) |
| 168 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 169 | 1 + encode_stateid_maxsz) |
| 170 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 171 | decode_stateid_maxsz) |
| 172 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 173 | encode_stateid_maxsz + \ |
| 174 | encode_attrs_maxsz) |
| 175 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 176 | nfs4_fattr_bitmap_maxsz) |
| 177 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 178 | encode_stateid_maxsz + 3) |
| 179 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 180 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
| 181 | 2 + encode_verifier_maxsz + 5) |
| 182 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
| 183 | decode_verifier_maxsz) |
| 184 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 185 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 186 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 187 | encode_stateid_maxsz + 4) |
| 188 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 189 | 2 + decode_verifier_maxsz) |
| 190 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 191 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 192 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 194 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 195 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 196 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 198 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 199 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 200 | decode_change_info_maxsz + \ |
| 201 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 203 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 204 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 205 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 206 | 7 + \ |
| 207 | 1 + encode_stateid_maxsz + 8) |
| 208 | #define decode_lock_denied_maxsz \ |
| 209 | (8 + decode_lockowner_maxsz) |
| 210 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 211 | decode_lock_denied_maxsz) |
| 212 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 12) |
| 213 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 214 | decode_lock_denied_maxsz) |
| 215 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 216 | encode_stateid_maxsz + \ |
| 217 | 4) |
| 218 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 219 | decode_stateid_maxsz) |
| 220 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 221 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 223 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 224 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 225 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 227 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 228 | 1 + 2 + nfs4_name_maxsz + \ |
| 229 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 230 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 231 | decode_change_info_maxsz + \ |
| 232 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 233 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 234 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 236 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 237 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 238 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 239 | nfs4_fattr_bitmap_maxsz + 1) |
| 240 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 241 | encode_stateid_maxsz + 3) |
| 242 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 243 | #define encode_fs_locations_maxsz \ |
| 244 | (encode_getattr_maxsz) |
| 245 | #define decode_fs_locations_maxsz \ |
| 246 | (0) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 247 | |
| 248 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 249 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
| 250 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 251 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 252 | encode_verifier_maxsz + \ |
| 253 | 1 /* co_ownerid.len */ + \ |
| 254 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 255 | 1 /* flags */ + \ |
| 256 | 1 /* spa_how */ + \ |
| 257 | 0 /* SP4_NONE (for now) */ + \ |
| 258 | 1 /* zero implemetation id array */) |
| 259 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 260 | 2 /* eir_clientid */ + \ |
| 261 | 1 /* eir_sequenceid */ + \ |
| 262 | 1 /* eir_flags */ + \ |
| 263 | 1 /* spr_how */ + \ |
| 264 | 0 /* SP4_NONE (for now) */ + \ |
| 265 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 266 | /* eir_server_owner.so_major_id<> */ \ |
| 267 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 268 | /* eir_server_scope<> */ \ |
| 269 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 270 | 1 /* eir_server_impl_id array length */ + \ |
| 271 | 0 /* ignored eir_server_impl_id contents */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 272 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 273 | #define decode_channel_attrs_maxsz (6 + \ |
| 274 | 1 /* ca_rdma_ird.len */ + \ |
| 275 | 1 /* ca_rdma_ird */) |
| 276 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 277 | 2 /* csa_clientid */ + \ |
| 278 | 1 /* csa_sequence */ + \ |
| 279 | 1 /* csa_flags */ + \ |
| 280 | encode_channel_attrs_maxsz + \ |
| 281 | encode_channel_attrs_maxsz + \ |
| 282 | 1 /* csa_cb_program */ + \ |
| 283 | 1 /* csa_sec_parms.len (1) */ + \ |
| 284 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 285 | 1 /* stamp */ + \ |
| 286 | 1 /* machinename.len */ + \ |
| 287 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 288 | 1 /* uid */ + \ |
| 289 | 1 /* gid */ + \ |
| 290 | 1 /* gids.len (0) */) |
| 291 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 292 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 293 | 1 /* csr_sequence */ + \ |
| 294 | 1 /* csr_flags */ + \ |
| 295 | decode_channel_attrs_maxsz + \ |
| 296 | decode_channel_attrs_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 297 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 298 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 299 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 300 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 301 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 302 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 303 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 304 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 305 | #else /* CONFIG_NFS_V4_1 */ |
| 306 | #define encode_sequence_maxsz 0 |
| 307 | #define decode_sequence_maxsz 0 |
| 308 | #endif /* CONFIG_NFS_V4_1 */ |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 311 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 312 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 313 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 315 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 317 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 319 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 321 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 323 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 325 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 327 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 329 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 331 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 333 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 335 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 337 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 339 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 340 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 342 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 344 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 345 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 347 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 349 | encode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 350 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 352 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 354 | decode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 355 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 357 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 358 | encode_putfh_maxsz + \ |
| 359 | encode_savefh_maxsz + \ |
| 360 | encode_open_maxsz + \ |
| 361 | encode_getfh_maxsz + \ |
| 362 | encode_getattr_maxsz + \ |
| 363 | encode_restorefh_maxsz + \ |
| 364 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 366 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 367 | decode_putfh_maxsz + \ |
| 368 | decode_savefh_maxsz + \ |
| 369 | decode_open_maxsz + \ |
| 370 | decode_getfh_maxsz + \ |
| 371 | decode_getattr_maxsz + \ |
| 372 | decode_restorefh_maxsz + \ |
| 373 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 374 | #define NFS4_enc_open_confirm_sz \ |
| 375 | (compound_encode_hdr_maxsz + \ |
| 376 | encode_putfh_maxsz + \ |
| 377 | encode_open_confirm_maxsz) |
| 378 | #define NFS4_dec_open_confirm_sz \ |
| 379 | (compound_decode_hdr_maxsz + \ |
| 380 | decode_putfh_maxsz + \ |
| 381 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 383 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 385 | encode_open_maxsz + \ |
| 386 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 388 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 390 | decode_open_maxsz + \ |
| 391 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | #define NFS4_enc_open_downgrade_sz \ |
| 393 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 394 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 395 | encode_putfh_maxsz + \ |
| 396 | encode_open_downgrade_maxsz + \ |
| 397 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | #define NFS4_dec_open_downgrade_sz \ |
| 399 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 400 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 401 | decode_putfh_maxsz + \ |
| 402 | decode_open_downgrade_maxsz + \ |
| 403 | decode_getattr_maxsz) |
| 404 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 405 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 406 | encode_putfh_maxsz + \ |
| 407 | encode_close_maxsz + \ |
| 408 | encode_getattr_maxsz) |
| 409 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 410 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 411 | decode_putfh_maxsz + \ |
| 412 | decode_close_maxsz + \ |
| 413 | decode_getattr_maxsz) |
| 414 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 415 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 416 | encode_putfh_maxsz + \ |
| 417 | encode_setattr_maxsz + \ |
| 418 | encode_getattr_maxsz) |
| 419 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 420 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 421 | decode_putfh_maxsz + \ |
| 422 | decode_setattr_maxsz + \ |
| 423 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 425 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | encode_putfh_maxsz + \ |
| 427 | encode_fsinfo_maxsz) |
| 428 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 429 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | decode_putfh_maxsz + \ |
| 431 | decode_fsinfo_maxsz) |
| 432 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 433 | encode_renew_maxsz) |
| 434 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 435 | decode_renew_maxsz) |
| 436 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 437 | encode_setclientid_maxsz) |
| 438 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 439 | decode_setclientid_maxsz) |
| 440 | #define NFS4_enc_setclientid_confirm_sz \ |
| 441 | (compound_encode_hdr_maxsz + \ |
| 442 | encode_setclientid_confirm_maxsz + \ |
| 443 | encode_putrootfh_maxsz + \ |
| 444 | encode_fsinfo_maxsz) |
| 445 | #define NFS4_dec_setclientid_confirm_sz \ |
| 446 | (compound_decode_hdr_maxsz + \ |
| 447 | decode_setclientid_confirm_maxsz + \ |
| 448 | decode_putrootfh_maxsz + \ |
| 449 | decode_fsinfo_maxsz) |
| 450 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 451 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 453 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 455 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 457 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 459 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 461 | encode_lockt_maxsz) |
| 462 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 464 | decode_putfh_maxsz + \ |
| 465 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 467 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 469 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 471 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 473 | decode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 475 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 477 | encode_access_maxsz + \ |
| 478 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 480 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 482 | decode_access_maxsz + \ |
| 483 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 485 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | encode_putfh_maxsz + \ |
| 487 | encode_getattr_maxsz) |
| 488 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 489 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | decode_putfh_maxsz + \ |
| 491 | decode_getattr_maxsz) |
| 492 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 493 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | encode_putfh_maxsz + \ |
| 495 | encode_lookup_maxsz + \ |
| 496 | encode_getattr_maxsz + \ |
| 497 | encode_getfh_maxsz) |
| 498 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 499 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 501 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | decode_getattr_maxsz + \ |
| 503 | decode_getfh_maxsz) |
| 504 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 505 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | encode_putrootfh_maxsz + \ |
| 507 | encode_getattr_maxsz + \ |
| 508 | encode_getfh_maxsz) |
| 509 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 510 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | decode_putrootfh_maxsz + \ |
| 512 | decode_getattr_maxsz + \ |
| 513 | decode_getfh_maxsz) |
| 514 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 515 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | encode_putfh_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 517 | encode_remove_maxsz + \ |
| 518 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 520 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | decode_putfh_maxsz + \ |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 522 | decode_remove_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 523 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 525 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | encode_putfh_maxsz + \ |
| 527 | encode_savefh_maxsz + \ |
| 528 | encode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 529 | encode_rename_maxsz + \ |
| 530 | encode_getattr_maxsz + \ |
| 531 | encode_restorefh_maxsz + \ |
| 532 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 534 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | decode_putfh_maxsz + \ |
| 536 | decode_savefh_maxsz + \ |
| 537 | decode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 538 | decode_rename_maxsz + \ |
| 539 | decode_getattr_maxsz + \ |
| 540 | decode_restorefh_maxsz + \ |
| 541 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 543 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | encode_putfh_maxsz + \ |
| 545 | encode_savefh_maxsz + \ |
| 546 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 547 | encode_link_maxsz + \ |
| 548 | decode_getattr_maxsz + \ |
| 549 | encode_restorefh_maxsz + \ |
| 550 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 552 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | decode_putfh_maxsz + \ |
| 554 | decode_savefh_maxsz + \ |
| 555 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 556 | decode_link_maxsz + \ |
| 557 | decode_getattr_maxsz + \ |
| 558 | decode_restorefh_maxsz + \ |
| 559 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 561 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | encode_putfh_maxsz + \ |
| 563 | encode_symlink_maxsz + \ |
| 564 | encode_getattr_maxsz + \ |
| 565 | encode_getfh_maxsz) |
| 566 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 567 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | decode_putfh_maxsz + \ |
| 569 | decode_symlink_maxsz + \ |
| 570 | decode_getattr_maxsz + \ |
| 571 | decode_getfh_maxsz) |
| 572 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 573 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | encode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 575 | encode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 577 | encode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | encode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 579 | encode_restorefh_maxsz + \ |
| 580 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 582 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | decode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 584 | decode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 586 | decode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | decode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 588 | decode_restorefh_maxsz + \ |
| 589 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 591 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | encode_putfh_maxsz + \ |
| 593 | encode_getattr_maxsz) |
| 594 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 595 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | decode_putfh_maxsz + \ |
| 597 | decode_getattr_maxsz) |
| 598 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 599 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 601 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 603 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 605 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 607 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 608 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | encode_getattr_maxsz) |
| 610 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 611 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 612 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | decode_getattr_maxsz) |
| 614 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 615 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 617 | encode_delegreturn_maxsz + \ |
| 618 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 620 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 621 | decode_delegreturn_maxsz + \ |
| 622 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 623 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 624 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 625 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 626 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 627 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 628 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 629 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 630 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 631 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 632 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 633 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 634 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 635 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 636 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 637 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 638 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 639 | #define NFS4_enc_fs_locations_sz \ |
| 640 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 641 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 642 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 643 | encode_lookup_maxsz + \ |
| 644 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 645 | #define NFS4_dec_fs_locations_sz \ |
| 646 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 647 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 648 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 649 | decode_lookup_maxsz + \ |
| 650 | decode_fs_locations_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 651 | #if defined(CONFIG_NFS_V4_1) |
| 652 | #define NFS4_enc_exchange_id_sz \ |
| 653 | (compound_encode_hdr_maxsz + \ |
| 654 | encode_exchange_id_maxsz) |
| 655 | #define NFS4_dec_exchange_id_sz \ |
| 656 | (compound_decode_hdr_maxsz + \ |
| 657 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 658 | #define NFS4_enc_create_session_sz \ |
| 659 | (compound_encode_hdr_maxsz + \ |
| 660 | encode_create_session_maxsz) |
| 661 | #define NFS4_dec_create_session_sz \ |
| 662 | (compound_decode_hdr_maxsz + \ |
| 663 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 664 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 665 | encode_destroy_session_maxsz) |
| 666 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 667 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 668 | #define NFS4_enc_sequence_sz \ |
| 669 | (compound_decode_hdr_maxsz + \ |
| 670 | encode_sequence_maxsz) |
| 671 | #define NFS4_dec_sequence_sz \ |
| 672 | (compound_decode_hdr_maxsz + \ |
| 673 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 674 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 675 | encode_sequence_maxsz + \ |
| 676 | encode_putrootfh_maxsz + \ |
| 677 | encode_fsinfo_maxsz) |
| 678 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 679 | decode_sequence_maxsz + \ |
| 680 | decode_putrootfh_maxsz + \ |
| 681 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 682 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 683 | encode_sequence_maxsz + \ |
| 684 | encode_reclaim_complete_maxsz) |
| 685 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 686 | decode_sequence_maxsz + \ |
| 687 | decode_reclaim_complete_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 688 | |
| 689 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 690 | compound_encode_hdr_maxsz + |
| 691 | encode_sequence_maxsz + |
| 692 | encode_putfh_maxsz + |
| 693 | encode_getattr_maxsz) * |
| 694 | XDR_UNIT); |
| 695 | |
| 696 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 697 | compound_decode_hdr_maxsz + |
| 698 | decode_sequence_maxsz + |
| 699 | decode_putfh_maxsz) * |
| 700 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 701 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 703 | static const umode_t nfs_type2fmt[] = { |
| 704 | [NF4BAD] = 0, |
| 705 | [NF4REG] = S_IFREG, |
| 706 | [NF4DIR] = S_IFDIR, |
| 707 | [NF4BLK] = S_IFBLK, |
| 708 | [NF4CHR] = S_IFCHR, |
| 709 | [NF4LNK] = S_IFLNK, |
| 710 | [NF4SOCK] = S_IFSOCK, |
| 711 | [NF4FIFO] = S_IFIFO, |
| 712 | [NF4ATTRDIR] = 0, |
| 713 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | }; |
| 715 | |
| 716 | struct compound_hdr { |
| 717 | int32_t status; |
| 718 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 719 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | uint32_t taglen; |
| 721 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 722 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 723 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | }; |
| 725 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 726 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 727 | { |
| 728 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 729 | BUG_ON(!p); |
| 730 | return p; |
| 731 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | |
| 733 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 734 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 735 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
| 737 | p = xdr_reserve_space(xdr, 4 + len); |
| 738 | BUG_ON(p == NULL); |
| 739 | xdr_encode_opaque(p, str, len); |
| 740 | } |
| 741 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 742 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 743 | struct rpc_rqst *req, |
| 744 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 746 | __be32 *p; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 747 | struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth; |
| 748 | |
| 749 | /* initialize running count of expected bytes in reply. |
| 750 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 751 | * but this is not required as a MUST for the server to do so. */ |
| 752 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | |
| 754 | dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); |
| 755 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 756 | p = reserve_space(xdr, 4 + hdr->taglen + 8); |
| 757 | p = xdr_encode_opaque(p, hdr->tag, hdr->taglen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 758 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 759 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 760 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | static void encode_nops(struct compound_hdr *hdr) |
| 764 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 765 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 766 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 770 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 771 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | |
| 773 | p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); |
| 774 | BUG_ON(p == NULL); |
| 775 | xdr_encode_opaque_fixed(p, verf->data, NFS4_VERIFIER_SIZE); |
| 776 | } |
| 777 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 778 | 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] | 779 | { |
| 780 | char owner_name[IDMAP_NAMESZ]; |
| 781 | char owner_group[IDMAP_NAMESZ]; |
| 782 | int owner_namelen = 0; |
| 783 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 784 | __be32 *p; |
| 785 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | int len; |
| 787 | uint32_t bmval0 = 0; |
| 788 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | |
| 790 | /* |
| 791 | * We reserve enough space to write the entire attribute buffer at once. |
| 792 | * In the worst-case, this would be |
| 793 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 794 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 795 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | */ |
| 797 | len = 16; |
| 798 | |
| 799 | /* Sigh */ |
| 800 | if (iap->ia_valid & ATTR_SIZE) |
| 801 | len += 8; |
| 802 | if (iap->ia_valid & ATTR_MODE) |
| 803 | len += 4; |
| 804 | if (iap->ia_valid & ATTR_UID) { |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 805 | owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 807 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 808 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | /* XXX */ |
| 810 | strcpy(owner_name, "nobody"); |
| 811 | owner_namelen = sizeof("nobody") - 1; |
| 812 | /* goto out; */ |
| 813 | } |
| 814 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 815 | } |
| 816 | if (iap->ia_valid & ATTR_GID) { |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 817 | owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 819 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 820 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | strcpy(owner_group, "nobody"); |
| 822 | owner_grouplen = sizeof("nobody") - 1; |
| 823 | /* goto out; */ |
| 824 | } |
| 825 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 826 | } |
| 827 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 828 | len += 16; |
| 829 | else if (iap->ia_valid & ATTR_ATIME) |
| 830 | len += 4; |
| 831 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 832 | len += 16; |
| 833 | else if (iap->ia_valid & ATTR_MTIME) |
| 834 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 835 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | |
| 837 | /* |
| 838 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 839 | * buffer length to be backfilled at the end of this routine. |
| 840 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 841 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | q = p; |
| 843 | p += 3; |
| 844 | |
| 845 | if (iap->ia_valid & ATTR_SIZE) { |
| 846 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 847 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | } |
| 849 | if (iap->ia_valid & ATTR_MODE) { |
| 850 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 851 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | } |
| 853 | if (iap->ia_valid & ATTR_UID) { |
| 854 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 855 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | } |
| 857 | if (iap->ia_valid & ATTR_GID) { |
| 858 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 859 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | } |
| 861 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 862 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 863 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 864 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 865 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 866 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | } |
| 868 | else if (iap->ia_valid & ATTR_ATIME) { |
| 869 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 870 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | } |
| 872 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 873 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 874 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 875 | *p++ = cpu_to_be32(0); |
| 876 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 877 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | } |
| 879 | else if (iap->ia_valid & ATTR_MTIME) { |
| 880 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 881 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 883 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | /* |
| 885 | * Now we backfill the bitmap and the attribute buffer length. |
| 886 | */ |
| 887 | if (len != ((char *)p - (char *)q) + 4) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 888 | printk(KERN_ERR "nfs: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | len, ((char *)p - (char *)q) + 4); |
| 890 | BUG(); |
| 891 | } |
| 892 | len = (char *)p - (char *)q - 12; |
| 893 | *q++ = htonl(bmval0); |
| 894 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 895 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | } |
| 899 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 900 | 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] | 901 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 902 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 904 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 905 | *p++ = cpu_to_be32(OP_ACCESS); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 906 | *p = cpu_to_be32(access); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 907 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 908 | hdr->replen += decode_access_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | } |
| 910 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 911 | 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] | 912 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 913 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 915 | p = reserve_space(xdr, 8+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 916 | *p++ = cpu_to_be32(OP_CLOSE); |
| 917 | *p++ = cpu_to_be32(arg->seqid->sequence->counter); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 918 | xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 919 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 920 | hdr->replen += decode_close_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 923 | 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] | 924 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 925 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 926 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 927 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 928 | *p++ = cpu_to_be32(OP_COMMIT); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 929 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 930 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 931 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 932 | hdr->replen += decode_commit_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 935 | 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] | 936 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 937 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 938 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 939 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 940 | *p++ = cpu_to_be32(OP_CREATE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 941 | *p = cpu_to_be32(create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | |
| 943 | switch (create->ftype) { |
| 944 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 945 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 946 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 947 | 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] | 948 | break; |
| 949 | |
| 950 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 951 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 952 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 953 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | break; |
| 955 | |
| 956 | default: |
| 957 | break; |
| 958 | } |
| 959 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 960 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 961 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 962 | hdr->replen += decode_create_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 964 | encode_attrs(xdr, create->attrs, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | } |
| 966 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 967 | 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] | 968 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 969 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 971 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 972 | *p++ = cpu_to_be32(OP_GETATTR); |
| 973 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 974 | *p = cpu_to_be32(bitmap); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 975 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 976 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | } |
| 978 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 979 | 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] | 980 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 981 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 983 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 984 | *p++ = cpu_to_be32(OP_GETATTR); |
| 985 | *p++ = cpu_to_be32(2); |
| 986 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 987 | *p = cpu_to_be32(bm1); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 988 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 989 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | } |
| 991 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 992 | 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] | 993 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 994 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 995 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | } |
| 997 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 998 | 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] | 999 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1000 | encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1001 | bitmask[1] & nfs4_fsinfo_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | } |
| 1003 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1004 | 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] | 1005 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1006 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1007 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1008 | } |
| 1009 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1010 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1012 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1014 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1015 | *p = cpu_to_be32(OP_GETFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1016 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1017 | hdr->replen += decode_getfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1020 | 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] | 1021 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1022 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1024 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1025 | *p++ = cpu_to_be32(OP_LINK); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1026 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1027 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1028 | hdr->replen += decode_link_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1031 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1032 | { |
| 1033 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1034 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1035 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1036 | } |
| 1037 | |
| 1038 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1039 | { |
| 1040 | if (fl->fl_end == OFFSET_MAX) |
| 1041 | return ~(uint64_t)0; |
| 1042 | return fl->fl_end - fl->fl_start + 1; |
| 1043 | } |
| 1044 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | /* |
| 1046 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1047 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1048 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1049 | 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] | 1050 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1051 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1053 | p = reserve_space(xdr, 32); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1054 | *p++ = cpu_to_be32(OP_LOCK); |
| 1055 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1056 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1057 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1058 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1059 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1060 | if (args->new_lock_owner){ |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1061 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+32); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1062 | *p++ = cpu_to_be32(args->open_seqid->sequence->counter); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1063 | p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1064 | *p++ = cpu_to_be32(args->lock_seqid->sequence->counter); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1065 | p = xdr_encode_hyper(p, args->lock_owner.clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1066 | *p++ = cpu_to_be32(16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1067 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1068 | xdr_encode_hyper(p, args->lock_owner.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } |
| 1070 | else { |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1071 | p = reserve_space(xdr, NFS4_STATEID_SIZE+4); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1072 | p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1073 | *p = cpu_to_be32(args->lock_seqid->sequence->counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1075 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1076 | hdr->replen += decode_lock_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | } |
| 1078 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1079 | 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] | 1080 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1081 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1083 | p = reserve_space(xdr, 52); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1084 | *p++ = cpu_to_be32(OP_LOCKT); |
| 1085 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1086 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1087 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
| 1088 | p = xdr_encode_hyper(p, args->lock_owner.clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1089 | *p++ = cpu_to_be32(16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1090 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1091 | xdr_encode_hyper(p, args->lock_owner.id); |
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_lockt_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_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] | 1097 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1098 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1100 | p = reserve_space(xdr, 12+NFS4_STATEID_SIZE+16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1101 | *p++ = cpu_to_be32(OP_LOCKU); |
| 1102 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
| 1103 | *p++ = cpu_to_be32(args->seqid->sequence->counter); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1104 | p = xdr_encode_opaque_fixed(p, args->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1105 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1106 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1107 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1108 | hdr->replen += decode_locku_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | } |
| 1110 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1111 | 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] | 1112 | { |
| 1113 | int len = name->len; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1114 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1116 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1117 | *p++ = cpu_to_be32(OP_LOOKUP); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1118 | xdr_encode_opaque(p, name->name, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1119 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1120 | hdr->replen += decode_lookup_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1123 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1125 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1127 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1128 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1129 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1130 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1131 | break; |
| 1132 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1133 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1134 | break; |
| 1135 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1136 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1137 | break; |
| 1138 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1139 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1141 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1145 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1146 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | /* |
| 1148 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1149 | * owner 4 = 32 |
| 1150 | */ |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1151 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1152 | *p++ = cpu_to_be32(OP_OPEN); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1153 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1154 | encode_share_access(xdr, arg->fmode); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1155 | p = reserve_space(xdr, 28); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1156 | p = xdr_encode_hyper(p, arg->clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1157 | *p++ = cpu_to_be32(16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1158 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1159 | xdr_encode_hyper(p, arg->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1163 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1164 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1165 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1167 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1169 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1170 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1171 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1172 | break; |
| 1173 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1174 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1175 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1176 | if (nfs4_has_persistent_session(clp)) { |
| 1177 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1178 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1179 | } else { |
| 1180 | struct iattr dummy; |
| 1181 | |
| 1182 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1183 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1184 | dummy.ia_valid = 0; |
| 1185 | encode_attrs(xdr, &dummy, arg->server); |
| 1186 | } |
| 1187 | } else { |
| 1188 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1189 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1195 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1196 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1198 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1200 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1201 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1202 | break; |
| 1203 | default: |
| 1204 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1205 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1206 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | } |
| 1208 | } |
| 1209 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1210 | 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] | 1211 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1212 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1214 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1216 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1217 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1218 | break; |
| 1219 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1220 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1221 | break; |
| 1222 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1223 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1224 | break; |
| 1225 | default: |
| 1226 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | } |
| 1228 | } |
| 1229 | |
| 1230 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1231 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1232 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1234 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1235 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | encode_string(xdr, name->len, name->name); |
| 1237 | } |
| 1238 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1239 | 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] | 1240 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1241 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1243 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1244 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | encode_delegation_type(xdr, type); |
| 1246 | } |
| 1247 | |
| 1248 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1249 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1250 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1252 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1253 | *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1254 | xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | encode_string(xdr, name->len, name->name); |
| 1256 | } |
| 1257 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1258 | 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] | 1259 | { |
| 1260 | encode_openhdr(xdr, arg); |
| 1261 | encode_opentype(xdr, arg); |
| 1262 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1263 | case NFS4_OPEN_CLAIM_NULL: |
| 1264 | encode_claim_null(xdr, arg->name); |
| 1265 | break; |
| 1266 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1267 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1268 | break; |
| 1269 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1270 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1271 | break; |
| 1272 | default: |
| 1273 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1275 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1276 | hdr->replen += decode_open_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1279 | 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] | 1280 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1281 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1283 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1284 | *p++ = cpu_to_be32(OP_OPEN_CONFIRM); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1285 | p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1286 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1287 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1288 | hdr->replen += decode_open_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1291 | 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] | 1292 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1293 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1295 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1296 | *p++ = cpu_to_be32(OP_OPEN_DOWNGRADE); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1297 | p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1298 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1299 | encode_share_access(xdr, arg->fmode); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1300 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1301 | hdr->replen += decode_open_downgrade_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1304 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1305 | 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] | 1306 | { |
| 1307 | int len = fh->size; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1308 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1310 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1311 | *p++ = cpu_to_be32(OP_PUTFH); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1312 | xdr_encode_opaque(p, fh->data, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1313 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1314 | hdr->replen += decode_putfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | } |
| 1316 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1317 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1319 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1320 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1321 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1322 | *p = cpu_to_be32(OP_PUTROOTFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1323 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1324 | hdr->replen += decode_putrootfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | } |
| 1326 | |
Trond Myklebust | f11ac8d | 2010-06-25 16:35:53 -0400 | [diff] [blame^] | 1327 | static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | nfs4_stateid stateid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1330 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1332 | p = reserve_space(xdr, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | if (ctx->state != NULL) { |
Trond Myklebust | f11ac8d | 2010-06-25 16:35:53 -0400 | [diff] [blame^] | 1334 | nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1335 | xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | } else |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1337 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1340 | 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] | 1341 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1342 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1344 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1345 | *p = cpu_to_be32(OP_READ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | |
Trond Myklebust | f11ac8d | 2010-06-25 16:35:53 -0400 | [diff] [blame^] | 1347 | encode_stateid(xdr, args->context, args->lock_context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1349 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1350 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1351 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1352 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1353 | hdr->replen += decode_read_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1356 | 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] | 1357 | { |
Manoj Naik | 97d312d | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1358 | uint32_t attrs[2] = { |
| 1359 | FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID, |
| 1360 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1361 | }; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1362 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1364 | p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1365 | *p++ = cpu_to_be32(OP_READDIR); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1366 | p = xdr_encode_hyper(p, readdir->cookie); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1367 | p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1368 | *p++ = cpu_to_be32(readdir->count >> 1); /* We're not doing readdirplus */ |
| 1369 | *p++ = cpu_to_be32(readdir->count); |
| 1370 | *p++ = cpu_to_be32(2); |
Manoj Naik | 97d312d | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1371 | /* Switch to mounted_on_fileid if the server supports it */ |
| 1372 | if (readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID) |
| 1373 | attrs[0] &= ~FATTR4_WORD0_FILEID; |
| 1374 | else |
| 1375 | attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1376 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1377 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1378 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1379 | hdr->replen += decode_readdir_maxsz; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1380 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1381 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1382 | (unsigned long long)readdir->cookie, |
| 1383 | ((u32 *)readdir->verifier.data)[0], |
| 1384 | ((u32 *)readdir->verifier.data)[1], |
| 1385 | attrs[0] & readdir->bitmask[0], |
| 1386 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | } |
| 1388 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1389 | 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] | 1390 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1391 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1393 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1394 | *p = cpu_to_be32(OP_READLINK); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1395 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1396 | hdr->replen += decode_readlink_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1399 | 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] | 1400 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1401 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1403 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1404 | *p++ = cpu_to_be32(OP_REMOVE); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1405 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1406 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1407 | hdr->replen += decode_remove_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | } |
| 1409 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1410 | 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] | 1411 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1412 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1414 | p = reserve_space(xdr, 4); |
| 1415 | *p = cpu_to_be32(OP_RENAME); |
| 1416 | encode_string(xdr, oldname->len, oldname->name); |
| 1417 | encode_string(xdr, newname->len, newname->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1418 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1419 | hdr->replen += decode_rename_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1422 | static void encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1424 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1426 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1427 | *p++ = cpu_to_be32(OP_RENEW); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1428 | xdr_encode_hyper(p, client_stateid->cl_clientid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1429 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1430 | hdr->replen += decode_renew_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1433 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1434 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1435 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1436 | __be32 *p; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1437 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1438 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1439 | *p = cpu_to_be32(OP_RESTOREFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1440 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1441 | hdr->replen += decode_restorefh_maxsz; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1442 | } |
| 1443 | |
| 1444 | static int |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1445 | 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] | 1446 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1447 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1448 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1449 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1450 | *p++ = cpu_to_be32(OP_SETATTR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1451 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1452 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1453 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1454 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1455 | if (arg->acl_len % 4) |
| 1456 | return -EINVAL; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1457 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1458 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1459 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1460 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1461 | hdr->replen += decode_setacl_maxsz; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1462 | return 0; |
| 1463 | } |
| 1464 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1465 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1466 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1468 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1470 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1471 | *p = cpu_to_be32(OP_SAVEFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1472 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1473 | hdr->replen += decode_savefh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | } |
| 1475 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1476 | 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] | 1477 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1478 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1479 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1480 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1481 | *p++ = cpu_to_be32(OP_SETATTR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1482 | xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1483 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1484 | hdr->replen += decode_setattr_maxsz; |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1485 | encode_attrs(xdr, arg->iap, server); |
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_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] | 1489 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1490 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1492 | p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1493 | *p++ = cpu_to_be32(OP_SETCLIENTID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1494 | xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | |
| 1496 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1497 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1498 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1500 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1501 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1502 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1503 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1504 | hdr->replen += decode_setclientid_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | } |
| 1506 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1507 | 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] | 1508 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1509 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1511 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1512 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1513 | p = xdr_encode_hyper(p, arg->clientid); |
| 1514 | xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1515 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1516 | hdr->replen += decode_setclientid_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | } |
| 1518 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1519 | 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] | 1520 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1521 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1523 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1524 | *p = cpu_to_be32(OP_WRITE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | |
Trond Myklebust | f11ac8d | 2010-06-25 16:35:53 -0400 | [diff] [blame^] | 1526 | encode_stateid(xdr, args->context, args->lock_context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1528 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1529 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1530 | *p++ = cpu_to_be32(args->stable); |
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 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1534 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1535 | hdr->replen += decode_write_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | } |
| 1537 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1538 | 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] | 1539 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1540 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1542 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1544 | *p++ = cpu_to_be32(OP_DELEGRETURN); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1545 | xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1546 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1547 | hdr->replen += decode_delegreturn_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1549 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1550 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1551 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1552 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1553 | struct nfs41_exchange_id_args *args, |
| 1554 | struct compound_hdr *hdr) |
| 1555 | { |
| 1556 | __be32 *p; |
| 1557 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1558 | p = reserve_space(xdr, 4 + sizeof(args->verifier->data)); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1559 | *p++ = cpu_to_be32(OP_EXCHANGE_ID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1560 | xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data)); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1561 | |
| 1562 | encode_string(xdr, args->id_len, args->id); |
| 1563 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1564 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1565 | *p++ = cpu_to_be32(args->flags); |
| 1566 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1567 | *p = cpu_to_be32(0); /* zero length implementation id array */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1568 | hdr->nops++; |
| 1569 | hdr->replen += decode_exchange_id_maxsz; |
| 1570 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1571 | |
| 1572 | static void encode_create_session(struct xdr_stream *xdr, |
| 1573 | struct nfs41_create_session_args *args, |
| 1574 | struct compound_hdr *hdr) |
| 1575 | { |
| 1576 | __be32 *p; |
| 1577 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1578 | uint32_t len; |
| 1579 | struct nfs_client *clp = args->client; |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1580 | u32 max_resp_sz_cached; |
| 1581 | |
| 1582 | /* |
| 1583 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1584 | * 2 is the verifier. |
| 1585 | */ |
| 1586 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1587 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1588 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1589 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1590 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1591 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1592 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1593 | *p++ = cpu_to_be32(OP_CREATE_SESSION); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1594 | p = xdr_encode_hyper(p, clp->cl_ex_clid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1595 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1596 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1597 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1598 | /* Fore Channel */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1599 | *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ |
| 1600 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1601 | *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] | 1602 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1603 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1604 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1605 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1606 | |
| 1607 | /* Back Channel */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1608 | *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ |
| 1609 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1610 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1611 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1612 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1613 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1614 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1615 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1616 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1617 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1618 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1619 | |
| 1620 | /* authsys_parms rfc1831 */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1621 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1622 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1623 | *p++ = cpu_to_be32(0); /* UID */ |
| 1624 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1625 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1626 | hdr->nops++; |
| 1627 | hdr->replen += decode_create_session_maxsz; |
| 1628 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1629 | |
| 1630 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1631 | struct nfs4_session *session, |
| 1632 | struct compound_hdr *hdr) |
| 1633 | { |
| 1634 | __be32 *p; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1635 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1636 | *p++ = cpu_to_be32(OP_DESTROY_SESSION); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1637 | 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] | 1638 | hdr->nops++; |
| 1639 | hdr->replen += decode_destroy_session_maxsz; |
| 1640 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1641 | |
| 1642 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1643 | struct nfs41_reclaim_complete_args *args, |
| 1644 | struct compound_hdr *hdr) |
| 1645 | { |
| 1646 | __be32 *p; |
| 1647 | |
| 1648 | p = reserve_space(xdr, 8); |
| 1649 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); |
| 1650 | *p++ = cpu_to_be32(args->one_fs); |
| 1651 | hdr->nops++; |
| 1652 | hdr->replen += decode_reclaim_complete_maxsz; |
| 1653 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1654 | #endif /* CONFIG_NFS_V4_1 */ |
| 1655 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1656 | static void encode_sequence(struct xdr_stream *xdr, |
| 1657 | const struct nfs4_sequence_args *args, |
| 1658 | struct compound_hdr *hdr) |
| 1659 | { |
| 1660 | #if defined(CONFIG_NFS_V4_1) |
| 1661 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1662 | struct nfs4_slot_table *tp; |
| 1663 | struct nfs4_slot *slot; |
| 1664 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1665 | |
| 1666 | if (!session) |
| 1667 | return; |
| 1668 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1669 | tp = &session->fc_slot_table; |
| 1670 | |
| 1671 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1672 | slot = tp->slots + args->sa_slotid; |
| 1673 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1674 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1675 | *p++ = cpu_to_be32(OP_SEQUENCE); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1676 | |
| 1677 | /* |
| 1678 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1679 | */ |
| 1680 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1681 | "max_slotid=%d cache_this=%d\n", |
| 1682 | __func__, |
| 1683 | ((u32 *)session->sess_id.data)[0], |
| 1684 | ((u32 *)session->sess_id.data)[1], |
| 1685 | ((u32 *)session->sess_id.data)[2], |
| 1686 | ((u32 *)session->sess_id.data)[3], |
| 1687 | slot->seq_nr, args->sa_slotid, |
| 1688 | tp->highest_used_slotid, args->sa_cache_this); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1689 | 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] | 1690 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1691 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1692 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1693 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1694 | hdr->nops++; |
| 1695 | hdr->replen += decode_sequence_maxsz; |
| 1696 | #endif /* CONFIG_NFS_V4_1 */ |
| 1697 | } |
| 1698 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | /* |
| 1700 | * END OF "GENERIC" ENCODE ROUTINES. |
| 1701 | */ |
| 1702 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1703 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 1704 | { |
| 1705 | #if defined(CONFIG_NFS_V4_1) |
| 1706 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1707 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1708 | #endif /* CONFIG_NFS_V4_1 */ |
| 1709 | return 0; |
| 1710 | } |
| 1711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | /* |
| 1713 | * Encode an ACCESS request |
| 1714 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1715 | static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | { |
| 1717 | struct xdr_stream xdr; |
| 1718 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1719 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | |
| 1722 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1723 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1724 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1725 | encode_putfh(&xdr, args->fh, &hdr); |
| 1726 | encode_access(&xdr, args->access, &hdr); |
| 1727 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1728 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1729 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | /* |
| 1733 | * Encode LOOKUP request |
| 1734 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1735 | static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | { |
| 1737 | struct xdr_stream xdr; |
| 1738 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1739 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | |
| 1742 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1743 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1744 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1745 | encode_putfh(&xdr, args->dir_fh, &hdr); |
| 1746 | encode_lookup(&xdr, args->name, &hdr); |
| 1747 | encode_getfh(&xdr, &hdr); |
| 1748 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1749 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1750 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | /* |
| 1754 | * Encode LOOKUP_ROOT request |
| 1755 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1756 | static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | { |
| 1758 | struct xdr_stream xdr; |
| 1759 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1760 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1762 | |
| 1763 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1764 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1765 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1766 | encode_putrootfh(&xdr, &hdr); |
| 1767 | encode_getfh(&xdr, &hdr); |
| 1768 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1769 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1770 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | } |
| 1772 | |
| 1773 | /* |
| 1774 | * Encode REMOVE request |
| 1775 | */ |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 1776 | static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1777 | { |
| 1778 | struct xdr_stream xdr; |
| 1779 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1780 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | |
| 1783 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1784 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1785 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1786 | encode_putfh(&xdr, args->fh, &hdr); |
| 1787 | encode_remove(&xdr, &args->name, &hdr); |
| 1788 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1789 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1790 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | } |
| 1792 | |
| 1793 | /* |
| 1794 | * Encode RENAME request |
| 1795 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1796 | static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs4_rename_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1797 | { |
| 1798 | struct xdr_stream xdr; |
| 1799 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1800 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | |
| 1803 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1804 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1805 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1806 | encode_putfh(&xdr, args->old_dir, &hdr); |
| 1807 | encode_savefh(&xdr, &hdr); |
| 1808 | encode_putfh(&xdr, args->new_dir, &hdr); |
| 1809 | encode_rename(&xdr, args->old_name, args->new_name, &hdr); |
| 1810 | encode_getfattr(&xdr, args->bitmask, &hdr); |
| 1811 | encode_restorefh(&xdr, &hdr); |
| 1812 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1813 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1814 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | } |
| 1816 | |
| 1817 | /* |
| 1818 | * Encode LINK request |
| 1819 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1820 | static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | { |
| 1822 | struct xdr_stream xdr; |
| 1823 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1824 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
| 1827 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1828 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1829 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1830 | encode_putfh(&xdr, args->fh, &hdr); |
| 1831 | encode_savefh(&xdr, &hdr); |
| 1832 | encode_putfh(&xdr, args->dir_fh, &hdr); |
| 1833 | encode_link(&xdr, args->name, &hdr); |
| 1834 | encode_getfattr(&xdr, args->bitmask, &hdr); |
| 1835 | encode_restorefh(&xdr, &hdr); |
| 1836 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1837 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1838 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1839 | } |
| 1840 | |
| 1841 | /* |
| 1842 | * Encode CREATE request |
| 1843 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1844 | static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | { |
| 1846 | struct xdr_stream xdr; |
| 1847 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1848 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1849 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1850 | |
| 1851 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1852 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1853 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1854 | encode_putfh(&xdr, args->dir_fh, &hdr); |
| 1855 | encode_savefh(&xdr, &hdr); |
| 1856 | encode_create(&xdr, args, &hdr); |
| 1857 | encode_getfh(&xdr, &hdr); |
| 1858 | encode_getfattr(&xdr, args->bitmask, &hdr); |
| 1859 | encode_restorefh(&xdr, &hdr); |
| 1860 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1861 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1862 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1863 | } |
| 1864 | |
| 1865 | /* |
| 1866 | * Encode SYMLINK request |
| 1867 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1868 | static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | { |
| 1870 | return nfs4_xdr_enc_create(req, p, args); |
| 1871 | } |
| 1872 | |
| 1873 | /* |
| 1874 | * Encode GETATTR request |
| 1875 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1876 | static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | { |
| 1878 | struct xdr_stream xdr; |
| 1879 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1880 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1882 | |
| 1883 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1884 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1885 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1886 | encode_putfh(&xdr, args->fh, &hdr); |
| 1887 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1888 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1889 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1890 | } |
| 1891 | |
| 1892 | /* |
| 1893 | * Encode a CLOSE request |
| 1894 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1895 | static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1897 | struct xdr_stream xdr; |
| 1898 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1899 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1900 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1901 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1902 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1903 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1904 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1905 | encode_putfh(&xdr, args->fh, &hdr); |
| 1906 | encode_close(&xdr, args, &hdr); |
| 1907 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1908 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1909 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1910 | } |
| 1911 | |
| 1912 | /* |
| 1913 | * Encode an OPEN request |
| 1914 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1915 | static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | { |
| 1917 | struct xdr_stream xdr; |
| 1918 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1919 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | |
| 1922 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1923 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1924 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1925 | encode_putfh(&xdr, args->fh, &hdr); |
| 1926 | encode_savefh(&xdr, &hdr); |
| 1927 | encode_open(&xdr, args, &hdr); |
| 1928 | encode_getfh(&xdr, &hdr); |
| 1929 | encode_getfattr(&xdr, args->bitmask, &hdr); |
| 1930 | encode_restorefh(&xdr, &hdr); |
| 1931 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1932 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1933 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | /* |
| 1937 | * Encode an OPEN_CONFIRM request |
| 1938 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1939 | static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1940 | { |
| 1941 | struct xdr_stream xdr; |
| 1942 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1943 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1944 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1945 | |
| 1946 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1947 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1948 | encode_putfh(&xdr, args->fh, &hdr); |
| 1949 | encode_open_confirm(&xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1950 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1951 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1952 | } |
| 1953 | |
| 1954 | /* |
| 1955 | * Encode an OPEN request with no attributes. |
| 1956 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1957 | static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1958 | { |
| 1959 | struct xdr_stream xdr; |
| 1960 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1961 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1962 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | |
| 1964 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1965 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1966 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1967 | encode_putfh(&xdr, args->fh, &hdr); |
| 1968 | encode_open(&xdr, args, &hdr); |
| 1969 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1970 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1971 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | /* |
| 1975 | * Encode an OPEN_DOWNGRADE request |
| 1976 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1977 | static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1978 | { |
| 1979 | struct xdr_stream xdr; |
| 1980 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1981 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1983 | |
| 1984 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1985 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1986 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1987 | encode_putfh(&xdr, args->fh, &hdr); |
| 1988 | encode_open_downgrade(&xdr, args, &hdr); |
| 1989 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1990 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1991 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | } |
| 1993 | |
| 1994 | /* |
| 1995 | * Encode a LOCK request |
| 1996 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1997 | static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | { |
| 1999 | struct xdr_stream xdr; |
| 2000 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2001 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | |
| 2004 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2005 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2006 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2007 | encode_putfh(&xdr, args->fh, &hdr); |
| 2008 | encode_lock(&xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2009 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2010 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | /* |
| 2014 | * Encode a LOCKT request |
| 2015 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2016 | static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | { |
| 2018 | struct xdr_stream xdr; |
| 2019 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2020 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | |
| 2023 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2024 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2025 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2026 | encode_putfh(&xdr, args->fh, &hdr); |
| 2027 | encode_lockt(&xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2028 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2029 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | } |
| 2031 | |
| 2032 | /* |
| 2033 | * Encode a LOCKU request |
| 2034 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2035 | static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | { |
| 2037 | struct xdr_stream xdr; |
| 2038 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2039 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | |
| 2042 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2043 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2044 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2045 | encode_putfh(&xdr, args->fh, &hdr); |
| 2046 | encode_locku(&xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2047 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2048 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | } |
| 2050 | |
| 2051 | /* |
| 2052 | * Encode a READLINK request |
| 2053 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2054 | static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | { |
| 2056 | struct xdr_stream xdr; |
| 2057 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2058 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | |
| 2061 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2062 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2063 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2064 | encode_putfh(&xdr, args->fh, &hdr); |
| 2065 | encode_readlink(&xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2066 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2067 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2068 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2069 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2070 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | } |
| 2072 | |
| 2073 | /* |
| 2074 | * Encode a READDIR request |
| 2075 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2076 | static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | { |
| 2078 | struct xdr_stream xdr; |
| 2079 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2080 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | |
| 2083 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2084 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2085 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2086 | encode_putfh(&xdr, args->fh, &hdr); |
| 2087 | encode_readdir(&xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2088 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2089 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2090 | args->pgbase, args->count); |
| 2091 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2092 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2093 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2094 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2095 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | } |
| 2097 | |
| 2098 | /* |
| 2099 | * Encode a READ request |
| 2100 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2101 | static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2102 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | struct xdr_stream xdr; |
| 2104 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2105 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | |
| 2108 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2109 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2110 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2111 | encode_putfh(&xdr, args->fh, &hdr); |
| 2112 | encode_read(&xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2114 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2116 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2117 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2118 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | } |
| 2120 | |
| 2121 | /* |
| 2122 | * Encode an SETATTR request |
| 2123 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2124 | static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2126 | struct xdr_stream xdr; |
| 2127 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2128 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2129 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2131 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2132 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2133 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2134 | encode_putfh(&xdr, args->fh, &hdr); |
| 2135 | encode_setattr(&xdr, args, args->server, &hdr); |
| 2136 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2137 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2138 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2142 | * Encode a GETACL request |
| 2143 | */ |
| 2144 | static int |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2145 | nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2146 | struct nfs_getaclargs *args) |
| 2147 | { |
| 2148 | struct xdr_stream xdr; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2149 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2150 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2151 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2152 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2153 | |
| 2154 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2155 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2156 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2157 | encode_putfh(&xdr, args->fh, &hdr); |
J. Bruce Fields | d327cf7 | 2009-12-03 08:10:17 -0500 | [diff] [blame] | 2158 | replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2159 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); |
| 2160 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2161 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2162 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2163 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2164 | return 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2165 | } |
| 2166 | |
| 2167 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2168 | * Encode a WRITE request |
| 2169 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2170 | static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | { |
| 2172 | struct xdr_stream xdr; |
| 2173 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2174 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | |
| 2177 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2178 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2179 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2180 | encode_putfh(&xdr, args->fh, &hdr); |
| 2181 | encode_write(&xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2182 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2183 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2184 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2185 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | /* |
| 2189 | * a COMMIT request |
| 2190 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2191 | static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | { |
| 2193 | struct xdr_stream xdr; |
| 2194 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2195 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | |
| 2198 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2199 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2200 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2201 | encode_putfh(&xdr, args->fh, &hdr); |
| 2202 | encode_commit(&xdr, args, &hdr); |
| 2203 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2204 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2205 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | /* |
| 2209 | * FSINFO request |
| 2210 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2211 | static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | { |
| 2213 | struct xdr_stream xdr; |
| 2214 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2215 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | |
| 2218 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2219 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2220 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2221 | encode_putfh(&xdr, args->fh, &hdr); |
| 2222 | encode_fsinfo(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2223 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2224 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | } |
| 2226 | |
| 2227 | /* |
| 2228 | * a PATHCONF request |
| 2229 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2230 | static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | struct xdr_stream xdr; |
| 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), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | |
| 2237 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2238 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2239 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2240 | encode_putfh(&xdr, args->fh, &hdr); |
| 2241 | encode_getattr_one(&xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
| 2242 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2243 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2244 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | } |
| 2246 | |
| 2247 | /* |
| 2248 | * a STATFS request |
| 2249 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2250 | static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | struct xdr_stream xdr; |
| 2253 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2254 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | |
| 2257 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2258 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2259 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2260 | encode_putfh(&xdr, args->fh, &hdr); |
| 2261 | encode_getattr_two(&xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
| 2262 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2263 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2264 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | /* |
| 2268 | * GETATTR_BITMAP request |
| 2269 | */ |
Benny Halevy | 43652ad | 2009-04-01 09:21:54 -0400 | [diff] [blame] | 2270 | static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p, |
| 2271 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | { |
| 2273 | struct xdr_stream xdr; |
| 2274 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2275 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
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 | |
| 2278 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2279 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2280 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Benny Halevy | 43652ad | 2009-04-01 09:21:54 -0400 | [diff] [blame] | 2281 | encode_putfh(&xdr, args->fhandle, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2282 | encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
| 2283 | FATTR4_WORD0_LINK_SUPPORT| |
| 2284 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2285 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2286 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2287 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | } |
| 2289 | |
| 2290 | /* |
| 2291 | * a RENEW request |
| 2292 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2293 | static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | { |
| 2295 | struct xdr_stream xdr; |
| 2296 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2297 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | }; |
| 2299 | |
| 2300 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2301 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2302 | encode_renew(&xdr, clp, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2303 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2304 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2305 | } |
| 2306 | |
| 2307 | /* |
| 2308 | * a SETCLIENTID request |
| 2309 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2310 | static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | { |
| 2312 | struct xdr_stream xdr; |
| 2313 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2314 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | }; |
| 2316 | |
| 2317 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2318 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2319 | encode_setclientid(&xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2320 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2321 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | } |
| 2323 | |
| 2324 | /* |
| 2325 | * a SETCLIENTID_CONFIRM request |
| 2326 | */ |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 2327 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | { |
| 2329 | struct xdr_stream xdr; |
| 2330 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2331 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | }; |
| 2333 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | |
| 2335 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2336 | encode_compound_hdr(&xdr, req, &hdr); |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 2337 | encode_setclientid_confirm(&xdr, arg, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2338 | encode_putrootfh(&xdr, &hdr); |
| 2339 | encode_fsinfo(&xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2340 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2341 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | } |
| 2343 | |
| 2344 | /* |
| 2345 | * DELEGRETURN request |
| 2346 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2347 | static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | { |
| 2349 | struct xdr_stream xdr; |
| 2350 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2351 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | |
| 2354 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2355 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2356 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2357 | encode_putfh(&xdr, args->fhandle, &hdr); |
| 2358 | encode_delegreturn(&xdr, args->stateid, &hdr); |
| 2359 | encode_getfattr(&xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2360 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2361 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2365 | * Encode FS_LOCATIONS request |
| 2366 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2367 | static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2368 | { |
| 2369 | struct xdr_stream xdr; |
| 2370 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2371 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2372 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2373 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2374 | |
| 2375 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 2376 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 2377 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2378 | encode_putfh(&xdr, args->dir_fh, &hdr); |
| 2379 | encode_lookup(&xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2380 | replen = hdr.replen; /* get the attribute into args->page */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2381 | encode_fs_locations(&xdr, args->bitmask, &hdr); |
| 2382 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2383 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2384 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2385 | encode_nops(&hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2386 | return 0; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2387 | } |
| 2388 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2389 | #if defined(CONFIG_NFS_V4_1) |
| 2390 | /* |
| 2391 | * EXCHANGE_ID request |
| 2392 | */ |
| 2393 | static int nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, uint32_t *p, |
| 2394 | struct nfs41_exchange_id_args *args) |
| 2395 | { |
| 2396 | struct xdr_stream xdr; |
| 2397 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2398 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2399 | }; |
| 2400 | |
| 2401 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2402 | encode_compound_hdr(&xdr, req, &hdr); |
| 2403 | encode_exchange_id(&xdr, args, &hdr); |
| 2404 | encode_nops(&hdr); |
| 2405 | return 0; |
| 2406 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2407 | |
| 2408 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2409 | * a CREATE_SESSION request |
| 2410 | */ |
| 2411 | static int nfs4_xdr_enc_create_session(struct rpc_rqst *req, uint32_t *p, |
| 2412 | struct nfs41_create_session_args *args) |
| 2413 | { |
| 2414 | struct xdr_stream xdr; |
| 2415 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2416 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2417 | }; |
| 2418 | |
| 2419 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2420 | encode_compound_hdr(&xdr, req, &hdr); |
| 2421 | encode_create_session(&xdr, args, &hdr); |
| 2422 | encode_nops(&hdr); |
| 2423 | return 0; |
| 2424 | } |
| 2425 | |
| 2426 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2427 | * a DESTROY_SESSION request |
| 2428 | */ |
| 2429 | static int nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, uint32_t *p, |
| 2430 | struct nfs4_session *session) |
| 2431 | { |
| 2432 | struct xdr_stream xdr; |
| 2433 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2434 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2435 | }; |
| 2436 | |
| 2437 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2438 | encode_compound_hdr(&xdr, req, &hdr); |
| 2439 | encode_destroy_session(&xdr, session, &hdr); |
| 2440 | encode_nops(&hdr); |
| 2441 | return 0; |
| 2442 | } |
| 2443 | |
| 2444 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2445 | * a SEQUENCE request |
| 2446 | */ |
| 2447 | static int nfs4_xdr_enc_sequence(struct rpc_rqst *req, uint32_t *p, |
| 2448 | struct nfs4_sequence_args *args) |
| 2449 | { |
| 2450 | struct xdr_stream xdr; |
| 2451 | struct compound_hdr hdr = { |
| 2452 | .minorversion = nfs4_xdr_minorversion(args), |
| 2453 | }; |
| 2454 | |
| 2455 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2456 | encode_compound_hdr(&xdr, req, &hdr); |
| 2457 | encode_sequence(&xdr, args, &hdr); |
| 2458 | encode_nops(&hdr); |
| 2459 | return 0; |
| 2460 | } |
| 2461 | |
| 2462 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2463 | * a GET_LEASE_TIME request |
| 2464 | */ |
| 2465 | static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, |
| 2466 | struct nfs4_get_lease_time_args *args) |
| 2467 | { |
| 2468 | struct xdr_stream xdr; |
| 2469 | struct compound_hdr hdr = { |
| 2470 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2471 | }; |
| 2472 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; |
| 2473 | |
| 2474 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2475 | encode_compound_hdr(&xdr, req, &hdr); |
| 2476 | encode_sequence(&xdr, &args->la_seq_args, &hdr); |
| 2477 | encode_putrootfh(&xdr, &hdr); |
| 2478 | encode_fsinfo(&xdr, lease_bitmap, &hdr); |
| 2479 | encode_nops(&hdr); |
| 2480 | return 0; |
| 2481 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2482 | |
| 2483 | /* |
| 2484 | * a RECLAIM_COMPLETE request |
| 2485 | */ |
| 2486 | static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p, |
| 2487 | struct nfs41_reclaim_complete_args *args) |
| 2488 | { |
| 2489 | struct xdr_stream xdr; |
| 2490 | struct compound_hdr hdr = { |
| 2491 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2492 | }; |
| 2493 | |
| 2494 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 2495 | encode_compound_hdr(&xdr, req, &hdr); |
| 2496 | encode_sequence(&xdr, &args->seq_args, &hdr); |
| 2497 | encode_reclaim_complete(&xdr, args, &hdr); |
| 2498 | encode_nops(&hdr); |
| 2499 | return 0; |
| 2500 | } |
| 2501 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2502 | #endif /* CONFIG_NFS_V4_1 */ |
| 2503 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 2504 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 2505 | { |
| 2506 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 2507 | "Remaining buffer length is %tu words.\n", |
| 2508 | func, xdr->end - xdr->p); |
| 2509 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2511 | 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] | 2512 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2513 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2515 | p = xdr_inline_decode(xdr, 4); |
| 2516 | if (unlikely(!p)) |
| 2517 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2518 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2519 | p = xdr_inline_decode(xdr, *len); |
| 2520 | if (unlikely(!p)) |
| 2521 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | *string = (char *)p; |
| 2523 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2524 | out_overflow: |
| 2525 | print_overflow_msg(__func__, xdr); |
| 2526 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2527 | } |
| 2528 | |
| 2529 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 2530 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2531 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2532 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2533 | p = xdr_inline_decode(xdr, 8); |
| 2534 | if (unlikely(!p)) |
| 2535 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2536 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2537 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2538 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2539 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 2540 | if (unlikely(!p)) |
| 2541 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2542 | hdr->tag = (char *)p; |
| 2543 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2544 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 2545 | if (unlikely(hdr->nops < 1)) |
| 2546 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2548 | out_overflow: |
| 2549 | print_overflow_msg(__func__, xdr); |
| 2550 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 2554 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2555 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2556 | uint32_t opnum; |
| 2557 | int32_t nfserr; |
| 2558 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2559 | p = xdr_inline_decode(xdr, 8); |
| 2560 | if (unlikely(!p)) |
| 2561 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2562 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 2564 | dprintk("nfs: Server returned operation" |
| 2565 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | opnum, expected); |
| 2567 | return -EIO; |
| 2568 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2569 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 2571 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2572 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2573 | out_overflow: |
| 2574 | print_overflow_msg(__func__, xdr); |
| 2575 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | } |
| 2577 | |
| 2578 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 2579 | 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] | 2580 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2581 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2582 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | char *str; |
| 2584 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2585 | p = xdr_inline_decode(xdr, 12); |
| 2586 | if (likely(p)) |
| 2587 | return decode_opaque_inline(xdr, &strlen, &str); |
| 2588 | print_overflow_msg(__func__, xdr); |
| 2589 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | } |
| 2591 | |
| 2592 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 2593 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2594 | uint32_t bmlen; |
| 2595 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2597 | p = xdr_inline_decode(xdr, 4); |
| 2598 | if (unlikely(!p)) |
| 2599 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2600 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | |
| 2602 | bitmap[0] = bitmap[1] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2603 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 2604 | if (unlikely(!p)) |
| 2605 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2607 | bitmap[0] = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | if (bmlen > 1) |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2609 | bitmap[1] = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | } |
| 2611 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2612 | out_overflow: |
| 2613 | print_overflow_msg(__func__, xdr); |
| 2614 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | } |
| 2616 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2617 | 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] | 2618 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2619 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2621 | p = xdr_inline_decode(xdr, 4); |
| 2622 | if (unlikely(!p)) |
| 2623 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2624 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2625 | *savep = xdr->p; |
| 2626 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2627 | out_overflow: |
| 2628 | print_overflow_msg(__func__, xdr); |
| 2629 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2630 | } |
| 2631 | |
| 2632 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 2633 | { |
| 2634 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
| 2635 | decode_attr_bitmap(xdr, bitmask); |
| 2636 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 2637 | } else |
| 2638 | bitmask[0] = bitmask[1] = 0; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 2639 | dprintk("%s: bitmask=%08x:%08x\n", __func__, bitmask[0], bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | return 0; |
| 2641 | } |
| 2642 | |
| 2643 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 2644 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2645 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2646 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | |
| 2648 | *type = 0; |
| 2649 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 2650 | return -EIO; |
| 2651 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2652 | p = xdr_inline_decode(xdr, 4); |
| 2653 | if (unlikely(!p)) |
| 2654 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2655 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2656 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2657 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | return -EIO; |
| 2659 | } |
| 2660 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2661 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 2663 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2664 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2665 | out_overflow: |
| 2666 | print_overflow_msg(__func__, xdr); |
| 2667 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2668 | } |
| 2669 | |
| 2670 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 2671 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2672 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2673 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | |
| 2675 | *change = 0; |
| 2676 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 2677 | return -EIO; |
| 2678 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2679 | p = xdr_inline_decode(xdr, 8); |
| 2680 | if (unlikely(!p)) |
| 2681 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2682 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2684 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2685 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2686 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2687 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2688 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2689 | out_overflow: |
| 2690 | print_overflow_msg(__func__, xdr); |
| 2691 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2692 | } |
| 2693 | |
| 2694 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 2695 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2696 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2697 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2698 | |
| 2699 | *size = 0; |
| 2700 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 2701 | return -EIO; |
| 2702 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2703 | p = xdr_inline_decode(xdr, 8); |
| 2704 | if (unlikely(!p)) |
| 2705 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2706 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2707 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2708 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2709 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2710 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2711 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2712 | out_overflow: |
| 2713 | print_overflow_msg(__func__, xdr); |
| 2714 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2715 | } |
| 2716 | |
| 2717 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 2718 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2719 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2720 | |
| 2721 | *res = 0; |
| 2722 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 2723 | return -EIO; |
| 2724 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2725 | p = xdr_inline_decode(xdr, 4); |
| 2726 | if (unlikely(!p)) |
| 2727 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2728 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2729 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 2730 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2731 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2732 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2733 | out_overflow: |
| 2734 | print_overflow_msg(__func__, xdr); |
| 2735 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | } |
| 2737 | |
| 2738 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 2739 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2740 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2741 | |
| 2742 | *res = 0; |
| 2743 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 2744 | return -EIO; |
| 2745 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2746 | p = xdr_inline_decode(xdr, 4); |
| 2747 | if (unlikely(!p)) |
| 2748 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2749 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2750 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 2751 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2752 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2754 | out_overflow: |
| 2755 | print_overflow_msg(__func__, xdr); |
| 2756 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | } |
| 2758 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 2759 | 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] | 2760 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2761 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2762 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | |
| 2764 | fsid->major = 0; |
| 2765 | fsid->minor = 0; |
| 2766 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 2767 | return -EIO; |
| 2768 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2769 | p = xdr_inline_decode(xdr, 16); |
| 2770 | if (unlikely(!p)) |
| 2771 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 2772 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2773 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2774 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2775 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2776 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2777 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2778 | (unsigned long long)fsid->major, |
| 2779 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2780 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2781 | out_overflow: |
| 2782 | print_overflow_msg(__func__, xdr); |
| 2783 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 2787 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2788 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | |
| 2790 | *res = 60; |
| 2791 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 2792 | return -EIO; |
| 2793 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2794 | p = xdr_inline_decode(xdr, 4); |
| 2795 | if (unlikely(!p)) |
| 2796 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2797 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 2799 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2800 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2801 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2802 | out_overflow: |
| 2803 | print_overflow_msg(__func__, xdr); |
| 2804 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2805 | } |
| 2806 | |
| 2807 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 2808 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2809 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2810 | |
| 2811 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 2812 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 2813 | return -EIO; |
| 2814 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2815 | p = xdr_inline_decode(xdr, 4); |
| 2816 | if (unlikely(!p)) |
| 2817 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2818 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2819 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 2820 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2821 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2823 | out_overflow: |
| 2824 | print_overflow_msg(__func__, xdr); |
| 2825 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2826 | } |
| 2827 | |
| 2828 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 2829 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2830 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2831 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | |
| 2833 | *fileid = 0; |
| 2834 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 2835 | return -EIO; |
| 2836 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2837 | p = xdr_inline_decode(xdr, 8); |
| 2838 | if (unlikely(!p)) |
| 2839 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2840 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2841 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2842 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2843 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2844 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2845 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2846 | out_overflow: |
| 2847 | print_overflow_msg(__func__, xdr); |
| 2848 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2849 | } |
| 2850 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 2851 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 2852 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2853 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2854 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 2855 | |
| 2856 | *fileid = 0; |
| 2857 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 2858 | return -EIO; |
| 2859 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2860 | p = xdr_inline_decode(xdr, 8); |
| 2861 | if (unlikely(!p)) |
| 2862 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2863 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 2864 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2865 | ret = NFS_ATTR_FATTR_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 2866 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2867 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 2868 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2869 | out_overflow: |
| 2870 | print_overflow_msg(__func__, xdr); |
| 2871 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 2872 | } |
| 2873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 2875 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2876 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | int status = 0; |
| 2878 | |
| 2879 | *res = 0; |
| 2880 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 2881 | return -EIO; |
| 2882 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2883 | p = xdr_inline_decode(xdr, 8); |
| 2884 | if (unlikely(!p)) |
| 2885 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2886 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 2888 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2889 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2890 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2891 | out_overflow: |
| 2892 | print_overflow_msg(__func__, xdr); |
| 2893 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | } |
| 2895 | |
| 2896 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 2897 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2898 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2899 | int status = 0; |
| 2900 | |
| 2901 | *res = 0; |
| 2902 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 2903 | return -EIO; |
| 2904 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2905 | p = xdr_inline_decode(xdr, 8); |
| 2906 | if (unlikely(!p)) |
| 2907 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2908 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2909 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 2910 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2911 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2912 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2913 | out_overflow: |
| 2914 | print_overflow_msg(__func__, xdr); |
| 2915 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2916 | } |
| 2917 | |
| 2918 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 2919 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2920 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2921 | int status = 0; |
| 2922 | |
| 2923 | *res = 0; |
| 2924 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 2925 | return -EIO; |
| 2926 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2927 | p = xdr_inline_decode(xdr, 8); |
| 2928 | if (unlikely(!p)) |
| 2929 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2930 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2931 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 2932 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2933 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2935 | out_overflow: |
| 2936 | print_overflow_msg(__func__, xdr); |
| 2937 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2938 | } |
| 2939 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 2940 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 2941 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 2942 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2943 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 2944 | int status = 0; |
| 2945 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2946 | p = xdr_inline_decode(xdr, 4); |
| 2947 | if (unlikely(!p)) |
| 2948 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2949 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 2950 | if (n == 0) |
| 2951 | goto root_path; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 2952 | dprintk("path "); |
| 2953 | path->ncomponents = 0; |
| 2954 | while (path->ncomponents < n) { |
| 2955 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 2956 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 2957 | if (unlikely(status != 0)) |
| 2958 | goto out_eio; |
| 2959 | if (path->ncomponents != n) |
| 2960 | dprintk("/"); |
| 2961 | dprintk("%s", component->data); |
| 2962 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 2963 | path->ncomponents++; |
| 2964 | else { |
| 2965 | dprintk("cannot parse %d components in path\n", n); |
| 2966 | goto out_eio; |
| 2967 | } |
| 2968 | } |
| 2969 | out: |
| 2970 | dprintk("\n"); |
| 2971 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 2972 | root_path: |
| 2973 | /* a root pathname is sent as a zero component4 */ |
| 2974 | path->ncomponents = 1; |
| 2975 | path->components[0].len=0; |
| 2976 | path->components[0].data=NULL; |
| 2977 | dprintk("path /\n"); |
| 2978 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 2979 | out_eio: |
| 2980 | dprintk(" status %d", status); |
| 2981 | status = -EIO; |
| 2982 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2983 | out_overflow: |
| 2984 | print_overflow_msg(__func__, xdr); |
| 2985 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 2986 | } |
| 2987 | |
| 2988 | 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] | 2989 | { |
| 2990 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2991 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2992 | int status = -EIO; |
| 2993 | |
| 2994 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 2995 | goto out; |
| 2996 | status = 0; |
| 2997 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 2998 | goto out; |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 2999 | dprintk("%s: fsroot ", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3000 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3001 | if (unlikely(status != 0)) |
| 3002 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3003 | p = xdr_inline_decode(xdr, 4); |
| 3004 | if (unlikely(!p)) |
| 3005 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3006 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3007 | if (n <= 0) |
| 3008 | goto out_eio; |
| 3009 | res->nlocations = 0; |
| 3010 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3011 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3012 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3013 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3014 | p = xdr_inline_decode(xdr, 4); |
| 3015 | if (unlikely(!p)) |
| 3016 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3017 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3018 | |
| 3019 | loc->nservers = 0; |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3020 | dprintk("%s: servers ", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3021 | while (loc->nservers < m) { |
| 3022 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3023 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3024 | if (unlikely(status != 0)) |
| 3025 | goto out_eio; |
| 3026 | dprintk("%s ", server->data); |
| 3027 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3028 | loc->nservers++; |
| 3029 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3030 | unsigned int i; |
| 3031 | dprintk("%s: using first %u of %u servers " |
| 3032 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3033 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3034 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3035 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3036 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3037 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3038 | char *data; |
| 3039 | status = decode_opaque_inline(xdr, &len, &data); |
| 3040 | if (unlikely(status != 0)) |
| 3041 | goto out_eio; |
| 3042 | } |
| 3043 | } |
| 3044 | } |
| 3045 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3046 | if (unlikely(status != 0)) |
| 3047 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3048 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3049 | res->nlocations++; |
| 3050 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3051 | if (res->nlocations != 0) |
| 3052 | status = NFS_ATTR_FATTR_V4_REFERRAL; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3053 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3054 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3055 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3056 | out_overflow: |
| 3057 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3058 | out_eio: |
| 3059 | status = -EIO; |
| 3060 | goto out; |
| 3061 | } |
| 3062 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3064 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3065 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | int status = 0; |
| 3067 | |
| 3068 | *res = 0; |
| 3069 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3070 | return -EIO; |
| 3071 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3072 | p = xdr_inline_decode(xdr, 8); |
| 3073 | if (unlikely(!p)) |
| 3074 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3075 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3077 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3078 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3079 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3080 | out_overflow: |
| 3081 | print_overflow_msg(__func__, xdr); |
| 3082 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3083 | } |
| 3084 | |
| 3085 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3086 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3087 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3088 | int status = 0; |
| 3089 | |
| 3090 | *maxlink = 1; |
| 3091 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3092 | return -EIO; |
| 3093 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3094 | p = xdr_inline_decode(xdr, 4); |
| 3095 | if (unlikely(!p)) |
| 3096 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3097 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3099 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3100 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3101 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3102 | out_overflow: |
| 3103 | print_overflow_msg(__func__, xdr); |
| 3104 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3105 | } |
| 3106 | |
| 3107 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3108 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3109 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3110 | int status = 0; |
| 3111 | |
| 3112 | *maxname = 1024; |
| 3113 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3114 | return -EIO; |
| 3115 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3116 | p = xdr_inline_decode(xdr, 4); |
| 3117 | if (unlikely(!p)) |
| 3118 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3119 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3120 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3121 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3122 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3123 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3124 | out_overflow: |
| 3125 | print_overflow_msg(__func__, xdr); |
| 3126 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3127 | } |
| 3128 | |
| 3129 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3130 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3131 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3132 | int status = 0; |
| 3133 | |
| 3134 | *res = 1024; |
| 3135 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3136 | return -EIO; |
| 3137 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3138 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3139 | p = xdr_inline_decode(xdr, 8); |
| 3140 | if (unlikely(!p)) |
| 3141 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3142 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3143 | if (maxread > 0x7FFFFFFF) |
| 3144 | maxread = 0x7FFFFFFF; |
| 3145 | *res = (uint32_t)maxread; |
| 3146 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3147 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3148 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3149 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3150 | out_overflow: |
| 3151 | print_overflow_msg(__func__, xdr); |
| 3152 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3156 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3157 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3158 | int status = 0; |
| 3159 | |
| 3160 | *res = 1024; |
| 3161 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3162 | return -EIO; |
| 3163 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3164 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3165 | p = xdr_inline_decode(xdr, 8); |
| 3166 | if (unlikely(!p)) |
| 3167 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3168 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3169 | if (maxwrite > 0x7FFFFFFF) |
| 3170 | maxwrite = 0x7FFFFFFF; |
| 3171 | *res = (uint32_t)maxwrite; |
| 3172 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3173 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3174 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3175 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3176 | out_overflow: |
| 3177 | print_overflow_msg(__func__, xdr); |
| 3178 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3179 | } |
| 3180 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3181 | 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] | 3182 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3183 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3184 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3185 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3186 | |
| 3187 | *mode = 0; |
| 3188 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3189 | return -EIO; |
| 3190 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3191 | p = xdr_inline_decode(xdr, 4); |
| 3192 | if (unlikely(!p)) |
| 3193 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3194 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3195 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3197 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3199 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3200 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3201 | out_overflow: |
| 3202 | print_overflow_msg(__func__, xdr); |
| 3203 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3204 | } |
| 3205 | |
| 3206 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3207 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3208 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3209 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3210 | |
| 3211 | *nlink = 1; |
| 3212 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3213 | return -EIO; |
| 3214 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3215 | p = xdr_inline_decode(xdr, 4); |
| 3216 | if (unlikely(!p)) |
| 3217 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3218 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3219 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3220 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3221 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3222 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3223 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3224 | out_overflow: |
| 3225 | print_overflow_msg(__func__, xdr); |
| 3226 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3227 | } |
| 3228 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3229 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
| 3230 | struct nfs_client *clp, uint32_t *uid, int may_sleep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3232 | uint32_t len; |
| 3233 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3234 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | |
| 3236 | *uid = -2; |
| 3237 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3238 | return -EIO; |
| 3239 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3240 | p = xdr_inline_decode(xdr, 4); |
| 3241 | if (unlikely(!p)) |
| 3242 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3243 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3244 | p = xdr_inline_decode(xdr, len); |
| 3245 | if (unlikely(!p)) |
| 3246 | goto out_overflow; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3247 | if (!may_sleep) { |
| 3248 | /* do nothing */ |
| 3249 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3250 | if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0) |
| 3251 | ret = NFS_ATTR_FATTR_OWNER; |
| 3252 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3253 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3254 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3256 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3257 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3259 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3260 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3261 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3262 | out_overflow: |
| 3263 | print_overflow_msg(__func__, xdr); |
| 3264 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3265 | } |
| 3266 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3267 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
| 3268 | struct nfs_client *clp, uint32_t *gid, int may_sleep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3269 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3270 | uint32_t len; |
| 3271 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3272 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | |
| 3274 | *gid = -2; |
| 3275 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3276 | return -EIO; |
| 3277 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3278 | p = xdr_inline_decode(xdr, 4); |
| 3279 | if (unlikely(!p)) |
| 3280 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3281 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3282 | p = xdr_inline_decode(xdr, len); |
| 3283 | if (unlikely(!p)) |
| 3284 | goto out_overflow; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3285 | if (!may_sleep) { |
| 3286 | /* do nothing */ |
| 3287 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3288 | if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0) |
| 3289 | ret = NFS_ATTR_FATTR_GROUP; |
| 3290 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3291 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3292 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3294 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3295 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3297 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3298 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3299 | return ret; |
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 | |
| 3305 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3306 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3307 | uint32_t major = 0, minor = 0; |
| 3308 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3309 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | |
| 3311 | *rdev = MKDEV(0,0); |
| 3312 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3313 | return -EIO; |
| 3314 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3315 | dev_t tmp; |
| 3316 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3317 | p = xdr_inline_decode(xdr, 8); |
| 3318 | if (unlikely(!p)) |
| 3319 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3320 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3321 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3322 | tmp = MKDEV(major, minor); |
| 3323 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3324 | *rdev = tmp; |
| 3325 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3326 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3327 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3328 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3329 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3330 | out_overflow: |
| 3331 | print_overflow_msg(__func__, xdr); |
| 3332 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3333 | } |
| 3334 | |
| 3335 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3336 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3337 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3338 | int status = 0; |
| 3339 | |
| 3340 | *res = 0; |
| 3341 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3342 | return -EIO; |
| 3343 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3344 | p = xdr_inline_decode(xdr, 8); |
| 3345 | if (unlikely(!p)) |
| 3346 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3347 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3349 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3350 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3351 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3352 | out_overflow: |
| 3353 | print_overflow_msg(__func__, xdr); |
| 3354 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3355 | } |
| 3356 | |
| 3357 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3358 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3359 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3360 | int status = 0; |
| 3361 | |
| 3362 | *res = 0; |
| 3363 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3364 | return -EIO; |
| 3365 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3366 | p = xdr_inline_decode(xdr, 8); |
| 3367 | if (unlikely(!p)) |
| 3368 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3369 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3370 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3371 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3372 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3373 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3374 | out_overflow: |
| 3375 | print_overflow_msg(__func__, xdr); |
| 3376 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3377 | } |
| 3378 | |
| 3379 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3380 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3381 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3382 | int status = 0; |
| 3383 | |
| 3384 | *res = 0; |
| 3385 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3386 | return -EIO; |
| 3387 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3388 | p = xdr_inline_decode(xdr, 8); |
| 3389 | if (unlikely(!p)) |
| 3390 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3391 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3392 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 3393 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3394 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3396 | out_overflow: |
| 3397 | print_overflow_msg(__func__, xdr); |
| 3398 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | } |
| 3400 | |
| 3401 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 3402 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3403 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3404 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3405 | |
| 3406 | *used = 0; |
| 3407 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 3408 | return -EIO; |
| 3409 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3410 | p = xdr_inline_decode(xdr, 8); |
| 3411 | if (unlikely(!p)) |
| 3412 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3413 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3414 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3415 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3416 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3417 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3418 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3419 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3420 | out_overflow: |
| 3421 | print_overflow_msg(__func__, xdr); |
| 3422 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3423 | } |
| 3424 | |
| 3425 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 3426 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3427 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3428 | uint64_t sec; |
| 3429 | uint32_t nsec; |
| 3430 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3431 | p = xdr_inline_decode(xdr, 12); |
| 3432 | if (unlikely(!p)) |
| 3433 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3434 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3435 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | time->tv_sec = (time_t)sec; |
| 3437 | time->tv_nsec = (long)nsec; |
| 3438 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3439 | out_overflow: |
| 3440 | print_overflow_msg(__func__, xdr); |
| 3441 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | } |
| 3443 | |
| 3444 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3445 | { |
| 3446 | int status = 0; |
| 3447 | |
| 3448 | time->tv_sec = 0; |
| 3449 | time->tv_nsec = 0; |
| 3450 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 3451 | return -EIO; |
| 3452 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 3453 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3454 | if (status == 0) |
| 3455 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3456 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 3457 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3458 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | return status; |
| 3460 | } |
| 3461 | |
| 3462 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3463 | { |
| 3464 | int status = 0; |
| 3465 | |
| 3466 | time->tv_sec = 0; |
| 3467 | time->tv_nsec = 0; |
| 3468 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 3469 | return -EIO; |
| 3470 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 3471 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3472 | if (status == 0) |
| 3473 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3474 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 3475 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3476 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3477 | return status; |
| 3478 | } |
| 3479 | |
| 3480 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3481 | { |
| 3482 | int status = 0; |
| 3483 | |
| 3484 | time->tv_sec = 0; |
| 3485 | time->tv_nsec = 0; |
| 3486 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 3487 | return -EIO; |
| 3488 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 3489 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3490 | if (status == 0) |
| 3491 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3492 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 3493 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3494 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3495 | return status; |
| 3496 | } |
| 3497 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3498 | 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] | 3499 | { |
| 3500 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 3501 | unsigned int nwords = xdr->p - savep; |
| 3502 | |
| 3503 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3504 | dprintk("%s: server returned incorrect attribute length: " |
| 3505 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3506 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3507 | attrwords << 2, |
| 3508 | (attrwords < nwords) ? '<' : '>', |
| 3509 | nwords << 2); |
| 3510 | return -EIO; |
| 3511 | } |
| 3512 | return 0; |
| 3513 | } |
| 3514 | |
| 3515 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 3516 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3517 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3519 | p = xdr_inline_decode(xdr, 20); |
| 3520 | if (unlikely(!p)) |
| 3521 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3522 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3523 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3524 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3525 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3526 | out_overflow: |
| 3527 | print_overflow_msg(__func__, xdr); |
| 3528 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3529 | } |
| 3530 | |
| 3531 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 3532 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3533 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | uint32_t supp, acc; |
| 3535 | int status; |
| 3536 | |
| 3537 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 3538 | if (status) |
| 3539 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3540 | p = xdr_inline_decode(xdr, 8); |
| 3541 | if (unlikely(!p)) |
| 3542 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3543 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3544 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3545 | access->supported = supp; |
| 3546 | access->access = acc; |
| 3547 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3548 | out_overflow: |
| 3549 | print_overflow_msg(__func__, xdr); |
| 3550 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3551 | } |
| 3552 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 3553 | 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] | 3554 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3555 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 3556 | |
| 3557 | p = xdr_inline_decode(xdr, len); |
| 3558 | if (likely(p)) { |
| 3559 | memcpy(buf, p, len); |
| 3560 | return 0; |
| 3561 | } |
| 3562 | print_overflow_msg(__func__, xdr); |
| 3563 | return -EIO; |
| 3564 | } |
| 3565 | |
| 3566 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 3567 | { |
| 3568 | return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3569 | } |
| 3570 | |
| 3571 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 3572 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3573 | int status; |
| 3574 | |
| 3575 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 3576 | if (status != -EIO) |
| 3577 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 3578 | if (!status) |
| 3579 | status = decode_stateid(xdr, &res->stateid); |
| 3580 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3581 | } |
| 3582 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 3583 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 3584 | { |
| 3585 | return decode_opaque_fixed(xdr, verifier, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3586 | } |
| 3587 | |
| 3588 | static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 3589 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3590 | int status; |
| 3591 | |
| 3592 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 3593 | if (!status) |
| 3594 | status = decode_verifier(xdr, res->verf->verifier); |
| 3595 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3596 | } |
| 3597 | |
| 3598 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 3599 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3600 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3601 | uint32_t bmlen; |
| 3602 | int status; |
| 3603 | |
| 3604 | status = decode_op_hdr(xdr, OP_CREATE); |
| 3605 | if (status) |
| 3606 | return status; |
| 3607 | if ((status = decode_change_info(xdr, cinfo))) |
| 3608 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3609 | p = xdr_inline_decode(xdr, 4); |
| 3610 | if (unlikely(!p)) |
| 3611 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3612 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3613 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 3614 | if (likely(p)) |
| 3615 | return 0; |
| 3616 | out_overflow: |
| 3617 | print_overflow_msg(__func__, xdr); |
| 3618 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3619 | } |
| 3620 | |
| 3621 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 3622 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3623 | __be32 *savep; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3624 | uint32_t attrlen, bitmap[2] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3625 | int status; |
| 3626 | |
| 3627 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 3628 | goto xdr_error; |
| 3629 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 3630 | goto xdr_error; |
| 3631 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 3632 | goto xdr_error; |
| 3633 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 3634 | goto xdr_error; |
| 3635 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 3636 | goto xdr_error; |
| 3637 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 3638 | goto xdr_error; |
| 3639 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 3640 | goto xdr_error; |
| 3641 | status = verify_attr_len(xdr, savep, attrlen); |
| 3642 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3643 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3644 | return status; |
| 3645 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3646 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3647 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 3648 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3649 | __be32 *savep; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3650 | uint32_t attrlen, bitmap[2] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3651 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 3654 | goto xdr_error; |
| 3655 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 3656 | goto xdr_error; |
| 3657 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 3658 | goto xdr_error; |
| 3659 | |
| 3660 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 3661 | goto xdr_error; |
| 3662 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 3663 | goto xdr_error; |
| 3664 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 3665 | goto xdr_error; |
| 3666 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 3667 | goto xdr_error; |
| 3668 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 3669 | goto xdr_error; |
| 3670 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 3671 | goto xdr_error; |
| 3672 | |
| 3673 | status = verify_attr_len(xdr, savep, attrlen); |
| 3674 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3675 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | return status; |
| 3677 | } |
| 3678 | |
| 3679 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 3680 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3681 | __be32 *savep; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3682 | uint32_t attrlen, bitmap[2] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3683 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3684 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3685 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 3686 | goto xdr_error; |
| 3687 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 3688 | goto xdr_error; |
| 3689 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 3690 | goto xdr_error; |
| 3691 | |
| 3692 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 3693 | goto xdr_error; |
| 3694 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 3695 | goto xdr_error; |
| 3696 | |
| 3697 | status = verify_attr_len(xdr, savep, attrlen); |
| 3698 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3699 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3700 | return status; |
| 3701 | } |
| 3702 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3703 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 3704 | const struct nfs_server *server, int may_sleep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3706 | __be32 *savep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | uint32_t attrlen, |
| 3708 | bitmap[2] = {0}, |
| 3709 | type; |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3710 | int status; |
| 3711 | umode_t fmode = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3712 | uint64_t fileid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3713 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3714 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 3715 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3716 | goto xdr_error; |
| 3717 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3718 | status = decode_attr_bitmap(xdr, bitmap); |
| 3719 | if (status < 0) |
| 3720 | goto xdr_error; |
| 3721 | |
| 3722 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 3723 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | goto xdr_error; |
| 3725 | |
| 3726 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3727 | status = decode_attr_type(xdr, bitmap, &type); |
| 3728 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3730 | fattr->mode = 0; |
| 3731 | if (status != 0) { |
| 3732 | fattr->mode |= nfs_type2fmt[type]; |
| 3733 | fattr->valid |= status; |
| 3734 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3735 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3736 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 3737 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3739 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3740 | |
| 3741 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 3742 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3743 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3744 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3745 | |
| 3746 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 3747 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3748 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3749 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3750 | |
| 3751 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 3752 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3753 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3754 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3755 | |
| 3756 | status = decode_attr_fs_locations(xdr, bitmap, container_of(fattr, |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3757 | struct nfs4_fs_locations, |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3758 | fattr)); |
| 3759 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3760 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3761 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3762 | |
| 3763 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 3764 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3765 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3766 | if (status != 0) { |
| 3767 | fattr->mode |= fmode; |
| 3768 | fattr->valid |= status; |
| 3769 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3770 | |
| 3771 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 3772 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3773 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3774 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3775 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3776 | status = decode_attr_owner(xdr, bitmap, server->nfs_client, |
| 3777 | &fattr->uid, may_sleep); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3778 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3780 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3781 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3782 | status = decode_attr_group(xdr, bitmap, server->nfs_client, |
| 3783 | &fattr->gid, may_sleep); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3784 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3785 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3786 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3787 | |
| 3788 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 3789 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3791 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3792 | |
| 3793 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 3794 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3795 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3796 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3797 | |
| 3798 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 3799 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3800 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3801 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3802 | |
| 3803 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 3804 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3805 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3806 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3807 | |
| 3808 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 3809 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3811 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3812 | |
| 3813 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fileid); |
| 3814 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3815 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3816 | if (status != 0 && !(fattr->valid & status)) { |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3817 | fattr->fileid = fileid; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3818 | fattr->valid |= status; |
| 3819 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3820 | |
| 3821 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3822 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3823 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3824 | return status; |
| 3825 | } |
| 3826 | |
| 3827 | |
| 3828 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 3829 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3830 | __be32 *savep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3831 | uint32_t attrlen, bitmap[2]; |
| 3832 | int status; |
| 3833 | |
| 3834 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 3835 | goto xdr_error; |
| 3836 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 3837 | goto xdr_error; |
| 3838 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 3839 | goto xdr_error; |
| 3840 | |
| 3841 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 3842 | |
| 3843 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 3844 | goto xdr_error; |
| 3845 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 3846 | goto xdr_error; |
| 3847 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 3848 | goto xdr_error; |
| 3849 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 3850 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 3851 | goto xdr_error; |
| 3852 | fsinfo->wtpref = fsinfo->wtmax; |
| 3853 | |
| 3854 | status = verify_attr_len(xdr, savep, attrlen); |
| 3855 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3856 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3857 | return status; |
| 3858 | } |
| 3859 | |
| 3860 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 3861 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3862 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | uint32_t len; |
| 3864 | int status; |
| 3865 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 3866 | /* Zero handle first to allow comparisons */ |
| 3867 | memset(fh, 0, sizeof(*fh)); |
| 3868 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | status = decode_op_hdr(xdr, OP_GETFH); |
| 3870 | if (status) |
| 3871 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3872 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3873 | p = xdr_inline_decode(xdr, 4); |
| 3874 | if (unlikely(!p)) |
| 3875 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3876 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3877 | if (len > NFS4_FHSIZE) |
| 3878 | return -EIO; |
| 3879 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3880 | p = xdr_inline_decode(xdr, len); |
| 3881 | if (unlikely(!p)) |
| 3882 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 3883 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3884 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3885 | out_overflow: |
| 3886 | print_overflow_msg(__func__, xdr); |
| 3887 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3888 | } |
| 3889 | |
| 3890 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 3891 | { |
| 3892 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3893 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3894 | status = decode_op_hdr(xdr, OP_LINK); |
| 3895 | if (status) |
| 3896 | return status; |
| 3897 | return decode_change_info(xdr, cinfo); |
| 3898 | } |
| 3899 | |
| 3900 | /* |
| 3901 | * We create the owner, so we know a proper owner.id length is 4. |
| 3902 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3903 | 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] | 3904 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3905 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3906 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3907 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3908 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3909 | p = xdr_inline_decode(xdr, 32); |
| 3910 | if (unlikely(!p)) |
| 3911 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3912 | p = xdr_decode_hyper(p, &offset); |
| 3913 | p = xdr_decode_hyper(p, &length); |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3914 | type = be32_to_cpup(p++); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3915 | if (fl != NULL) { |
| 3916 | fl->fl_start = (loff_t)offset; |
| 3917 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 3918 | if (length == ~(uint64_t)0) |
| 3919 | fl->fl_end = OFFSET_MAX; |
| 3920 | fl->fl_type = F_WRLCK; |
| 3921 | if (type & 1) |
| 3922 | fl->fl_type = F_RDLCK; |
| 3923 | fl->fl_pid = 0; |
| 3924 | } |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3925 | p = xdr_decode_hyper(p, &clientid); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3926 | namelen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3927 | p = xdr_inline_decode(xdr, namelen); |
| 3928 | if (likely(p)) |
| 3929 | return -NFS4ERR_DENIED; |
| 3930 | out_overflow: |
| 3931 | print_overflow_msg(__func__, xdr); |
| 3932 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3933 | } |
| 3934 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3935 | 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] | 3936 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | int status; |
| 3938 | |
| 3939 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 3940 | if (status == -EIO) |
| 3941 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3942 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 3943 | status = decode_stateid(xdr, &res->stateid); |
| 3944 | if (unlikely(status)) |
| 3945 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3946 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 3947 | status = decode_lock_denied(xdr, NULL); |
| 3948 | if (res->open_seqid != NULL) |
| 3949 | nfs_increment_open_seqid(status, res->open_seqid); |
| 3950 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 3951 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3952 | return status; |
| 3953 | } |
| 3954 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3955 | 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] | 3956 | { |
| 3957 | int status; |
| 3958 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 3959 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3960 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3961 | return status; |
| 3962 | } |
| 3963 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 3964 | 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] | 3965 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3966 | int status; |
| 3967 | |
| 3968 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 3969 | if (status != -EIO) |
| 3970 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 3971 | if (status == 0) |
| 3972 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | return status; |
| 3974 | } |
| 3975 | |
| 3976 | static int decode_lookup(struct xdr_stream *xdr) |
| 3977 | { |
| 3978 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 3979 | } |
| 3980 | |
| 3981 | /* This is too sick! */ |
| 3982 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 3983 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3984 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3985 | uint32_t limit_type, nblocks, blocksize; |
| 3986 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3987 | p = xdr_inline_decode(xdr, 12); |
| 3988 | if (unlikely(!p)) |
| 3989 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3990 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3992 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3993 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3994 | break; |
| 3995 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3996 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3997 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3998 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3999 | } |
| 4000 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4001 | out_overflow: |
| 4002 | print_overflow_msg(__func__, xdr); |
| 4003 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | } |
| 4005 | |
| 4006 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4007 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4008 | __be32 *p; |
| 4009 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4010 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4011 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4012 | p = xdr_inline_decode(xdr, 4); |
| 4013 | if (unlikely(!p)) |
| 4014 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4015 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4016 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4017 | res->delegation_type = 0; |
| 4018 | return 0; |
| 4019 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4020 | status = decode_stateid(xdr, &res->delegation); |
| 4021 | if (unlikely(status)) |
| 4022 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4023 | p = xdr_inline_decode(xdr, 4); |
| 4024 | if (unlikely(!p)) |
| 4025 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4026 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4027 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4029 | case NFS4_OPEN_DELEGATE_READ: |
| 4030 | res->delegation_type = FMODE_READ; |
| 4031 | break; |
| 4032 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4033 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4034 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4035 | return -EIO; |
| 4036 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4037 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4038 | out_overflow: |
| 4039 | print_overflow_msg(__func__, xdr); |
| 4040 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4041 | } |
| 4042 | |
| 4043 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4044 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4045 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4046 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4047 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4048 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4049 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4050 | if (status != -EIO) |
| 4051 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4052 | if (!status) |
| 4053 | status = decode_stateid(xdr, &res->stateid); |
| 4054 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4055 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4057 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4058 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4059 | p = xdr_inline_decode(xdr, 8); |
| 4060 | if (unlikely(!p)) |
| 4061 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4062 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4063 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4064 | if (bmlen > 10) |
| 4065 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4066 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4067 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4068 | if (unlikely(!p)) |
| 4069 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4070 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4071 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4072 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4073 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4074 | res->attrset[i] = 0; |
| 4075 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4076 | return decode_delegation(xdr, res); |
| 4077 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4078 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4080 | out_overflow: |
| 4081 | print_overflow_msg(__func__, xdr); |
| 4082 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4083 | } |
| 4084 | |
| 4085 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4086 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4087 | int status; |
| 4088 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4089 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4090 | if (status != -EIO) |
| 4091 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4092 | if (!status) |
| 4093 | status = decode_stateid(xdr, &res->stateid); |
| 4094 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4095 | } |
| 4096 | |
| 4097 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4098 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4099 | int status; |
| 4100 | |
| 4101 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4102 | if (status != -EIO) |
| 4103 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4104 | if (!status) |
| 4105 | status = decode_stateid(xdr, &res->stateid); |
| 4106 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4107 | } |
| 4108 | |
| 4109 | static int decode_putfh(struct xdr_stream *xdr) |
| 4110 | { |
| 4111 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4112 | } |
| 4113 | |
| 4114 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4115 | { |
| 4116 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4117 | } |
| 4118 | |
| 4119 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4120 | { |
| 4121 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4122 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4123 | uint32_t count, eof, recvd, hdrlen; |
| 4124 | int status; |
| 4125 | |
| 4126 | status = decode_op_hdr(xdr, OP_READ); |
| 4127 | if (status) |
| 4128 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4129 | p = xdr_inline_decode(xdr, 8); |
| 4130 | if (unlikely(!p)) |
| 4131 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4132 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4133 | count = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4134 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
| 4135 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4136 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4137 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4138 | "count %u > recvd %u\n", count, recvd); |
| 4139 | count = recvd; |
| 4140 | eof = 0; |
| 4141 | } |
| 4142 | xdr_read_pages(xdr, count); |
| 4143 | res->eof = eof; |
| 4144 | res->count = count; |
| 4145 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4146 | out_overflow: |
| 4147 | print_overflow_msg(__func__, xdr); |
| 4148 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4149 | } |
| 4150 | |
| 4151 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4152 | { |
| 4153 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4154 | struct page *page = *rcvbuf->pages; |
| 4155 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4156 | size_t hdrlen; |
| 4157 | u32 recvd, pglen = rcvbuf->page_len; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4158 | __be32 *end, *entry, *p, *kaddr; |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4159 | unsigned int nr = 0; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4160 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4161 | |
| 4162 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4163 | if (!status) |
| 4164 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4165 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4166 | return status; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4167 | dprintk("%s: verifier = %08x:%08x\n", |
| 4168 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 4169 | ((u32 *)readdir->verifier.data)[0], |
| 4170 | ((u32 *)readdir->verifier.data)[1]); |
| 4171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4172 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4173 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4174 | recvd = rcvbuf->len - hdrlen; |
| 4175 | if (pglen > recvd) |
| 4176 | pglen = recvd; |
| 4177 | xdr_read_pages(xdr, pglen); |
| 4178 | |
| 4179 | BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE); |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4180 | kaddr = p = kmap_atomic(page, KM_USER0); |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4181 | end = p + ((pglen + readdir->pgbase) >> 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4182 | entry = p; |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4183 | |
| 4184 | /* Make sure the packet actually has a value_follows and EOF entry */ |
| 4185 | if ((entry + 1) > end) |
| 4186 | goto short_pkt; |
| 4187 | |
| 4188 | for (; *p++; nr++) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4189 | u32 len, attrlen, xlen; |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4190 | if (end - p < 3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4191 | goto short_pkt; |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 4192 | dprintk("cookie = %Lu, ", *((unsigned long long *)p)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4193 | p += 2; /* cookie */ |
| 4194 | len = ntohl(*p++); /* filename length */ |
| 4195 | if (len > NFS4_MAXNAMLEN) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4196 | dprintk("NFS: giant filename in readdir (len 0x%x)\n", |
| 4197 | len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4198 | goto err_unmap; |
| 4199 | } |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4200 | xlen = XDR_QUADLEN(len); |
| 4201 | if (end - p < xlen + 1) |
| 4202 | goto short_pkt; |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 4203 | dprintk("filename = %*s\n", len, (char *)p); |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4204 | p += xlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4205 | len = ntohl(*p++); /* bitmap length */ |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4206 | if (end - p < len + 1) |
| 4207 | goto short_pkt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4208 | p += len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4209 | attrlen = XDR_QUADLEN(ntohl(*p++)); |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4210 | if (end - p < attrlen + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | goto short_pkt; |
David Howells | e889649 | 2006-08-24 15:44:19 -0400 | [diff] [blame] | 4212 | p += attrlen; /* attributes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4213 | entry = p; |
| 4214 | } |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4215 | /* |
| 4216 | * Apparently some server sends responses that are a valid size, but |
| 4217 | * contain no entries, and have value_follows==0 and EOF==0. For |
| 4218 | * those, just set the EOF marker. |
| 4219 | */ |
| 4220 | if (!nr && entry[1] == 0) { |
| 4221 | dprintk("NFS: readdir reply truncated!\n"); |
| 4222 | entry[1] = 1; |
| 4223 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4224 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4225 | kunmap_atomic(kaddr, KM_USER0); |
| 4226 | return 0; |
| 4227 | short_pkt: |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4228 | /* |
| 4229 | * When we get a short packet there are 2 possibilities. We can |
| 4230 | * return an error, or fix up the response to look like a valid |
| 4231 | * response and return what we have so far. If there are no |
| 4232 | * entries and the packet was short, then return -EIO. If there |
| 4233 | * are valid entries in the response, return them and pretend that |
| 4234 | * the call was successful, but incomplete. The caller can retry the |
| 4235 | * readdir starting at the last cookie. |
| 4236 | */ |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4237 | dprintk("%s: short packet at entry %d\n", __func__, nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4238 | entry[0] = entry[1] = 0; |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4239 | if (nr) |
| 4240 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4241 | err_unmap: |
| 4242 | kunmap_atomic(kaddr, KM_USER0); |
| 4243 | return -errno_NFSERR_IO; |
| 4244 | } |
| 4245 | |
| 4246 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4247 | { |
| 4248 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4249 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4250 | size_t hdrlen; |
| 4251 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4252 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | char *kaddr; |
| 4254 | int status; |
| 4255 | |
| 4256 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4257 | if (status) |
| 4258 | return status; |
| 4259 | |
| 4260 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4261 | p = xdr_inline_decode(xdr, 4); |
| 4262 | if (unlikely(!p)) |
| 4263 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4264 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4265 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4266 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4267 | return -ENAMETOOLONG; |
| 4268 | } |
| 4269 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4270 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4271 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4272 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | "count %u > recvd %u\n", len, recvd); |
| 4274 | return -EIO; |
| 4275 | } |
| 4276 | xdr_read_pages(xdr, len); |
| 4277 | /* |
| 4278 | * The XDR encode routine has set things up so that |
| 4279 | * the link text will be copied directly into the |
| 4280 | * buffer. We just have to do overflow-checking, |
| 4281 | * and and null-terminate the text (the VFS expects |
| 4282 | * null-termination). |
| 4283 | */ |
| 4284 | kaddr = (char *)kmap_atomic(rcvbuf->pages[0], KM_USER0); |
| 4285 | kaddr[len+rcvbuf->page_base] = '\0'; |
| 4286 | kunmap_atomic(kaddr, KM_USER0); |
| 4287 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4288 | out_overflow: |
| 4289 | print_overflow_msg(__func__, xdr); |
| 4290 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4291 | } |
| 4292 | |
| 4293 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4294 | { |
| 4295 | int status; |
| 4296 | |
| 4297 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 4298 | if (status) |
| 4299 | goto out; |
| 4300 | status = decode_change_info(xdr, cinfo); |
| 4301 | out: |
| 4302 | return status; |
| 4303 | } |
| 4304 | |
| 4305 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 4306 | struct nfs4_change_info *new_cinfo) |
| 4307 | { |
| 4308 | int status; |
| 4309 | |
| 4310 | status = decode_op_hdr(xdr, OP_RENAME); |
| 4311 | if (status) |
| 4312 | goto out; |
| 4313 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 4314 | goto out; |
| 4315 | status = decode_change_info(xdr, new_cinfo); |
| 4316 | out: |
| 4317 | return status; |
| 4318 | } |
| 4319 | |
| 4320 | static int decode_renew(struct xdr_stream *xdr) |
| 4321 | { |
| 4322 | return decode_op_hdr(xdr, OP_RENEW); |
| 4323 | } |
| 4324 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4325 | static int |
| 4326 | decode_restorefh(struct xdr_stream *xdr) |
| 4327 | { |
| 4328 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 4329 | } |
| 4330 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4331 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 4332 | size_t *acl_len) |
| 4333 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4334 | __be32 *savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4335 | uint32_t attrlen, |
| 4336 | bitmap[2] = {0}; |
| 4337 | struct kvec *iov = req->rq_rcv_buf.head; |
| 4338 | int status; |
| 4339 | |
| 4340 | *acl_len = 0; |
| 4341 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4342 | goto out; |
| 4343 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4344 | goto out; |
| 4345 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4346 | goto out; |
| 4347 | |
| 4348 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 4349 | return -EIO; |
| 4350 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4351 | size_t hdrlen; |
| 4352 | u32 recvd; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4353 | |
| 4354 | /* We ignore &savep and don't do consistency checks on |
| 4355 | * the attr length. Let userspace figure it out.... */ |
| 4356 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
| 4357 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4358 | if (attrlen > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4359 | dprintk("NFS: server cheating in getattr" |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4360 | " acl reply: attrlen %u > recvd %u\n", |
| 4361 | attrlen, recvd); |
| 4362 | return -EINVAL; |
| 4363 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 4364 | xdr_read_pages(xdr, attrlen); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4365 | *acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 4366 | } else |
| 4367 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4368 | |
| 4369 | out: |
| 4370 | return status; |
| 4371 | } |
| 4372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4373 | static int |
| 4374 | decode_savefh(struct xdr_stream *xdr) |
| 4375 | { |
| 4376 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 4377 | } |
| 4378 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 4379 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4380 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4381 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4382 | uint32_t bmlen; |
| 4383 | int status; |
| 4384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4385 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 4386 | if (status) |
| 4387 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4388 | p = xdr_inline_decode(xdr, 4); |
| 4389 | if (unlikely(!p)) |
| 4390 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4391 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4392 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4393 | if (likely(p)) |
| 4394 | return 0; |
| 4395 | out_overflow: |
| 4396 | print_overflow_msg(__func__, xdr); |
| 4397 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4398 | } |
| 4399 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4400 | 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] | 4401 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4402 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4403 | uint32_t opnum; |
| 4404 | int32_t nfserr; |
| 4405 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4406 | p = xdr_inline_decode(xdr, 8); |
| 4407 | if (unlikely(!p)) |
| 4408 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4409 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4410 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4411 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4412 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4413 | return -EIO; |
| 4414 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4415 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4416 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4417 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 4418 | if (unlikely(!p)) |
| 4419 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4420 | p = xdr_decode_hyper(p, &res->clientid); |
| 4421 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4422 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 4423 | uint32_t len; |
| 4424 | |
| 4425 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4426 | p = xdr_inline_decode(xdr, 4); |
| 4427 | if (unlikely(!p)) |
| 4428 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4429 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4430 | p = xdr_inline_decode(xdr, len); |
| 4431 | if (unlikely(!p)) |
| 4432 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4433 | |
| 4434 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4435 | p = xdr_inline_decode(xdr, 4); |
| 4436 | if (unlikely(!p)) |
| 4437 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4438 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4439 | p = xdr_inline_decode(xdr, len); |
| 4440 | if (unlikely(!p)) |
| 4441 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4442 | return -NFSERR_CLID_INUSE; |
| 4443 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 4444 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4445 | |
| 4446 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4447 | out_overflow: |
| 4448 | print_overflow_msg(__func__, xdr); |
| 4449 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4450 | } |
| 4451 | |
| 4452 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 4453 | { |
| 4454 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 4455 | } |
| 4456 | |
| 4457 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 4458 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4459 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | int status; |
| 4461 | |
| 4462 | status = decode_op_hdr(xdr, OP_WRITE); |
| 4463 | if (status) |
| 4464 | return status; |
| 4465 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4466 | p = xdr_inline_decode(xdr, 16); |
| 4467 | if (unlikely(!p)) |
| 4468 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4469 | res->count = be32_to_cpup(p++); |
| 4470 | res->verf->committed = be32_to_cpup(p++); |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4471 | memcpy(res->verf->verifier, p, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4472 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4473 | out_overflow: |
| 4474 | print_overflow_msg(__func__, xdr); |
| 4475 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4476 | } |
| 4477 | |
| 4478 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 4479 | { |
| 4480 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 4481 | } |
| 4482 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4483 | #if defined(CONFIG_NFS_V4_1) |
| 4484 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 4485 | struct nfs41_exchange_id_res *res) |
| 4486 | { |
| 4487 | __be32 *p; |
| 4488 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 4489 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4490 | int status; |
| 4491 | struct nfs_client *clp = res->client; |
| 4492 | |
| 4493 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 4494 | if (status) |
| 4495 | return status; |
| 4496 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4497 | p = xdr_inline_decode(xdr, 8); |
| 4498 | if (unlikely(!p)) |
| 4499 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4500 | xdr_decode_hyper(p, &clp->cl_ex_clid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4501 | p = xdr_inline_decode(xdr, 12); |
| 4502 | if (unlikely(!p)) |
| 4503 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4504 | clp->cl_seqid = be32_to_cpup(p++); |
| 4505 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4506 | |
| 4507 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4508 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4509 | if (dummy != SP4_NONE) |
| 4510 | return -EIO; |
| 4511 | |
| 4512 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4513 | p = xdr_inline_decode(xdr, 8); |
| 4514 | if (unlikely(!p)) |
| 4515 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4516 | |
| 4517 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 4518 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 4519 | if (unlikely(status)) |
| 4520 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4521 | |
| 4522 | /* Throw away server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 4523 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 4524 | if (unlikely(status)) |
| 4525 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4526 | |
| 4527 | /* Throw away Implementation id array */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 4528 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 4529 | if (unlikely(status)) |
| 4530 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4531 | |
| 4532 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4533 | out_overflow: |
| 4534 | print_overflow_msg(__func__, xdr); |
| 4535 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4536 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4537 | |
| 4538 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 4539 | struct nfs4_channel_attrs *attrs) |
| 4540 | { |
| 4541 | __be32 *p; |
| 4542 | u32 nr_attrs; |
| 4543 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4544 | p = xdr_inline_decode(xdr, 28); |
| 4545 | if (unlikely(!p)) |
| 4546 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4547 | attrs->headerpadsz = be32_to_cpup(p++); |
| 4548 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 4549 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 4550 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 4551 | attrs->max_ops = be32_to_cpup(p++); |
| 4552 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4553 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4554 | if (unlikely(nr_attrs > 1)) { |
| 4555 | printk(KERN_WARNING "%s: Invalid rdma channel attrs count %u\n", |
| 4556 | __func__, nr_attrs); |
| 4557 | return -EINVAL; |
| 4558 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4559 | if (nr_attrs == 1) { |
| 4560 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 4561 | if (unlikely(!p)) |
| 4562 | goto out_overflow; |
| 4563 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4564 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4565 | out_overflow: |
| 4566 | print_overflow_msg(__func__, xdr); |
| 4567 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4568 | } |
| 4569 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4570 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 4571 | { |
| 4572 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4573 | } |
| 4574 | |
| 4575 | static int decode_create_session(struct xdr_stream *xdr, |
| 4576 | struct nfs41_create_session_res *res) |
| 4577 | { |
| 4578 | __be32 *p; |
| 4579 | int status; |
| 4580 | struct nfs_client *clp = res->client; |
| 4581 | struct nfs4_session *session = clp->cl_session; |
| 4582 | |
| 4583 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4584 | if (!status) |
| 4585 | status = decode_sessionid(xdr, &session->sess_id); |
| 4586 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4587 | return status; |
| 4588 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4589 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4590 | p = xdr_inline_decode(xdr, 8); |
| 4591 | if (unlikely(!p)) |
| 4592 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4593 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4594 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4595 | |
| 4596 | /* Channel attributes */ |
| 4597 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 4598 | if (!status) |
| 4599 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 4600 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4601 | out_overflow: |
| 4602 | print_overflow_msg(__func__, xdr); |
| 4603 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 4604 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 4605 | |
| 4606 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 4607 | { |
| 4608 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 4609 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 4610 | |
| 4611 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 4612 | { |
| 4613 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 4614 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 4615 | #endif /* CONFIG_NFS_V4_1 */ |
| 4616 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4617 | static int decode_sequence(struct xdr_stream *xdr, |
| 4618 | struct nfs4_sequence_res *res, |
| 4619 | struct rpc_rqst *rqstp) |
| 4620 | { |
| 4621 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4622 | struct nfs4_slot *slot; |
| 4623 | struct nfs4_sessionid id; |
| 4624 | u32 dummy; |
| 4625 | int status; |
| 4626 | __be32 *p; |
| 4627 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4628 | if (!res->sr_session) |
| 4629 | return 0; |
| 4630 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4631 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4632 | if (!status) |
| 4633 | status = decode_sessionid(xdr, &id); |
| 4634 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4635 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4636 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4637 | /* |
| 4638 | * If the server returns different values for sessionID, slotID or |
| 4639 | * sequence number, the server is looney tunes. |
| 4640 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 4641 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4642 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4643 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 4644 | NFS4_MAX_SESSIONID_LEN)) { |
| 4645 | dprintk("%s Invalid session id\n", __func__); |
| 4646 | goto out_err; |
| 4647 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4648 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4649 | p = xdr_inline_decode(xdr, 20); |
| 4650 | if (unlikely(!p)) |
| 4651 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4652 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4653 | /* seqid */ |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 4654 | slot = &res->sr_session->fc_slot_table.slots[res->sr_slotid]; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4655 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4656 | if (dummy != slot->seq_nr) { |
| 4657 | dprintk("%s Invalid sequence number\n", __func__); |
| 4658 | goto out_err; |
| 4659 | } |
| 4660 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4661 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4662 | if (dummy != res->sr_slotid) { |
| 4663 | dprintk("%s Invalid slot id\n", __func__); |
| 4664 | goto out_err; |
| 4665 | } |
| 4666 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4667 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4668 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4669 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 4670 | /* result flags */ |
| 4671 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4672 | status = 0; |
| 4673 | out_err: |
| 4674 | res->sr_status = status; |
| 4675 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4676 | out_overflow: |
| 4677 | print_overflow_msg(__func__, xdr); |
| 4678 | status = -EIO; |
| 4679 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4680 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4681 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 4682 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4683 | } |
| 4684 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4685 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 4686 | * END OF "GENERIC" DECODE ROUTINES. |
| 4687 | */ |
| 4688 | |
| 4689 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4690 | * Decode OPEN_DOWNGRADE response |
| 4691 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4692 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4693 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4694 | struct xdr_stream xdr; |
| 4695 | struct compound_hdr hdr; |
| 4696 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4697 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4698 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 4699 | status = decode_compound_hdr(&xdr, &hdr); |
| 4700 | if (status) |
| 4701 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4702 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4703 | if (status) |
| 4704 | goto out; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4705 | status = decode_putfh(&xdr); |
| 4706 | if (status) |
| 4707 | goto out; |
| 4708 | status = decode_open_downgrade(&xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 4709 | if (status != 0) |
| 4710 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4711 | decode_getfattr(&xdr, res->fattr, res->server, |
| 4712 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4713 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4714 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4715 | } |
| 4716 | |
| 4717 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4718 | * Decode ACCESS response |
| 4719 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4720 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4721 | { |
| 4722 | struct xdr_stream xdr; |
| 4723 | struct compound_hdr hdr; |
| 4724 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4725 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4726 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4727 | status = decode_compound_hdr(&xdr, &hdr); |
| 4728 | if (status) |
| 4729 | goto out; |
| 4730 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4731 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4732 | goto out; |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 4733 | status = decode_putfh(&xdr); |
| 4734 | if (status != 0) |
| 4735 | goto out; |
| 4736 | status = decode_access(&xdr, res); |
| 4737 | if (status != 0) |
| 4738 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4739 | decode_getfattr(&xdr, res->fattr, res->server, |
| 4740 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4741 | out: |
| 4742 | return status; |
| 4743 | } |
| 4744 | |
| 4745 | /* |
| 4746 | * Decode LOOKUP response |
| 4747 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4748 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4749 | { |
| 4750 | struct xdr_stream xdr; |
| 4751 | struct compound_hdr hdr; |
| 4752 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4753 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4755 | status = decode_compound_hdr(&xdr, &hdr); |
| 4756 | if (status) |
| 4757 | goto out; |
| 4758 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4759 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4760 | goto out; |
| 4761 | if ((status = decode_putfh(&xdr)) != 0) |
| 4762 | goto out; |
| 4763 | if ((status = decode_lookup(&xdr)) != 0) |
| 4764 | goto out; |
| 4765 | if ((status = decode_getfh(&xdr, res->fh)) != 0) |
| 4766 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4767 | status = decode_getfattr(&xdr, res->fattr, res->server |
| 4768 | ,!RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4769 | out: |
| 4770 | return status; |
| 4771 | } |
| 4772 | |
| 4773 | /* |
| 4774 | * Decode LOOKUP_ROOT response |
| 4775 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4776 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4777 | { |
| 4778 | struct xdr_stream xdr; |
| 4779 | struct compound_hdr hdr; |
| 4780 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4781 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4782 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4783 | status = decode_compound_hdr(&xdr, &hdr); |
| 4784 | if (status) |
| 4785 | goto out; |
| 4786 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4787 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4788 | goto out; |
| 4789 | if ((status = decode_putrootfh(&xdr)) != 0) |
| 4790 | goto out; |
| 4791 | if ((status = decode_getfh(&xdr, res->fh)) == 0) |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4792 | status = decode_getfattr(&xdr, res->fattr, res->server, |
| 4793 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4794 | out: |
| 4795 | return status; |
| 4796 | } |
| 4797 | |
| 4798 | /* |
| 4799 | * Decode REMOVE response |
| 4800 | */ |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 4801 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4802 | { |
| 4803 | struct xdr_stream xdr; |
| 4804 | struct compound_hdr hdr; |
| 4805 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4806 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4807 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4808 | status = decode_compound_hdr(&xdr, &hdr); |
| 4809 | if (status) |
| 4810 | goto out; |
| 4811 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4812 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4813 | goto out; |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 4814 | if ((status = decode_putfh(&xdr)) != 0) |
| 4815 | goto out; |
| 4816 | if ((status = decode_remove(&xdr, &res->cinfo)) != 0) |
| 4817 | goto out; |
Trond Myklebust | d346890 | 2010-04-16 16:22:50 -0400 | [diff] [blame] | 4818 | decode_getfattr(&xdr, res->dir_attr, res->server, |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4819 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4820 | out: |
| 4821 | return status; |
| 4822 | } |
| 4823 | |
| 4824 | /* |
| 4825 | * Decode RENAME response |
| 4826 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4827 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_rename_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4828 | { |
| 4829 | struct xdr_stream xdr; |
| 4830 | struct compound_hdr hdr; |
| 4831 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4832 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4833 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4834 | status = decode_compound_hdr(&xdr, &hdr); |
| 4835 | if (status) |
| 4836 | goto out; |
| 4837 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4838 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4839 | goto out; |
| 4840 | if ((status = decode_putfh(&xdr)) != 0) |
| 4841 | goto out; |
| 4842 | if ((status = decode_savefh(&xdr)) != 0) |
| 4843 | goto out; |
| 4844 | if ((status = decode_putfh(&xdr)) != 0) |
| 4845 | goto out; |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 4846 | if ((status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo)) != 0) |
| 4847 | goto out; |
| 4848 | /* Current FH is target directory */ |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4849 | if (decode_getfattr(&xdr, res->new_fattr, res->server, |
| 4850 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 4851 | goto out; |
| 4852 | if ((status = decode_restorefh(&xdr)) != 0) |
| 4853 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4854 | decode_getfattr(&xdr, res->old_fattr, res->server, |
| 4855 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4856 | out: |
| 4857 | return status; |
| 4858 | } |
| 4859 | |
| 4860 | /* |
| 4861 | * Decode LINK response |
| 4862 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4863 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4864 | { |
| 4865 | struct xdr_stream xdr; |
| 4866 | struct compound_hdr hdr; |
| 4867 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4868 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4869 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4870 | status = decode_compound_hdr(&xdr, &hdr); |
| 4871 | if (status) |
| 4872 | goto out; |
| 4873 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4874 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4875 | goto out; |
| 4876 | if ((status = decode_putfh(&xdr)) != 0) |
| 4877 | goto out; |
| 4878 | if ((status = decode_savefh(&xdr)) != 0) |
| 4879 | goto out; |
| 4880 | if ((status = decode_putfh(&xdr)) != 0) |
| 4881 | goto out; |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 4882 | if ((status = decode_link(&xdr, &res->cinfo)) != 0) |
| 4883 | goto out; |
| 4884 | /* |
| 4885 | * Note order: OP_LINK leaves the directory as the current |
| 4886 | * filehandle. |
| 4887 | */ |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4888 | if (decode_getfattr(&xdr, res->dir_attr, res->server, |
| 4889 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 4890 | goto out; |
| 4891 | if ((status = decode_restorefh(&xdr)) != 0) |
| 4892 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4893 | decode_getfattr(&xdr, res->fattr, res->server, |
| 4894 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4895 | out: |
| 4896 | return status; |
| 4897 | } |
| 4898 | |
| 4899 | /* |
| 4900 | * Decode CREATE response |
| 4901 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4902 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4903 | { |
| 4904 | struct xdr_stream xdr; |
| 4905 | struct compound_hdr hdr; |
| 4906 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4907 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4908 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4909 | status = decode_compound_hdr(&xdr, &hdr); |
| 4910 | if (status) |
| 4911 | goto out; |
| 4912 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4913 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4914 | goto out; |
| 4915 | if ((status = decode_putfh(&xdr)) != 0) |
| 4916 | goto out; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4917 | if ((status = decode_savefh(&xdr)) != 0) |
| 4918 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4919 | if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0) |
| 4920 | goto out; |
| 4921 | if ((status = decode_getfh(&xdr, res->fh)) != 0) |
| 4922 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4923 | if (decode_getfattr(&xdr, res->fattr, res->server, |
| 4924 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4925 | goto out; |
| 4926 | if ((status = decode_restorefh(&xdr)) != 0) |
| 4927 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4928 | decode_getfattr(&xdr, res->dir_fattr, res->server, |
| 4929 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4930 | out: |
| 4931 | return status; |
| 4932 | } |
| 4933 | |
| 4934 | /* |
| 4935 | * Decode SYMLINK response |
| 4936 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4937 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4938 | { |
| 4939 | return nfs4_xdr_dec_create(rqstp, p, res); |
| 4940 | } |
| 4941 | |
| 4942 | /* |
| 4943 | * Decode GETATTR response |
| 4944 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4945 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4946 | { |
| 4947 | struct xdr_stream xdr; |
| 4948 | struct compound_hdr hdr; |
| 4949 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4951 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 4952 | status = decode_compound_hdr(&xdr, &hdr); |
| 4953 | if (status) |
| 4954 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4955 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 4956 | if (status) |
| 4957 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4958 | status = decode_putfh(&xdr); |
| 4959 | if (status) |
| 4960 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4961 | status = decode_getfattr(&xdr, res->fattr, res->server, |
| 4962 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4963 | out: |
| 4964 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4965 | } |
| 4966 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4967 | /* |
| 4968 | * Encode an SETACL request |
| 4969 | */ |
| 4970 | static int |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4971 | nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4972 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4973 | struct xdr_stream xdr; |
| 4974 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 4975 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4976 | }; |
| 4977 | int status; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4978 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4979 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 4980 | encode_compound_hdr(&xdr, req, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 4981 | encode_sequence(&xdr, &args->seq_args, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 4982 | encode_putfh(&xdr, args->fh, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 4983 | status = encode_setacl(&xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 4984 | encode_nops(&hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4985 | return status; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4986 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4987 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4988 | /* |
| 4989 | * Decode SETACL response |
| 4990 | */ |
| 4991 | static int |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 4992 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, __be32 *p, |
| 4993 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4994 | { |
| 4995 | struct xdr_stream xdr; |
| 4996 | struct compound_hdr hdr; |
| 4997 | int status; |
| 4998 | |
| 4999 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5000 | status = decode_compound_hdr(&xdr, &hdr); |
| 5001 | if (status) |
| 5002 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5003 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5004 | if (status) |
| 5005 | goto out; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5006 | status = decode_putfh(&xdr); |
| 5007 | if (status) |
| 5008 | goto out; |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5009 | status = decode_setattr(&xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5010 | out: |
| 5011 | return status; |
| 5012 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5013 | |
| 5014 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5015 | * Decode GETACL response |
| 5016 | */ |
| 5017 | static int |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 5018 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, __be32 *p, |
| 5019 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5020 | { |
| 5021 | struct xdr_stream xdr; |
| 5022 | struct compound_hdr hdr; |
| 5023 | int status; |
| 5024 | |
| 5025 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5026 | status = decode_compound_hdr(&xdr, &hdr); |
| 5027 | if (status) |
| 5028 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5029 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5030 | if (status) |
| 5031 | goto out; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5032 | status = decode_putfh(&xdr); |
| 5033 | if (status) |
| 5034 | goto out; |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 5035 | status = decode_getacl(&xdr, rqstp, &res->acl_len); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5036 | |
| 5037 | out: |
| 5038 | return status; |
| 5039 | } |
| 5040 | |
| 5041 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5042 | * Decode CLOSE response |
| 5043 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5044 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5045 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5046 | struct xdr_stream xdr; |
| 5047 | struct compound_hdr hdr; |
| 5048 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5049 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5050 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5051 | status = decode_compound_hdr(&xdr, &hdr); |
| 5052 | if (status) |
| 5053 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5054 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5055 | if (status) |
| 5056 | goto out; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5057 | status = decode_putfh(&xdr); |
| 5058 | if (status) |
| 5059 | goto out; |
| 5060 | status = decode_close(&xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5061 | if (status != 0) |
| 5062 | goto out; |
| 5063 | /* |
| 5064 | * Note: Server may do delete on close for this file |
| 5065 | * in which case the getattr call will fail with |
| 5066 | * an ESTALE error. Shouldn't be a problem, |
| 5067 | * though, since fattr->valid will remain unset. |
| 5068 | */ |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5069 | decode_getfattr(&xdr, res->fattr, res->server, |
| 5070 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5071 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5072 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | } |
| 5074 | |
| 5075 | /* |
| 5076 | * Decode OPEN response |
| 5077 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5078 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5079 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5080 | struct xdr_stream xdr; |
| 5081 | struct compound_hdr hdr; |
| 5082 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5083 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5084 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5085 | status = decode_compound_hdr(&xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5086 | if (status) |
| 5087 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5088 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5089 | if (status) |
| 5090 | goto out; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5091 | status = decode_putfh(&xdr); |
| 5092 | if (status) |
| 5093 | goto out; |
| 5094 | status = decode_savefh(&xdr); |
| 5095 | if (status) |
| 5096 | goto out; |
| 5097 | status = decode_open(&xdr, res); |
| 5098 | if (status) |
| 5099 | goto out; |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 5100 | if (decode_getfh(&xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5101 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5102 | if (decode_getfattr(&xdr, res->f_attr, res->server, |
| 5103 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5104 | goto out; |
Trond Myklebust | 365c8f5 | 2007-07-17 21:52:37 -0400 | [diff] [blame] | 5105 | if (decode_restorefh(&xdr) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5106 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5107 | decode_getfattr(&xdr, res->dir_attr, res->server, |
| 5108 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5109 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5110 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5111 | } |
| 5112 | |
| 5113 | /* |
| 5114 | * Decode OPEN_CONFIRM response |
| 5115 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5116 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, __be32 *p, struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5117 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5118 | struct xdr_stream xdr; |
| 5119 | struct compound_hdr hdr; |
| 5120 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5121 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5122 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5123 | status = decode_compound_hdr(&xdr, &hdr); |
| 5124 | if (status) |
| 5125 | goto out; |
| 5126 | status = decode_putfh(&xdr); |
| 5127 | if (status) |
| 5128 | goto out; |
| 5129 | status = decode_open_confirm(&xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5130 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5131 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5132 | } |
| 5133 | |
| 5134 | /* |
| 5135 | * Decode OPEN response |
| 5136 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5137 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5138 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5139 | struct xdr_stream xdr; |
| 5140 | struct compound_hdr hdr; |
| 5141 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5142 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5143 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5144 | status = decode_compound_hdr(&xdr, &hdr); |
| 5145 | if (status) |
| 5146 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5147 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5148 | if (status) |
| 5149 | goto out; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5150 | status = decode_putfh(&xdr); |
| 5151 | if (status) |
| 5152 | goto out; |
| 5153 | status = decode_open(&xdr, res); |
| 5154 | if (status) |
| 5155 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5156 | decode_getfattr(&xdr, res->f_attr, res->server, |
| 5157 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5158 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5159 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5160 | } |
| 5161 | |
| 5162 | /* |
| 5163 | * Decode SETATTR response |
| 5164 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5165 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5166 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5167 | struct xdr_stream xdr; |
| 5168 | struct compound_hdr hdr; |
| 5169 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5170 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5171 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5172 | status = decode_compound_hdr(&xdr, &hdr); |
| 5173 | if (status) |
| 5174 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5175 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5176 | if (status) |
| 5177 | goto out; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5178 | status = decode_putfh(&xdr); |
| 5179 | if (status) |
| 5180 | goto out; |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5181 | status = decode_setattr(&xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5182 | if (status) |
| 5183 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5184 | decode_getfattr(&xdr, res->fattr, res->server, |
| 5185 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5186 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5187 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5188 | } |
| 5189 | |
| 5190 | /* |
| 5191 | * Decode LOCK response |
| 5192 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5193 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5194 | { |
| 5195 | struct xdr_stream xdr; |
| 5196 | struct compound_hdr hdr; |
| 5197 | int status; |
| 5198 | |
| 5199 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5200 | status = decode_compound_hdr(&xdr, &hdr); |
| 5201 | if (status) |
| 5202 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5203 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5204 | if (status) |
| 5205 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5206 | status = decode_putfh(&xdr); |
| 5207 | if (status) |
| 5208 | goto out; |
| 5209 | status = decode_lock(&xdr, res); |
| 5210 | out: |
| 5211 | return status; |
| 5212 | } |
| 5213 | |
| 5214 | /* |
| 5215 | * Decode LOCKT response |
| 5216 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5217 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5218 | { |
| 5219 | struct xdr_stream xdr; |
| 5220 | struct compound_hdr hdr; |
| 5221 | int status; |
| 5222 | |
| 5223 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5224 | status = decode_compound_hdr(&xdr, &hdr); |
| 5225 | if (status) |
| 5226 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5227 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5228 | if (status) |
| 5229 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | status = decode_putfh(&xdr); |
| 5231 | if (status) |
| 5232 | goto out; |
| 5233 | status = decode_lockt(&xdr, res); |
| 5234 | out: |
| 5235 | return status; |
| 5236 | } |
| 5237 | |
| 5238 | /* |
| 5239 | * Decode LOCKU response |
| 5240 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5241 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, __be32 *p, struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5242 | { |
| 5243 | struct xdr_stream xdr; |
| 5244 | struct compound_hdr hdr; |
| 5245 | int status; |
| 5246 | |
| 5247 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5248 | status = decode_compound_hdr(&xdr, &hdr); |
| 5249 | if (status) |
| 5250 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5251 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5252 | if (status) |
| 5253 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5254 | status = decode_putfh(&xdr); |
| 5255 | if (status) |
| 5256 | goto out; |
| 5257 | status = decode_locku(&xdr, res); |
| 5258 | out: |
| 5259 | return status; |
| 5260 | } |
| 5261 | |
| 5262 | /* |
| 5263 | * Decode READLINK response |
| 5264 | */ |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 5265 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, __be32 *p, |
| 5266 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | { |
| 5268 | struct xdr_stream xdr; |
| 5269 | struct compound_hdr hdr; |
| 5270 | int status; |
| 5271 | |
| 5272 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5273 | status = decode_compound_hdr(&xdr, &hdr); |
| 5274 | if (status) |
| 5275 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5276 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5277 | if (status) |
| 5278 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5279 | status = decode_putfh(&xdr); |
| 5280 | if (status) |
| 5281 | goto out; |
| 5282 | status = decode_readlink(&xdr, rqstp); |
| 5283 | out: |
| 5284 | return status; |
| 5285 | } |
| 5286 | |
| 5287 | /* |
| 5288 | * Decode READDIR response |
| 5289 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5290 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5291 | { |
| 5292 | struct xdr_stream xdr; |
| 5293 | struct compound_hdr hdr; |
| 5294 | int status; |
| 5295 | |
| 5296 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5297 | status = decode_compound_hdr(&xdr, &hdr); |
| 5298 | if (status) |
| 5299 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5300 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5301 | if (status) |
| 5302 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5303 | status = decode_putfh(&xdr); |
| 5304 | if (status) |
| 5305 | goto out; |
| 5306 | status = decode_readdir(&xdr, rqstp, res); |
| 5307 | out: |
| 5308 | return status; |
| 5309 | } |
| 5310 | |
| 5311 | /* |
| 5312 | * Decode Read response |
| 5313 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5314 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5315 | { |
| 5316 | struct xdr_stream xdr; |
| 5317 | struct compound_hdr hdr; |
| 5318 | int status; |
| 5319 | |
| 5320 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5321 | status = decode_compound_hdr(&xdr, &hdr); |
| 5322 | if (status) |
| 5323 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5324 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5325 | if (status) |
| 5326 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | status = decode_putfh(&xdr); |
| 5328 | if (status) |
| 5329 | goto out; |
| 5330 | status = decode_read(&xdr, rqstp, res); |
| 5331 | if (!status) |
| 5332 | status = res->count; |
| 5333 | out: |
| 5334 | return status; |
| 5335 | } |
| 5336 | |
| 5337 | /* |
| 5338 | * Decode WRITE response |
| 5339 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5340 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5341 | { |
| 5342 | struct xdr_stream xdr; |
| 5343 | struct compound_hdr hdr; |
| 5344 | int status; |
| 5345 | |
| 5346 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5347 | status = decode_compound_hdr(&xdr, &hdr); |
| 5348 | if (status) |
| 5349 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5350 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5351 | if (status) |
| 5352 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5353 | status = decode_putfh(&xdr); |
| 5354 | if (status) |
| 5355 | goto out; |
| 5356 | status = decode_write(&xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5357 | if (status) |
| 5358 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5359 | decode_getfattr(&xdr, res->fattr, res->server, |
| 5360 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5361 | if (!status) |
| 5362 | status = res->count; |
| 5363 | out: |
| 5364 | return status; |
| 5365 | } |
| 5366 | |
| 5367 | /* |
| 5368 | * Decode COMMIT response |
| 5369 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5370 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5371 | { |
| 5372 | struct xdr_stream xdr; |
| 5373 | struct compound_hdr hdr; |
| 5374 | int status; |
| 5375 | |
| 5376 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5377 | status = decode_compound_hdr(&xdr, &hdr); |
| 5378 | if (status) |
| 5379 | goto out; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5380 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5381 | if (status) |
| 5382 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5383 | status = decode_putfh(&xdr); |
| 5384 | if (status) |
| 5385 | goto out; |
| 5386 | status = decode_commit(&xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5387 | if (status) |
| 5388 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5389 | decode_getfattr(&xdr, res->fattr, res->server, |
| 5390 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5391 | out: |
| 5392 | return status; |
| 5393 | } |
| 5394 | |
| 5395 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5396 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5397 | */ |
Benny Halevy | 3dda5e4 | 2009-04-01 09:21:57 -0400 | [diff] [blame] | 5398 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, |
| 5399 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5400 | { |
| 5401 | struct xdr_stream xdr; |
| 5402 | struct compound_hdr hdr; |
| 5403 | int status; |
| 5404 | |
| 5405 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5406 | status = decode_compound_hdr(&xdr, &hdr); |
| 5407 | if (!status) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5408 | status = decode_sequence(&xdr, &res->seq_res, req); |
| 5409 | if (!status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5410 | status = decode_putfh(&xdr); |
| 5411 | if (!status) |
Benny Halevy | 3dda5e4 | 2009-04-01 09:21:57 -0400 | [diff] [blame] | 5412 | status = decode_fsinfo(&xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5413 | return status; |
| 5414 | } |
| 5415 | |
| 5416 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5417 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5418 | */ |
Benny Halevy | d45b298 | 2009-04-01 09:21:58 -0400 | [diff] [blame] | 5419 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, |
| 5420 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5421 | { |
| 5422 | struct xdr_stream xdr; |
| 5423 | struct compound_hdr hdr; |
| 5424 | int status; |
| 5425 | |
| 5426 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5427 | status = decode_compound_hdr(&xdr, &hdr); |
| 5428 | if (!status) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5429 | status = decode_sequence(&xdr, &res->seq_res, req); |
| 5430 | if (!status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5431 | status = decode_putfh(&xdr); |
| 5432 | if (!status) |
Benny Halevy | d45b298 | 2009-04-01 09:21:58 -0400 | [diff] [blame] | 5433 | status = decode_pathconf(&xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5434 | return status; |
| 5435 | } |
| 5436 | |
| 5437 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5438 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5439 | */ |
Benny Halevy | 24ad148 | 2009-04-01 09:21:56 -0400 | [diff] [blame] | 5440 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, |
| 5441 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5442 | { |
| 5443 | struct xdr_stream xdr; |
| 5444 | struct compound_hdr hdr; |
| 5445 | int status; |
| 5446 | |
| 5447 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5448 | status = decode_compound_hdr(&xdr, &hdr); |
| 5449 | if (!status) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5450 | status = decode_sequence(&xdr, &res->seq_res, req); |
| 5451 | if (!status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5452 | status = decode_putfh(&xdr); |
| 5453 | if (!status) |
Benny Halevy | 24ad148 | 2009-04-01 09:21:56 -0400 | [diff] [blame] | 5454 | status = decode_statfs(&xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5455 | return status; |
| 5456 | } |
| 5457 | |
| 5458 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5459 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5460 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5461 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5462 | { |
| 5463 | struct xdr_stream xdr; |
| 5464 | struct compound_hdr hdr; |
| 5465 | int status; |
| 5466 | |
| 5467 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5468 | status = decode_compound_hdr(&xdr, &hdr); |
| 5469 | if (status) |
| 5470 | goto out; |
| 5471 | status = decode_sequence(&xdr, &res->seq_res, req); |
| 5472 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5473 | goto out; |
| 5474 | if ((status = decode_putfh(&xdr)) != 0) |
| 5475 | goto out; |
| 5476 | status = decode_server_caps(&xdr, res); |
| 5477 | out: |
| 5478 | return status; |
| 5479 | } |
| 5480 | |
| 5481 | /* |
| 5482 | * Decode RENEW response |
| 5483 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5484 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5485 | { |
| 5486 | struct xdr_stream xdr; |
| 5487 | struct compound_hdr hdr; |
| 5488 | int status; |
| 5489 | |
| 5490 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5491 | status = decode_compound_hdr(&xdr, &hdr); |
| 5492 | if (!status) |
| 5493 | status = decode_renew(&xdr); |
| 5494 | return status; |
| 5495 | } |
| 5496 | |
| 5497 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5498 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5499 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5500 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5501 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5502 | { |
| 5503 | struct xdr_stream xdr; |
| 5504 | struct compound_hdr hdr; |
| 5505 | int status; |
| 5506 | |
| 5507 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5508 | status = decode_compound_hdr(&xdr, &hdr); |
| 5509 | if (!status) |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5510 | status = decode_setclientid(&xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5511 | return status; |
| 5512 | } |
| 5513 | |
| 5514 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5515 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5516 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5517 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5518 | { |
| 5519 | struct xdr_stream xdr; |
| 5520 | struct compound_hdr hdr; |
| 5521 | int status; |
| 5522 | |
| 5523 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5524 | status = decode_compound_hdr(&xdr, &hdr); |
| 5525 | if (!status) |
| 5526 | status = decode_setclientid_confirm(&xdr); |
| 5527 | if (!status) |
| 5528 | status = decode_putrootfh(&xdr); |
| 5529 | if (!status) |
| 5530 | status = decode_fsinfo(&xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5531 | return status; |
| 5532 | } |
| 5533 | |
| 5534 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5535 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5536 | */ |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5537 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5538 | { |
| 5539 | struct xdr_stream xdr; |
| 5540 | struct compound_hdr hdr; |
| 5541 | int status; |
| 5542 | |
| 5543 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5544 | status = decode_compound_hdr(&xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5545 | if (status) |
| 5546 | goto out; |
| 5547 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5548 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 5549 | goto out; |
| 5550 | status = decode_putfh(&xdr); |
| 5551 | if (status != 0) |
| 5552 | goto out; |
| 5553 | status = decode_delegreturn(&xdr); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 5554 | if (status != 0) |
| 5555 | goto out; |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5556 | decode_getfattr(&xdr, res->fattr, res->server, |
| 5557 | !RPC_IS_ASYNC(rqstp->rq_task)); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 5558 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5559 | return status; |
| 5560 | } |
| 5561 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5562 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5563 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5564 | */ |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 5565 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, |
| 5566 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5567 | { |
| 5568 | struct xdr_stream xdr; |
| 5569 | struct compound_hdr hdr; |
| 5570 | int status; |
| 5571 | |
| 5572 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
| 5573 | status = decode_compound_hdr(&xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5574 | if (status) |
| 5575 | goto out; |
| 5576 | status = decode_sequence(&xdr, &res->seq_res, req); |
| 5577 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5578 | goto out; |
| 5579 | if ((status = decode_putfh(&xdr)) != 0) |
| 5580 | goto out; |
| 5581 | if ((status = decode_lookup(&xdr)) != 0) |
| 5582 | goto out; |
| 5583 | xdr_enter_page(&xdr, PAGE_SIZE); |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 5584 | status = decode_getfattr(&xdr, &res->fs_locations->fattr, |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 5585 | res->fs_locations->server, |
| 5586 | !RPC_IS_ASYNC(req->rq_task)); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5587 | out: |
| 5588 | return status; |
| 5589 | } |
| 5590 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5591 | #if defined(CONFIG_NFS_V4_1) |
| 5592 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5593 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5594 | */ |
| 5595 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, |
| 5596 | void *res) |
| 5597 | { |
| 5598 | struct xdr_stream xdr; |
| 5599 | struct compound_hdr hdr; |
| 5600 | int status; |
| 5601 | |
| 5602 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5603 | status = decode_compound_hdr(&xdr, &hdr); |
| 5604 | if (!status) |
| 5605 | status = decode_exchange_id(&xdr, res); |
| 5606 | return status; |
| 5607 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 5608 | |
| 5609 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5610 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5611 | */ |
| 5612 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, |
| 5613 | struct nfs41_create_session_res *res) |
| 5614 | { |
| 5615 | struct xdr_stream xdr; |
| 5616 | struct compound_hdr hdr; |
| 5617 | int status; |
| 5618 | |
| 5619 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5620 | status = decode_compound_hdr(&xdr, &hdr); |
| 5621 | if (!status) |
| 5622 | status = decode_create_session(&xdr, res); |
| 5623 | return status; |
| 5624 | } |
| 5625 | |
| 5626 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5627 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5628 | */ |
| 5629 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, |
| 5630 | void *dummy) |
| 5631 | { |
| 5632 | struct xdr_stream xdr; |
| 5633 | struct compound_hdr hdr; |
| 5634 | int status; |
| 5635 | |
| 5636 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5637 | status = decode_compound_hdr(&xdr, &hdr); |
| 5638 | if (!status) |
| 5639 | status = decode_destroy_session(&xdr, dummy); |
| 5640 | return status; |
| 5641 | } |
| 5642 | |
| 5643 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5644 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5645 | */ |
| 5646 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, |
| 5647 | struct nfs4_sequence_res *res) |
| 5648 | { |
| 5649 | struct xdr_stream xdr; |
| 5650 | struct compound_hdr hdr; |
| 5651 | int status; |
| 5652 | |
| 5653 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5654 | status = decode_compound_hdr(&xdr, &hdr); |
| 5655 | if (!status) |
| 5656 | status = decode_sequence(&xdr, res, rqstp); |
| 5657 | return status; |
| 5658 | } |
| 5659 | |
| 5660 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 5661 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 5662 | */ |
| 5663 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, |
| 5664 | struct nfs4_get_lease_time_res *res) |
| 5665 | { |
| 5666 | struct xdr_stream xdr; |
| 5667 | struct compound_hdr hdr; |
| 5668 | int status; |
| 5669 | |
| 5670 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5671 | status = decode_compound_hdr(&xdr, &hdr); |
| 5672 | if (!status) |
| 5673 | status = decode_sequence(&xdr, &res->lr_seq_res, rqstp); |
| 5674 | if (!status) |
| 5675 | status = decode_putrootfh(&xdr); |
| 5676 | if (!status) |
| 5677 | status = decode_fsinfo(&xdr, res->lr_fsinfo); |
| 5678 | return status; |
| 5679 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5680 | |
| 5681 | /* |
| 5682 | * Decode RECLAIM_COMPLETE response |
| 5683 | */ |
| 5684 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p, |
| 5685 | struct nfs41_reclaim_complete_res *res) |
| 5686 | { |
| 5687 | struct xdr_stream xdr; |
| 5688 | struct compound_hdr hdr; |
| 5689 | int status; |
| 5690 | |
| 5691 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 5692 | status = decode_compound_hdr(&xdr, &hdr); |
| 5693 | if (!status) |
| 5694 | status = decode_sequence(&xdr, &res->seq_res, rqstp); |
| 5695 | if (!status) |
| 5696 | status = decode_reclaim_complete(&xdr, (void *)NULL); |
| 5697 | return status; |
| 5698 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5699 | #endif /* CONFIG_NFS_V4_1 */ |
| 5700 | |
Al Viro | 0dbb4c6 | 2006-10-19 23:28:49 -0700 | [diff] [blame] | 5701 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5702 | { |
| 5703 | uint32_t bitmap[2] = {0}; |
| 5704 | uint32_t len; |
| 5705 | |
| 5706 | if (!*p++) { |
| 5707 | if (!*p) |
| 5708 | return ERR_PTR(-EAGAIN); |
| 5709 | entry->eof = 1; |
| 5710 | return ERR_PTR(-EBADCOOKIE); |
| 5711 | } |
| 5712 | |
| 5713 | entry->prev_cookie = entry->cookie; |
| 5714 | p = xdr_decode_hyper(p, &entry->cookie); |
| 5715 | entry->len = ntohl(*p++); |
| 5716 | entry->name = (const char *) p; |
| 5717 | p += XDR_QUADLEN(entry->len); |
| 5718 | |
| 5719 | /* |
| 5720 | * In case the server doesn't return an inode number, |
| 5721 | * we fake one here. (We don't use inode number 0, |
| 5722 | * since glibc seems to choke on it...) |
| 5723 | */ |
| 5724 | entry->ino = 1; |
| 5725 | |
| 5726 | len = ntohl(*p++); /* bitmap length */ |
| 5727 | if (len-- > 0) { |
| 5728 | bitmap[0] = ntohl(*p++); |
| 5729 | if (len-- > 0) { |
| 5730 | bitmap[1] = ntohl(*p++); |
| 5731 | p += len; |
| 5732 | } |
| 5733 | } |
| 5734 | len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */ |
| 5735 | if (len > 0) { |
Manoj Naik | 97d312d | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 5736 | if (bitmap[0] & FATTR4_WORD0_RDATTR_ERROR) { |
| 5737 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
| 5738 | /* Ignore the return value of rdattr_error for now */ |
| 5739 | p++; |
| 5740 | len--; |
| 5741 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5742 | if (bitmap[0] == 0 && bitmap[1] == FATTR4_WORD1_MOUNTED_ON_FILEID) |
| 5743 | xdr_decode_hyper(p, &entry->ino); |
| 5744 | else if (bitmap[0] == FATTR4_WORD0_FILEID) |
| 5745 | xdr_decode_hyper(p, &entry->ino); |
| 5746 | p += len; |
| 5747 | } |
| 5748 | |
| 5749 | entry->eof = !p[0] && p[1]; |
| 5750 | return p; |
| 5751 | } |
| 5752 | |
| 5753 | /* |
| 5754 | * We need to translate between nfs status return values and |
| 5755 | * the local errno values which may not be the same. |
| 5756 | */ |
| 5757 | static struct { |
| 5758 | int stat; |
| 5759 | int errno; |
| 5760 | } nfs_errtbl[] = { |
| 5761 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5762 | { NFS4ERR_PERM, -EPERM }, |
| 5763 | { NFS4ERR_NOENT, -ENOENT }, |
| 5764 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 5765 | { NFS4ERR_NXIO, -ENXIO }, |
| 5766 | { NFS4ERR_ACCESS, -EACCES }, |
| 5767 | { NFS4ERR_EXIST, -EEXIST }, |
| 5768 | { NFS4ERR_XDEV, -EXDEV }, |
| 5769 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 5770 | { NFS4ERR_ISDIR, -EISDIR }, |
| 5771 | { NFS4ERR_INVAL, -EINVAL }, |
| 5772 | { NFS4ERR_FBIG, -EFBIG }, |
| 5773 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 5774 | { NFS4ERR_ROFS, -EROFS }, |
| 5775 | { NFS4ERR_MLINK, -EMLINK }, |
| 5776 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 5777 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 5778 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 5779 | { NFS4ERR_STALE, -ESTALE }, |
| 5780 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
| 5781 | { NFS4ERR_BADOWNER, -EINVAL }, |
| 5782 | { NFS4ERR_BADNAME, -EINVAL }, |
| 5783 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 5784 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 5785 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5786 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5787 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 5788 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5789 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 5790 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 5791 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
| 5792 | { NFS4ERR_WRONGSEC, -EPERM }, /* FIXME: this needs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5793 | * to be handled by a |
| 5794 | * middle-layer. |
| 5795 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5796 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5797 | }; |
| 5798 | |
| 5799 | /* |
| 5800 | * Convert an NFS error code to a local one. |
| 5801 | * This one is used jointly by NFSv2 and NFSv3. |
| 5802 | */ |
| 5803 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 5804 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5805 | { |
| 5806 | int i; |
| 5807 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 5808 | if (nfs_errtbl[i].stat == stat) |
| 5809 | return nfs_errtbl[i].errno; |
| 5810 | } |
| 5811 | if (stat <= 10000 || stat > 10100) { |
| 5812 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5813 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5814 | } |
| 5815 | /* If we cannot translate the error, the recovery routines should |
| 5816 | * handle it. |
| 5817 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 5818 | * not conflict with native Linux error codes. |
| 5819 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5820 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5821 | } |
| 5822 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5823 | #define PROC(proc, argtype, restype) \ |
| 5824 | [NFSPROC4_CLNT_##proc] = { \ |
| 5825 | .p_proc = NFSPROC4_COMPOUND, \ |
| 5826 | .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ |
| 5827 | .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 5828 | .p_arglen = NFS4_##argtype##_sz, \ |
| 5829 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 5830 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 5831 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5832 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5833 | |
| 5834 | struct rpc_procinfo nfs4_procedures[] = { |
| 5835 | PROC(READ, enc_read, dec_read), |
| 5836 | PROC(WRITE, enc_write, dec_write), |
| 5837 | PROC(COMMIT, enc_commit, dec_commit), |
| 5838 | PROC(OPEN, enc_open, dec_open), |
| 5839 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 5840 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 5841 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 5842 | PROC(CLOSE, enc_close, dec_close), |
| 5843 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 5844 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 5845 | PROC(RENEW, enc_renew, dec_renew), |
| 5846 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 5847 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 5848 | PROC(LOCK, enc_lock, dec_lock), |
| 5849 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 5850 | PROC(LOCKU, enc_locku, dec_locku), |
| 5851 | PROC(ACCESS, enc_access, dec_access), |
| 5852 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 5853 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 5854 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 5855 | PROC(REMOVE, enc_remove, dec_remove), |
| 5856 | PROC(RENAME, enc_rename, dec_rename), |
| 5857 | PROC(LINK, enc_link, dec_link), |
| 5858 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 5859 | PROC(CREATE, enc_create, dec_create), |
| 5860 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 5861 | PROC(STATFS, enc_statfs, dec_statfs), |
| 5862 | PROC(READLINK, enc_readlink, dec_readlink), |
| 5863 | PROC(READDIR, enc_readdir, dec_readdir), |
| 5864 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 5865 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5866 | PROC(GETACL, enc_getacl, dec_getacl), |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5867 | PROC(SETACL, enc_setacl, dec_setacl), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 5868 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5869 | #if defined(CONFIG_NFS_V4_1) |
| 5870 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5871 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5872 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5873 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 5874 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5875 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5876 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5877 | }; |
| 5878 | |
| 5879 | struct rpc_version nfs_version4 = { |
| 5880 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 5881 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5882 | .procs = nfs4_procedures |
| 5883 | }; |
| 5884 | |
| 5885 | /* |
| 5886 | * Local variables: |
| 5887 | * c-basic-offset: 8 |
| 5888 | * End: |
| 5889 | */ |