Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * fs/nfs/nfs4xdr.c |
| 3 | * |
| 4 | * Client-side XDR for NFSv4. |
| 5 | * |
| 6 | * Copyright (c) 2002 The Regents of the University of Michigan. |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Kendrick Smith <kmsmith@umich.edu> |
| 10 | * Andy Adamson <andros@umich.edu> |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * |
| 16 | * 1. Redistributions of source code must retain the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer. |
| 18 | * 2. Redistributions in binary form must reproduce the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer in the |
| 20 | * documentation and/or other materials provided with the distribution. |
| 21 | * 3. Neither the name of the University nor the names of its |
| 22 | * contributors may be used to endorse or promote products derived |
| 23 | * from this software without specific prior written permission. |
| 24 | * |
| 25 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 26 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 28 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ |
| 37 | |
| 38 | #include <linux/param.h> |
| 39 | #include <linux/time.h> |
| 40 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/errno.h> |
| 42 | #include <linux/string.h> |
| 43 | #include <linux/in.h> |
| 44 | #include <linux/pagemap.h> |
| 45 | #include <linux/proc_fs.h> |
| 46 | #include <linux/kdev_t.h> |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 47 | #include <linux/module.h> |
| 48 | #include <linux/utsname.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/sunrpc/clnt.h> |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 50 | #include <linux/sunrpc/msg_prot.h> |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 51 | #include <linux/sunrpc/gss_api.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/nfs.h> |
| 53 | #include <linux/nfs4.h> |
| 54 | #include <linux/nfs_fs.h> |
| 55 | #include <linux/nfs_idmap.h> |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 56 | |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 57 | #include "nfs4_fs.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 58 | #include "internal.h" |
Trond Myklebust | 76e697b | 2012-11-26 14:20:49 -0500 | [diff] [blame] | 59 | #include "nfs4session.h" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 60 | #include "pnfs.h" |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 61 | #include "netns.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 64 | |
| 65 | /* Mapping from NFS error code to "errno" error code. */ |
| 66 | #define errno_NFSERR_IO EIO |
| 67 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 68 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 71 | #ifdef DEBUG |
| 72 | #define NFS4_MAXTAGLEN 20 |
| 73 | #else |
| 74 | #define NFS4_MAXTAGLEN 0 |
| 75 | #endif |
| 76 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 77 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 78 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | */ |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 80 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 81 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 82 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 84 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 85 | #define op_encode_hdr_maxsz (1) |
| 86 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 87 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 88 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 89 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 90 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 92 | (NFS4_FHSIZE >> 2)) |
| 93 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 94 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 95 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 96 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 97 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 98 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 99 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 100 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 102 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 103 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 104 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 105 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
| 106 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ |
| 107 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 108 | #else |
| 109 | #define nfs4_label_maxsz 0 |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 110 | #endif |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 111 | /* We support only one layout type per file system */ |
| 112 | #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 113 | /* This is based on getfattr, which uses the most attributes: */ |
| 114 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 115 | 3 + 3 + 3 + nfs4_owner_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 116 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
| 117 | decode_mdsthreshold_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 118 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 119 | nfs4_fattr_value_maxsz) |
| 120 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 121 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 122 | 1 + 2 + 1 + \ |
| 123 | nfs4_owner_maxsz + \ |
| 124 | nfs4_group_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 125 | nfs4_label_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 126 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 128 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 129 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 130 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 131 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 132 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 133 | * layout types will be returned. |
| 134 | */ |
| 135 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 136 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 138 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 139 | #define encode_setclientid_maxsz \ |
| 140 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 141 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 142 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 143 | 1 /* sc_prog */ + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 144 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 145 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 146 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | #define decode_setclientid_maxsz \ |
| 148 | (op_decode_hdr_maxsz + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 149 | 2 /* clientid */ + \ |
| 150 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 151 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 152 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | #define encode_setclientid_confirm_maxsz \ |
| 154 | (op_encode_hdr_maxsz + \ |
| 155 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 156 | #define decode_setclientid_confirm_maxsz \ |
| 157 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 158 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 159 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 160 | #define encode_share_access_maxsz \ |
| 161 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 162 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 163 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 164 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 165 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 166 | 2 + encode_share_access_maxsz + 2 + \ |
| 167 | open_owner_id_maxsz + \ |
| 168 | encode_opentype_maxsz + \ |
| 169 | encode_claim_null_maxsz) |
| 170 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 171 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 172 | decode_ace_maxsz) |
| 173 | #define decode_change_info_maxsz (5) |
| 174 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 175 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 176 | decode_change_info_maxsz + 1 + \ |
| 177 | nfs4_fattr_bitmap_maxsz + \ |
| 178 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 179 | #define encode_open_confirm_maxsz \ |
| 180 | (op_encode_hdr_maxsz + \ |
| 181 | encode_stateid_maxsz + 1) |
| 182 | #define decode_open_confirm_maxsz \ |
| 183 | (op_decode_hdr_maxsz + \ |
| 184 | decode_stateid_maxsz) |
| 185 | #define encode_open_downgrade_maxsz \ |
| 186 | (op_encode_hdr_maxsz + \ |
| 187 | encode_stateid_maxsz + 1 + \ |
| 188 | encode_share_access_maxsz) |
| 189 | #define decode_open_downgrade_maxsz \ |
| 190 | (op_decode_hdr_maxsz + \ |
| 191 | decode_stateid_maxsz) |
| 192 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 193 | 1 + encode_stateid_maxsz) |
| 194 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 195 | decode_stateid_maxsz) |
| 196 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 197 | encode_stateid_maxsz + \ |
| 198 | encode_attrs_maxsz) |
| 199 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 200 | nfs4_fattr_bitmap_maxsz) |
| 201 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 202 | encode_stateid_maxsz + 3) |
| 203 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 204 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 205 | 2 + encode_verifier_maxsz + 5 + \ |
| 206 | nfs4_label_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 207 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
Chuck Lever | a7697f6 | 2014-03-12 12:51:17 -0400 | [diff] [blame] | 208 | decode_verifier_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 209 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 210 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 211 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 212 | encode_stateid_maxsz + 4) |
| 213 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 214 | 2 + decode_verifier_maxsz) |
| 215 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 216 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 217 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 219 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 220 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 221 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 223 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 224 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 225 | decode_change_info_maxsz + \ |
| 226 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 228 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 229 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 230 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 231 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 232 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 233 | 1 + encode_stateid_maxsz + 1 + \ |
| 234 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 235 | #define decode_lock_denied_maxsz \ |
| 236 | (8 + decode_lockowner_maxsz) |
| 237 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 238 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 239 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 240 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 241 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 242 | decode_lock_denied_maxsz) |
| 243 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 244 | encode_stateid_maxsz + \ |
| 245 | 4) |
| 246 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 247 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 248 | #define encode_release_lockowner_maxsz \ |
| 249 | (op_encode_hdr_maxsz + \ |
| 250 | encode_lockowner_maxsz) |
| 251 | #define decode_release_lockowner_maxsz \ |
| 252 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 253 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 254 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 256 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 257 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 258 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 260 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 261 | 1 + 2 + nfs4_name_maxsz + \ |
| 262 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 263 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 264 | decode_change_info_maxsz + \ |
| 265 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 266 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 267 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 269 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 270 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 271 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 272 | nfs4_fattr_bitmap_maxsz + 1) |
| 273 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 274 | encode_stateid_maxsz + 3) |
| 275 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 276 | #define encode_fs_locations_maxsz \ |
| 277 | (encode_getattr_maxsz) |
| 278 | #define decode_fs_locations_maxsz \ |
| 279 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 280 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 281 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 282 | |
| 283 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 284 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 285 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
| 286 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 287 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 288 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 289 | encode_verifier_maxsz + \ |
| 290 | 1 /* co_ownerid.len */ + \ |
| 291 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 292 | 1 /* flags */ + \ |
| 293 | 1 /* spa_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 294 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 295 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 296 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 297 | 1 /* implementation id array of size 1 */ + \ |
| 298 | 1 /* nii_domain */ + \ |
| 299 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 300 | 1 /* nii_name */ + \ |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 301 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 302 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 303 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 304 | 2 /* eir_clientid */ + \ |
| 305 | 1 /* eir_sequenceid */ + \ |
| 306 | 1 /* eir_flags */ + \ |
| 307 | 1 /* spr_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 308 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 309 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 310 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 311 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 312 | /* eir_server_owner.so_major_id<> */ \ |
| 313 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 314 | /* eir_server_scope<> */ \ |
| 315 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 316 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 317 | 1 /* nii_domain */ + \ |
| 318 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 319 | 1 /* nii_name */ + \ |
| 320 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 321 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 322 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 323 | #define decode_channel_attrs_maxsz (6 + \ |
| 324 | 1 /* ca_rdma_ird.len */ + \ |
| 325 | 1 /* ca_rdma_ird */) |
| 326 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 327 | 2 /* csa_clientid */ + \ |
| 328 | 1 /* csa_sequence */ + \ |
| 329 | 1 /* csa_flags */ + \ |
| 330 | encode_channel_attrs_maxsz + \ |
| 331 | encode_channel_attrs_maxsz + \ |
| 332 | 1 /* csa_cb_program */ + \ |
| 333 | 1 /* csa_sec_parms.len (1) */ + \ |
| 334 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 335 | 1 /* stamp */ + \ |
| 336 | 1 /* machinename.len */ + \ |
| 337 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 338 | 1 /* uid */ + \ |
| 339 | 1 /* gid */ + \ |
| 340 | 1 /* gids.len (0) */) |
| 341 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 342 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 343 | 1 /* csr_sequence */ + \ |
| 344 | 1 /* csr_flags */ + \ |
| 345 | decode_channel_attrs_maxsz + \ |
| 346 | decode_channel_attrs_maxsz) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 347 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
| 348 | /* bctsa_sessid */ \ |
| 349 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 350 | 1 /* bctsa_dir */ + \ |
| 351 | 1 /* bctsa_use_conn_in_rdma_mode */) |
| 352 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ |
| 353 | /* bctsr_sessid */ \ |
| 354 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 355 | 1 /* bctsr_dir */ + \ |
| 356 | 1 /* bctsr_use_conn_in_rdma_mode */) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 357 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 358 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 359 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
| 360 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 361 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 362 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 363 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 364 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 365 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 366 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 367 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
| 368 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ |
| 369 | 1 /* layout type */ + \ |
| 370 | 1 /* maxcount */ + \ |
| 371 | 1 /* bitmap size */ + \ |
| 372 | 1 /* notification bitmap length */ + \ |
| 373 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 374 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 375 | 1 /* layout type */ + \ |
| 376 | 1 /* opaque devaddr4 length */ + \ |
| 377 | /* devaddr4 payload is read into page */ \ |
| 378 | 1 /* notification bitmap length */ + \ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 379 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 380 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 381 | encode_stateid_maxsz) |
| 382 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 383 | decode_stateid_maxsz + \ |
| 384 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 385 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 386 | 2 /* offset */ + \ |
| 387 | 2 /* length */ + \ |
| 388 | 1 /* reclaim */ + \ |
| 389 | encode_stateid_maxsz + \ |
| 390 | 1 /* new offset (true) */ + \ |
| 391 | 2 /* last byte written */ + \ |
| 392 | 1 /* nt_timechanged (false) */ + \ |
| 393 | 1 /* layoutupdate4 layout type */ + \ |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 394 | 1 /* layoutupdate4 opaqueue len */) |
| 395 | /* the actual content of layoutupdate4 should |
| 396 | be allocated by drivers and spliced in |
| 397 | using xdr_write_pages */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 398 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 399 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 400 | encode_stateid_maxsz + \ |
| 401 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 402 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 403 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 404 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 405 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 406 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 407 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 408 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 409 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 410 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 411 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 412 | #else /* CONFIG_NFS_V4_1 */ |
| 413 | #define encode_sequence_maxsz 0 |
| 414 | #define decode_sequence_maxsz 0 |
| 415 | #endif /* CONFIG_NFS_V4_1 */ |
| 416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 418 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 419 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 420 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 422 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 424 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 426 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 428 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 430 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 432 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 434 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 436 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 438 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 440 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 442 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 444 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 446 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 447 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 449 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 451 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 452 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 454 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 456 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 458 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 460 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 462 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 463 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 464 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 465 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 466 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 467 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 469 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 470 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 471 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 472 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 473 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 474 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 475 | #define NFS4_enc_open_confirm_sz \ |
| 476 | (compound_encode_hdr_maxsz + \ |
| 477 | encode_putfh_maxsz + \ |
| 478 | encode_open_confirm_maxsz) |
| 479 | #define NFS4_dec_open_confirm_sz \ |
| 480 | (compound_decode_hdr_maxsz + \ |
| 481 | decode_putfh_maxsz + \ |
| 482 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 484 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 486 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 487 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 488 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 490 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 492 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 493 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 494 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | #define NFS4_enc_open_downgrade_sz \ |
| 496 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 497 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 498 | encode_putfh_maxsz + \ |
| 499 | encode_open_downgrade_maxsz + \ |
| 500 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | #define NFS4_dec_open_downgrade_sz \ |
| 502 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 503 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 504 | decode_putfh_maxsz + \ |
| 505 | decode_open_downgrade_maxsz + \ |
| 506 | decode_getattr_maxsz) |
| 507 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 508 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 509 | encode_putfh_maxsz + \ |
| 510 | encode_close_maxsz + \ |
| 511 | encode_getattr_maxsz) |
| 512 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 513 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 514 | decode_putfh_maxsz + \ |
| 515 | decode_close_maxsz + \ |
| 516 | decode_getattr_maxsz) |
| 517 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 518 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 519 | encode_putfh_maxsz + \ |
| 520 | encode_setattr_maxsz + \ |
| 521 | encode_getattr_maxsz) |
| 522 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 523 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 524 | decode_putfh_maxsz + \ |
| 525 | decode_setattr_maxsz + \ |
| 526 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 528 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | encode_putfh_maxsz + \ |
| 530 | encode_fsinfo_maxsz) |
| 531 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 532 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | decode_putfh_maxsz + \ |
| 534 | decode_fsinfo_maxsz) |
| 535 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 536 | encode_renew_maxsz) |
| 537 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 538 | decode_renew_maxsz) |
| 539 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 540 | encode_setclientid_maxsz) |
| 541 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 542 | decode_setclientid_maxsz) |
| 543 | #define NFS4_enc_setclientid_confirm_sz \ |
| 544 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 545 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | #define NFS4_dec_setclientid_confirm_sz \ |
| 547 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 548 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 550 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 552 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 554 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 556 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 558 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 560 | encode_lockt_maxsz) |
| 561 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 562 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 563 | decode_putfh_maxsz + \ |
| 564 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 566 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 568 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 570 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 572 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 573 | #define NFS4_enc_release_lockowner_sz \ |
| 574 | (compound_encode_hdr_maxsz + \ |
| 575 | encode_lockowner_maxsz) |
| 576 | #define NFS4_dec_release_lockowner_sz \ |
| 577 | (compound_decode_hdr_maxsz + \ |
| 578 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 580 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 582 | encode_access_maxsz + \ |
| 583 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 585 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 587 | decode_access_maxsz + \ |
| 588 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 590 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 592 | encode_getattr_maxsz + \ |
| 593 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | #define NFS4_dec_getattr_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 + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 597 | decode_getattr_maxsz + \ |
| 598 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 600 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | encode_putfh_maxsz + \ |
| 602 | encode_lookup_maxsz + \ |
| 603 | encode_getattr_maxsz + \ |
| 604 | encode_getfh_maxsz) |
| 605 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 606 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 608 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | decode_getattr_maxsz + \ |
| 610 | decode_getfh_maxsz) |
| 611 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 612 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | encode_putrootfh_maxsz + \ |
| 614 | encode_getattr_maxsz + \ |
| 615 | encode_getfh_maxsz) |
| 616 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 617 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | decode_putrootfh_maxsz + \ |
| 619 | decode_getattr_maxsz + \ |
| 620 | decode_getfh_maxsz) |
| 621 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 622 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 624 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 626 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 628 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 630 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | encode_putfh_maxsz + \ |
| 632 | encode_savefh_maxsz + \ |
| 633 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 634 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 636 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | decode_putfh_maxsz + \ |
| 638 | decode_savefh_maxsz + \ |
| 639 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 640 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 642 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | encode_putfh_maxsz + \ |
| 644 | encode_savefh_maxsz + \ |
| 645 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 646 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 647 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 648 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 650 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | decode_putfh_maxsz + \ |
| 652 | decode_savefh_maxsz + \ |
| 653 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 654 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 655 | decode_restorefh_maxsz + \ |
| 656 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 658 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | encode_putfh_maxsz + \ |
| 660 | encode_symlink_maxsz + \ |
| 661 | encode_getattr_maxsz + \ |
| 662 | encode_getfh_maxsz) |
| 663 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 664 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | decode_putfh_maxsz + \ |
| 666 | decode_symlink_maxsz + \ |
| 667 | decode_getattr_maxsz + \ |
| 668 | decode_getfh_maxsz) |
| 669 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 670 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | encode_putfh_maxsz + \ |
| 672 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 673 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 674 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 676 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | decode_putfh_maxsz + \ |
| 678 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 679 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 680 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 682 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | encode_putfh_maxsz + \ |
| 684 | encode_getattr_maxsz) |
| 685 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 686 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | decode_putfh_maxsz + \ |
| 688 | decode_getattr_maxsz) |
| 689 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 690 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 692 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 694 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 696 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 698 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 699 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | encode_getattr_maxsz) |
| 701 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 702 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 703 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | decode_getattr_maxsz) |
| 705 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 706 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 708 | encode_delegreturn_maxsz + \ |
| 709 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 711 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 712 | decode_delegreturn_maxsz + \ |
| 713 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 714 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 715 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 716 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 717 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 718 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 719 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 720 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 721 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 722 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 723 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 724 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 725 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 726 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 727 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 728 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 729 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 730 | #define NFS4_enc_fs_locations_sz \ |
| 731 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 732 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 733 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 734 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 735 | encode_fs_locations_maxsz + \ |
| 736 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 737 | #define NFS4_dec_fs_locations_sz \ |
| 738 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 739 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 740 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 741 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 742 | decode_fs_locations_maxsz + \ |
| 743 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 744 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 745 | encode_sequence_maxsz + \ |
| 746 | encode_putfh_maxsz + \ |
| 747 | encode_secinfo_maxsz) |
| 748 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 749 | decode_sequence_maxsz + \ |
| 750 | decode_putfh_maxsz + \ |
| 751 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 752 | #define NFS4_enc_fsid_present_sz \ |
| 753 | (compound_encode_hdr_maxsz + \ |
| 754 | encode_sequence_maxsz + \ |
| 755 | encode_putfh_maxsz + \ |
| 756 | encode_getfh_maxsz + \ |
| 757 | encode_renew_maxsz) |
| 758 | #define NFS4_dec_fsid_present_sz \ |
| 759 | (compound_decode_hdr_maxsz + \ |
| 760 | decode_sequence_maxsz + \ |
| 761 | decode_putfh_maxsz + \ |
| 762 | decode_getfh_maxsz + \ |
| 763 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 764 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 765 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 766 | (compound_encode_hdr_maxsz + \ |
| 767 | encode_bind_conn_to_session_maxsz) |
| 768 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 769 | (compound_decode_hdr_maxsz + \ |
| 770 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 771 | #define NFS4_enc_exchange_id_sz \ |
| 772 | (compound_encode_hdr_maxsz + \ |
| 773 | encode_exchange_id_maxsz) |
| 774 | #define NFS4_dec_exchange_id_sz \ |
| 775 | (compound_decode_hdr_maxsz + \ |
| 776 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 777 | #define NFS4_enc_create_session_sz \ |
| 778 | (compound_encode_hdr_maxsz + \ |
| 779 | encode_create_session_maxsz) |
| 780 | #define NFS4_dec_create_session_sz \ |
| 781 | (compound_decode_hdr_maxsz + \ |
| 782 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 783 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 784 | encode_destroy_session_maxsz) |
| 785 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 786 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 787 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 788 | encode_destroy_clientid_maxsz) |
| 789 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 790 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 791 | #define NFS4_enc_sequence_sz \ |
| 792 | (compound_decode_hdr_maxsz + \ |
| 793 | encode_sequence_maxsz) |
| 794 | #define NFS4_dec_sequence_sz \ |
| 795 | (compound_decode_hdr_maxsz + \ |
| 796 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 797 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 798 | encode_sequence_maxsz + \ |
| 799 | encode_putrootfh_maxsz + \ |
| 800 | encode_fsinfo_maxsz) |
| 801 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 802 | decode_sequence_maxsz + \ |
| 803 | decode_putrootfh_maxsz + \ |
| 804 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 805 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 806 | encode_sequence_maxsz + \ |
| 807 | encode_reclaim_complete_maxsz) |
| 808 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 809 | decode_sequence_maxsz + \ |
| 810 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 811 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 812 | encode_sequence_maxsz +\ |
| 813 | encode_getdeviceinfo_maxsz) |
| 814 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 815 | decode_sequence_maxsz + \ |
| 816 | decode_getdeviceinfo_maxsz) |
| 817 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 818 | encode_sequence_maxsz + \ |
| 819 | encode_putfh_maxsz + \ |
| 820 | encode_layoutget_maxsz) |
| 821 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 822 | decode_sequence_maxsz + \ |
| 823 | decode_putfh_maxsz + \ |
| 824 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 825 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 826 | encode_sequence_maxsz +\ |
| 827 | encode_putfh_maxsz + \ |
| 828 | encode_layoutcommit_maxsz + \ |
| 829 | encode_getattr_maxsz) |
| 830 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 831 | decode_sequence_maxsz + \ |
| 832 | decode_putfh_maxsz + \ |
| 833 | decode_layoutcommit_maxsz + \ |
| 834 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 835 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 836 | encode_sequence_maxsz + \ |
| 837 | encode_putfh_maxsz + \ |
| 838 | encode_layoutreturn_maxsz) |
| 839 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 840 | decode_sequence_maxsz + \ |
| 841 | decode_putfh_maxsz + \ |
| 842 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 843 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 844 | encode_sequence_maxsz + \ |
| 845 | encode_putrootfh_maxsz +\ |
| 846 | encode_secinfo_no_name_maxsz) |
| 847 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 848 | decode_sequence_maxsz + \ |
| 849 | decode_putrootfh_maxsz + \ |
| 850 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 851 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 852 | encode_sequence_maxsz + \ |
| 853 | encode_test_stateid_maxsz) |
| 854 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 855 | decode_sequence_maxsz + \ |
| 856 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 857 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 858 | encode_sequence_maxsz + \ |
| 859 | encode_free_stateid_maxsz) |
| 860 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 861 | decode_sequence_maxsz + \ |
| 862 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 863 | |
| 864 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 865 | compound_encode_hdr_maxsz + |
| 866 | encode_sequence_maxsz + |
| 867 | encode_putfh_maxsz + |
| 868 | encode_getattr_maxsz) * |
| 869 | XDR_UNIT); |
| 870 | |
| 871 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 872 | compound_decode_hdr_maxsz + |
| 873 | decode_sequence_maxsz + |
| 874 | decode_putfh_maxsz) * |
| 875 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 876 | |
| 877 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 878 | compound_decode_hdr_maxsz + |
| 879 | decode_sequence_maxsz) * |
| 880 | XDR_UNIT); |
| 881 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 882 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 884 | static const umode_t nfs_type2fmt[] = { |
| 885 | [NF4BAD] = 0, |
| 886 | [NF4REG] = S_IFREG, |
| 887 | [NF4DIR] = S_IFDIR, |
| 888 | [NF4BLK] = S_IFBLK, |
| 889 | [NF4CHR] = S_IFCHR, |
| 890 | [NF4LNK] = S_IFLNK, |
| 891 | [NF4SOCK] = S_IFSOCK, |
| 892 | [NF4FIFO] = S_IFIFO, |
| 893 | [NF4ATTRDIR] = 0, |
| 894 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | }; |
| 896 | |
| 897 | struct compound_hdr { |
| 898 | int32_t status; |
| 899 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 900 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | uint32_t taglen; |
| 902 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 903 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 904 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | }; |
| 906 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 907 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 908 | { |
| 909 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 910 | BUG_ON(!p); |
| 911 | return p; |
| 912 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 914 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 915 | { |
| 916 | __be32 *p; |
| 917 | |
| 918 | p = xdr_reserve_space(xdr, len); |
| 919 | xdr_encode_opaque_fixed(p, buf, len); |
| 920 | } |
| 921 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 923 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 924 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 926 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | xdr_encode_opaque(p, str, len); |
| 928 | } |
| 929 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 930 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 931 | { |
| 932 | __be32 *p; |
| 933 | |
| 934 | p = reserve_space(xdr, 4); |
| 935 | *p = cpu_to_be32(n); |
| 936 | } |
| 937 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 938 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 939 | { |
| 940 | __be32 *p; |
| 941 | |
| 942 | p = reserve_space(xdr, 8); |
| 943 | xdr_encode_hyper(p, n); |
| 944 | } |
| 945 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 946 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 947 | const struct nfs_seqid *seqid) |
| 948 | { |
Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 949 | if (seqid != NULL) |
| 950 | encode_uint32(xdr, seqid->sequence->counter); |
| 951 | else |
| 952 | encode_uint32(xdr, 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 953 | } |
| 954 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 955 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 956 | struct rpc_rqst *req, |
| 957 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 959 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 960 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 961 | |
| 962 | /* initialize running count of expected bytes in reply. |
| 963 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 964 | * but this is not required as a MUST for the server to do so. */ |
| 965 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 967 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 968 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 969 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 970 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 971 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 972 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 973 | } |
| 974 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 975 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 976 | uint32_t replen, |
| 977 | struct compound_hdr *hdr) |
| 978 | { |
| 979 | encode_uint32(xdr, op); |
| 980 | hdr->nops++; |
| 981 | hdr->replen += replen; |
| 982 | } |
| 983 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 984 | static void encode_nops(struct compound_hdr *hdr) |
| 985 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 986 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 987 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
| 989 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 990 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 991 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 992 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 993 | } |
| 994 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 996 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 997 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | } |
| 999 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1000 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 1001 | const struct nfs4_label *label, |
| 1002 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | { |
| 1004 | char owner_name[IDMAP_NAMESZ]; |
| 1005 | char owner_group[IDMAP_NAMESZ]; |
| 1006 | int owner_namelen = 0; |
| 1007 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1008 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1009 | unsigned i; |
| 1010 | uint32_t len = 0; |
| 1011 | uint32_t bmval_len; |
| 1012 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
| 1014 | /* |
| 1015 | * We reserve enough space to write the entire attribute buffer at once. |
| 1016 | * In the worst-case, this would be |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1017 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 1018 | * = 40 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1019 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | */ |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1021 | if (iap->ia_valid & ATTR_SIZE) { |
| 1022 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1024 | } |
| 1025 | if (iap->ia_valid & ATTR_MODE) { |
| 1026 | bmval[1] |= FATTR4_WORD1_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | len += 4; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1028 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1030 | owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1032 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1033 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | /* XXX */ |
| 1035 | strcpy(owner_name, "nobody"); |
| 1036 | owner_namelen = sizeof("nobody") - 1; |
| 1037 | /* goto out; */ |
| 1038 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1039 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1041 | } |
| 1042 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1043 | owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1045 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1046 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | strcpy(owner_group, "nobody"); |
| 1048 | owner_grouplen = sizeof("nobody") - 1; |
| 1049 | /* goto out; */ |
| 1050 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1051 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1053 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | if (iap->ia_valid & ATTR_ATIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1055 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1056 | len += 16; |
| 1057 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1058 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1059 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | } |
| 1061 | if (iap->ia_valid & ATTR_MTIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1062 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1063 | len += 16; |
| 1064 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1065 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1066 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | } |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1068 | if (label) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1069 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1070 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1071 | } |
| 1072 | |
| 1073 | if (bmval[2] != 0) |
| 1074 | bmval_len = 3; |
| 1075 | else if (bmval[1] != 0) |
| 1076 | bmval_len = 2; |
| 1077 | else |
| 1078 | bmval_len = 1; |
| 1079 | |
| 1080 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); |
| 1081 | |
| 1082 | *p++ = cpu_to_be32(bmval_len); |
| 1083 | for (i = 0; i < bmval_len; i++) |
| 1084 | *p++ = cpu_to_be32(bmval[i]); |
| 1085 | *p++ = cpu_to_be32(len); |
| 1086 | |
| 1087 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1088 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1089 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1090 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1091 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1092 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1093 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1094 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1095 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1096 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1097 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1098 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); |
| 1099 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
| 1100 | } else |
| 1101 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1102 | } |
| 1103 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1104 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1105 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1106 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); |
| 1107 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
| 1108 | } else |
| 1109 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1110 | } |
| 1111 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1112 | *p++ = cpu_to_be32(label->lfs); |
| 1113 | *p++ = cpu_to_be32(label->pi); |
| 1114 | *p++ = cpu_to_be32(label->len); |
| 1115 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1116 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1121 | 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] | 1122 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1123 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1124 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | } |
| 1126 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1127 | 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] | 1128 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1129 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1130 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1131 | encode_nfs4_stateid(xdr, &arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | } |
| 1133 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1134 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1136 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1137 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1138 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1139 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1140 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1141 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1144 | 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] | 1145 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1146 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1147 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1148 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1149 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | |
| 1151 | switch (create->ftype) { |
| 1152 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1153 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1154 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1155 | 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] | 1156 | break; |
| 1157 | |
| 1158 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1159 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1160 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1161 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | break; |
| 1163 | |
| 1164 | default: |
| 1165 | break; |
| 1166 | } |
| 1167 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1168 | encode_string(xdr, create->name->len, create->name->name); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1169 | encode_attrs(xdr, create->attrs, create->label, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1172 | 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] | 1173 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1174 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1176 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1177 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1178 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1179 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1182 | 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] | 1183 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1184 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1186 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1187 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1188 | *p++ = cpu_to_be32(2); |
| 1189 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1190 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | } |
| 1192 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1193 | static void |
| 1194 | encode_getattr_three(struct xdr_stream *xdr, |
| 1195 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1196 | struct compound_hdr *hdr) |
| 1197 | { |
| 1198 | __be32 *p; |
| 1199 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1200 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1201 | if (bm2) { |
| 1202 | p = reserve_space(xdr, 16); |
| 1203 | *p++ = cpu_to_be32(3); |
| 1204 | *p++ = cpu_to_be32(bm0); |
| 1205 | *p++ = cpu_to_be32(bm1); |
| 1206 | *p = cpu_to_be32(bm2); |
| 1207 | } else if (bm1) { |
| 1208 | p = reserve_space(xdr, 12); |
| 1209 | *p++ = cpu_to_be32(2); |
| 1210 | *p++ = cpu_to_be32(bm0); |
| 1211 | *p = cpu_to_be32(bm1); |
| 1212 | } else { |
| 1213 | p = reserve_space(xdr, 8); |
| 1214 | *p++ = cpu_to_be32(1); |
| 1215 | *p = cpu_to_be32(bm0); |
| 1216 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1217 | } |
| 1218 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1219 | 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] | 1220 | { |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1221 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1222 | bitmask[1] & nfs4_fattr_bitmap[1], |
| 1223 | bitmask[2] & nfs4_fattr_bitmap[2], |
| 1224 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1225 | } |
| 1226 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1227 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1228 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1229 | struct compound_hdr *hdr) |
| 1230 | { |
| 1231 | encode_getattr_three(xdr, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1232 | bitmask[0] & open_bitmap[0], |
| 1233 | bitmask[1] & open_bitmap[1], |
| 1234 | bitmask[2] & open_bitmap[2], |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1235 | hdr); |
| 1236 | } |
| 1237 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1238 | 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] | 1239 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1240 | encode_getattr_three(xdr, |
| 1241 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1242 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1243 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1244 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1247 | 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] | 1248 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1249 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1250 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1251 | } |
| 1252 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1253 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1255 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1258 | 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] | 1259 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1260 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1261 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | } |
| 1263 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1264 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1265 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1266 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1267 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1268 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1269 | } |
| 1270 | |
| 1271 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1272 | { |
| 1273 | if (fl->fl_end == OFFSET_MAX) |
| 1274 | return ~(uint64_t)0; |
| 1275 | return fl->fl_end - fl->fl_start + 1; |
| 1276 | } |
| 1277 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1278 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1279 | { |
| 1280 | __be32 *p; |
| 1281 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1282 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1283 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1284 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1285 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1286 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1287 | xdr_encode_hyper(p, lowner->id); |
| 1288 | } |
| 1289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | /* |
| 1291 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1292 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1293 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1294 | 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] | 1295 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1296 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1298 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1299 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1300 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1301 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1302 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1303 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1304 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1305 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1306 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1307 | encode_nfs4_stateid(xdr, &args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1308 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1309 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | } |
| 1311 | else { |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1312 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1313 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | } |
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_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] | 1318 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1319 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1321 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1322 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1323 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1324 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1325 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1326 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | } |
| 1328 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1329 | 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] | 1330 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1331 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1333 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1334 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1335 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1336 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1337 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1338 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1339 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | } |
| 1341 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1342 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1343 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1344 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1345 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1346 | } |
| 1347 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1348 | 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] | 1349 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1350 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1351 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1354 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1356 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1358 | p = reserve_space(xdr, 8); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1359 | *p++ = cpu_to_be32(share_access); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1360 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | } |
| 1362 | |
| 1363 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1364 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1365 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | /* |
| 1367 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1368 | * owner 4 = 32 |
| 1369 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1370 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1371 | encode_share_access(xdr, arg->share_access); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1372 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1373 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1374 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1375 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1376 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1377 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1378 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1382 | { |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1383 | struct iattr dummy; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1384 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1386 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1387 | switch(arg->createmode) { |
| 1388 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1389 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1390 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1391 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1392 | case NFS4_CREATE_GUARDED: |
| 1393 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1394 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1395 | break; |
| 1396 | case NFS4_CREATE_EXCLUSIVE: |
| 1397 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1398 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1399 | break; |
| 1400 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1401 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1402 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1403 | dummy.ia_valid = 0; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1404 | encode_attrs(xdr, &dummy, arg->label, arg->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1409 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1410 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1412 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1414 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1415 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1416 | break; |
| 1417 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1418 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1419 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | } |
| 1421 | } |
| 1422 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1423 | 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] | 1424 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1425 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1427 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1429 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1430 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1431 | break; |
| 1432 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1433 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1434 | break; |
| 1435 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1436 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1437 | break; |
| 1438 | default: |
| 1439 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1444 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1445 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1447 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1448 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1449 | encode_string(xdr, name->len, name->name); |
| 1450 | } |
| 1451 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1452 | 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] | 1453 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1454 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1456 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1457 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | encode_delegation_type(xdr, type); |
| 1459 | } |
| 1460 | |
| 1461 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1462 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1463 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1465 | p = reserve_space(xdr, 4); |
| 1466 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1467 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | encode_string(xdr, name->len, name->name); |
| 1469 | } |
| 1470 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1471 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1472 | { |
| 1473 | __be32 *p; |
| 1474 | |
| 1475 | p = reserve_space(xdr, 4); |
| 1476 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1477 | } |
| 1478 | |
| 1479 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1480 | { |
| 1481 | __be32 *p; |
| 1482 | |
| 1483 | p = reserve_space(xdr, 4); |
| 1484 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1485 | encode_nfs4_stateid(xdr, stateid); |
| 1486 | } |
| 1487 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1488 | 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] | 1489 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1490 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | encode_openhdr(xdr, arg); |
| 1492 | encode_opentype(xdr, arg); |
| 1493 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1494 | case NFS4_OPEN_CLAIM_NULL: |
| 1495 | encode_claim_null(xdr, arg->name); |
| 1496 | break; |
| 1497 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1498 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1499 | break; |
| 1500 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1501 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1502 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1503 | case NFS4_OPEN_CLAIM_FH: |
| 1504 | encode_claim_fh(xdr); |
| 1505 | break; |
| 1506 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1507 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1508 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1509 | default: |
| 1510 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | } |
| 1513 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1514 | 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] | 1515 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1516 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1517 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1518 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1521 | static void encode_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] | 1522 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1523 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1524 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1525 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1526 | encode_share_access(xdr, arg->share_access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | } |
| 1528 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1529 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1530 | 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] | 1531 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1532 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1533 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | } |
| 1535 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1536 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1538 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | } |
| 1540 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1541 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1542 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1544 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1546 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1547 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1549 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1550 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1551 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | } |
| 1553 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1554 | 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] | 1555 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1556 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1557 | FATTR4_WORD0_RDATTR_ERROR, |
| 1558 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1559 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1560 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1561 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1562 | uint32_t attrlen = 0; |
| 1563 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1565 | if (readdir->plus) { |
| 1566 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1567 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1568 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1569 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1570 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1571 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1572 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1573 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1574 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1575 | /* Use mounted_on_fileid only if the server supports it */ |
| 1576 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1577 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1578 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1579 | attrs[i] &= readdir->bitmask[i]; |
| 1580 | if (attrs[i] != 0) |
| 1581 | attrlen = i+1; |
| 1582 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1583 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1584 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1585 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1586 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1587 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1588 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1589 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1590 | *p++ = cpu_to_be32(attrlen); |
| 1591 | for (i = 0; i < attrlen; i++) |
| 1592 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1593 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1594 | |
| 1595 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1596 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1597 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1598 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1599 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1600 | attrs[1] & readdir->bitmask[1], |
| 1601 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1602 | } |
| 1603 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1604 | 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] | 1605 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1606 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | } |
| 1608 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1609 | 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] | 1610 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1611 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1612 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | } |
| 1614 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1615 | static void encode_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] | 1616 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1617 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1618 | encode_string(xdr, oldname->len, oldname->name); |
| 1619 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1622 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1623 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1625 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1626 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | } |
| 1628 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1629 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1630 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1631 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1632 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1633 | } |
| 1634 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1635 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1636 | 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] | 1637 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1638 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1639 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1640 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1641 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1642 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1643 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1644 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1645 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1646 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1647 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1648 | } |
| 1649 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1650 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1651 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1653 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | } |
| 1655 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1656 | 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] | 1657 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1658 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1659 | encode_nfs4_stateid(xdr, &arg->stateid); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1660 | encode_attrs(xdr, arg->iap, arg->label, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1663 | 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] | 1664 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1665 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1667 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1668 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | |
| 1670 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1671 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1672 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1674 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1675 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1676 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | } |
| 1678 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1679 | 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] | 1680 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1681 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1682 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1683 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1684 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1685 | } |
| 1686 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1687 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1688 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1689 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1690 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1692 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1693 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1695 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1696 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1697 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1698 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | |
| 1700 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1703 | static void encode_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] | 1704 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1705 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1706 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1708 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1709 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1710 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1711 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1712 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1713 | } |
| 1714 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1715 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1716 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1717 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1718 | struct nfs41_bind_conn_to_session_args *args, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1719 | struct compound_hdr *hdr) |
| 1720 | { |
| 1721 | __be32 *p; |
| 1722 | |
| 1723 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1724 | decode_bind_conn_to_session_maxsz, hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1725 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1726 | p = xdr_reserve_space(xdr, 8); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1727 | *p++ = cpu_to_be32(args->dir); |
| 1728 | *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1729 | } |
| 1730 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1731 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 1732 | { |
| 1733 | unsigned int i; |
| 1734 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1735 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1736 | encode_uint32(xdr, op_map->u.words[i]); |
| 1737 | } |
| 1738 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1739 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1740 | struct nfs41_exchange_id_args *args, |
| 1741 | struct compound_hdr *hdr) |
| 1742 | { |
| 1743 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1744 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1745 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1746 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1747 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1748 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1749 | |
| 1750 | encode_string(xdr, args->id_len, args->id); |
| 1751 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1752 | encode_uint32(xdr, args->flags); |
| 1753 | encode_uint32(xdr, args->state_protect.how); |
| 1754 | |
| 1755 | switch (args->state_protect.how) { |
| 1756 | case SP4_NONE: |
| 1757 | break; |
| 1758 | case SP4_MACH_CRED: |
| 1759 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1760 | encode_op_map(xdr, &args->state_protect.allow); |
| 1761 | break; |
| 1762 | default: |
| 1763 | WARN_ON_ONCE(1); |
| 1764 | break; |
| 1765 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1766 | |
| 1767 | if (send_implementation_id && |
| 1768 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1769 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1770 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1771 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1772 | utsname()->sysname, utsname()->release, |
| 1773 | utsname()->version, utsname()->machine); |
| 1774 | |
| 1775 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1776 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1777 | |
| 1778 | encode_string(xdr, |
| 1779 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1780 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1781 | encode_string(xdr, len, impl_name); |
| 1782 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1783 | p = reserve_space(xdr, 12); |
| 1784 | p = xdr_encode_hyper(p, 0); |
| 1785 | *p = cpu_to_be32(0); |
| 1786 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1787 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1788 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1789 | |
| 1790 | static void encode_create_session(struct xdr_stream *xdr, |
| 1791 | struct nfs41_create_session_args *args, |
| 1792 | struct compound_hdr *hdr) |
| 1793 | { |
| 1794 | __be32 *p; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1795 | struct nfs_client *clp = args->client; |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1796 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1797 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1798 | u32 max_resp_sz_cached; |
| 1799 | |
| 1800 | /* |
| 1801 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1802 | * 2 is the verifier. |
| 1803 | */ |
| 1804 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1805 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1806 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1807 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1808 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1809 | p = xdr_encode_hyper(p, args->clientid); |
| 1810 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1811 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1812 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1813 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1814 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1815 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1816 | *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] | 1817 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1818 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1819 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1820 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1821 | |
| 1822 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1823 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1824 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1825 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1826 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1827 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1828 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1829 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1830 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1831 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1832 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1833 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1834 | |
| 1835 | /* authsys_parms rfc1831 */ |
Trond Myklebust | 17f26b1 | 2013-08-21 15:48:42 -0400 | [diff] [blame] | 1836 | *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */ |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1837 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1838 | *p++ = cpu_to_be32(0); /* UID */ |
| 1839 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1840 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1841 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1842 | |
| 1843 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1844 | struct nfs4_session *session, |
| 1845 | struct compound_hdr *hdr) |
| 1846 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1847 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1848 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1849 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1850 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1851 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1852 | uint64_t clientid, |
| 1853 | struct compound_hdr *hdr) |
| 1854 | { |
| 1855 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1856 | encode_uint64(xdr, clientid); |
| 1857 | } |
| 1858 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1859 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1860 | struct nfs41_reclaim_complete_args *args, |
| 1861 | struct compound_hdr *hdr) |
| 1862 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1863 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1864 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1865 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1866 | #endif /* CONFIG_NFS_V4_1 */ |
| 1867 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1868 | static void encode_sequence(struct xdr_stream *xdr, |
| 1869 | const struct nfs4_sequence_args *args, |
| 1870 | struct compound_hdr *hdr) |
| 1871 | { |
| 1872 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1873 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1874 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1875 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1876 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1877 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1878 | tp = slot->table; |
| 1879 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1880 | if (!session) |
| 1881 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1882 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1883 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1884 | |
| 1885 | /* |
| 1886 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1887 | */ |
| 1888 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1889 | "max_slotid=%d cache_this=%d\n", |
| 1890 | __func__, |
| 1891 | ((u32 *)session->sess_id.data)[0], |
| 1892 | ((u32 *)session->sess_id.data)[1], |
| 1893 | ((u32 *)session->sess_id.data)[2], |
| 1894 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1895 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1896 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1897 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1898 | 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] | 1899 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1900 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1901 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1902 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1903 | #endif /* CONFIG_NFS_V4_1 */ |
| 1904 | } |
| 1905 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1906 | #ifdef CONFIG_NFS_V4_1 |
| 1907 | static void |
| 1908 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1909 | const struct nfs4_getdeviceinfo_args *args, |
| 1910 | struct compound_hdr *hdr) |
| 1911 | { |
| 1912 | __be32 *p; |
| 1913 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1914 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1915 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1916 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1917 | NFS4_DEVICEID4_SIZE); |
| 1918 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1919 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1920 | |
| 1921 | p = reserve_space(xdr, 4 + 4); |
| 1922 | *p++ = cpu_to_be32(1); /* bitmap length */ |
| 1923 | *p++ = cpu_to_be32(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1924 | } |
| 1925 | |
| 1926 | static void |
| 1927 | encode_layoutget(struct xdr_stream *xdr, |
| 1928 | const struct nfs4_layoutget_args *args, |
| 1929 | struct compound_hdr *hdr) |
| 1930 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1931 | __be32 *p; |
| 1932 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1933 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1934 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1935 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1936 | *p++ = cpu_to_be32(args->type); |
| 1937 | *p++ = cpu_to_be32(args->range.iomode); |
| 1938 | p = xdr_encode_hyper(p, args->range.offset); |
| 1939 | p = xdr_encode_hyper(p, args->range.length); |
| 1940 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1941 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1942 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1943 | |
| 1944 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1945 | __func__, |
| 1946 | args->type, |
| 1947 | args->range.iomode, |
| 1948 | (unsigned long)args->range.offset, |
| 1949 | (unsigned long)args->range.length, |
| 1950 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1951 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1952 | |
| 1953 | static int |
| 1954 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1955 | struct inode *inode, |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1956 | struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1957 | struct compound_hdr *hdr) |
| 1958 | { |
| 1959 | __be32 *p; |
| 1960 | |
| 1961 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1962 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1963 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1964 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1965 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1966 | /* Only whole file layouts */ |
| 1967 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1968 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1969 | *p = cpu_to_be32(0); /* reclaim */ |
| 1970 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1971 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1972 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1973 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1974 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1975 | *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */ |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1976 | |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1977 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1978 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1979 | NFS_I(inode)->layout, xdr, args); |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1980 | } else { |
| 1981 | encode_uint32(xdr, args->layoutupdate_len); |
| 1982 | if (args->layoutupdate_pages) { |
| 1983 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 1984 | args->layoutupdate_len); |
| 1985 | } |
| 1986 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1987 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1988 | return 0; |
| 1989 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1990 | |
| 1991 | static void |
| 1992 | encode_layoutreturn(struct xdr_stream *xdr, |
| 1993 | const struct nfs4_layoutreturn_args *args, |
| 1994 | struct compound_hdr *hdr) |
| 1995 | { |
| 1996 | __be32 *p; |
| 1997 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1998 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 1999 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2000 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2001 | *p++ = cpu_to_be32(args->layout_type); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2002 | *p++ = cpu_to_be32(args->range.iomode); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2003 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2004 | p = reserve_space(xdr, 16); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2005 | p = xdr_encode_hyper(p, args->range.offset); |
| 2006 | p = xdr_encode_hyper(p, args->range.length); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2007 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2008 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2009 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2010 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2011 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2012 | NFS_I(args->inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2013 | } else |
| 2014 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2015 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2016 | |
| 2017 | static int |
| 2018 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2019 | const struct nfs41_secinfo_no_name_args *args, |
| 2020 | struct compound_hdr *hdr) |
| 2021 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2022 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2023 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2024 | return 0; |
| 2025 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2026 | |
| 2027 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2028 | struct nfs41_test_stateid_args *args, |
| 2029 | struct compound_hdr *hdr) |
| 2030 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2031 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2032 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2033 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2034 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2035 | |
| 2036 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2037 | struct nfs41_free_stateid_args *args, |
| 2038 | struct compound_hdr *hdr) |
| 2039 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2040 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2041 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2042 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2043 | #endif /* CONFIG_NFS_V4_1 */ |
| 2044 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | /* |
| 2046 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2047 | */ |
| 2048 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2049 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2050 | { |
| 2051 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2052 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2053 | if (session) |
| 2054 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2055 | #endif /* CONFIG_NFS_V4_1 */ |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | /* |
| 2060 | * Encode an ACCESS request |
| 2061 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2062 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2063 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2066 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2069 | encode_compound_hdr(xdr, req, &hdr); |
| 2070 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2071 | encode_putfh(xdr, args->fh, &hdr); |
| 2072 | encode_access(xdr, args->access, &hdr); |
| 2073 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2074 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | /* |
| 2078 | * Encode LOOKUP request |
| 2079 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2080 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2081 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2084 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2087 | encode_compound_hdr(xdr, req, &hdr); |
| 2088 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2089 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2090 | encode_lookup(xdr, args->name, &hdr); |
| 2091 | encode_getfh(xdr, &hdr); |
| 2092 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2093 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | /* |
| 2097 | * Encode LOOKUP_ROOT request |
| 2098 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2099 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2100 | struct xdr_stream *xdr, |
| 2101 | const struct nfs4_lookup_root_arg *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 compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2104 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2107 | encode_compound_hdr(xdr, req, &hdr); |
| 2108 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2109 | encode_putrootfh(xdr, &hdr); |
| 2110 | encode_getfh(xdr, &hdr); |
| 2111 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2112 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | } |
| 2114 | |
| 2115 | /* |
| 2116 | * Encode REMOVE request |
| 2117 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2118 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2119 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2122 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2125 | encode_compound_hdr(xdr, req, &hdr); |
| 2126 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2127 | encode_putfh(xdr, args->fh, &hdr); |
| 2128 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2129 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | } |
| 2131 | |
| 2132 | /* |
| 2133 | * Encode RENAME request |
| 2134 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2135 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2136 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2139 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2142 | encode_compound_hdr(xdr, req, &hdr); |
| 2143 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2144 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2145 | encode_savefh(xdr, &hdr); |
| 2146 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2147 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2148 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | /* |
| 2152 | * Encode LINK request |
| 2153 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2154 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2155 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2158 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2159 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2161 | encode_compound_hdr(xdr, req, &hdr); |
| 2162 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2163 | encode_putfh(xdr, args->fh, &hdr); |
| 2164 | encode_savefh(xdr, &hdr); |
| 2165 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2166 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2167 | encode_restorefh(xdr, &hdr); |
| 2168 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2169 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | } |
| 2171 | |
| 2172 | /* |
| 2173 | * Encode CREATE request |
| 2174 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2175 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2176 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2179 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2182 | encode_compound_hdr(xdr, req, &hdr); |
| 2183 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2184 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2185 | encode_create(xdr, args, &hdr); |
| 2186 | encode_getfh(xdr, &hdr); |
| 2187 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2188 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | /* |
| 2192 | * Encode SYMLINK request |
| 2193 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2194 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2195 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2197 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | /* |
| 2201 | * Encode GETATTR request |
| 2202 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2203 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2204 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2205 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2207 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2210 | encode_compound_hdr(xdr, req, &hdr); |
| 2211 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2212 | encode_putfh(xdr, args->fh, &hdr); |
| 2213 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2214 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | } |
| 2216 | |
| 2217 | /* |
| 2218 | * Encode a CLOSE request |
| 2219 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2220 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2221 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2222 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2223 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2224 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2225 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2227 | encode_compound_hdr(xdr, req, &hdr); |
| 2228 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2229 | encode_putfh(xdr, args->fh, &hdr); |
| 2230 | encode_close(xdr, args, &hdr); |
| 2231 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2232 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | } |
| 2234 | |
| 2235 | /* |
| 2236 | * Encode an OPEN request |
| 2237 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2238 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2239 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2242 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2245 | encode_compound_hdr(xdr, req, &hdr); |
| 2246 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2247 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2248 | encode_open(xdr, args, &hdr); |
| 2249 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2250 | if (args->access) |
| 2251 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2252 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2253 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | } |
| 2255 | |
| 2256 | /* |
| 2257 | * Encode an OPEN_CONFIRM request |
| 2258 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2259 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2260 | struct xdr_stream *xdr, |
| 2261 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2263 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2264 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2267 | encode_compound_hdr(xdr, req, &hdr); |
| 2268 | encode_putfh(xdr, args->fh, &hdr); |
| 2269 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2270 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | } |
| 2272 | |
| 2273 | /* |
| 2274 | * Encode an OPEN request with no attributes. |
| 2275 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2276 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2277 | struct xdr_stream *xdr, |
| 2278 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2281 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2284 | encode_compound_hdr(xdr, req, &hdr); |
| 2285 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2286 | encode_putfh(xdr, args->fh, &hdr); |
| 2287 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2288 | if (args->access) |
| 2289 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2290 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2291 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | } |
| 2293 | |
| 2294 | /* |
| 2295 | * Encode an OPEN_DOWNGRADE request |
| 2296 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2297 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2298 | struct xdr_stream *xdr, |
| 2299 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2300 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2302 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2303 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2305 | encode_compound_hdr(xdr, req, &hdr); |
| 2306 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2307 | encode_putfh(xdr, args->fh, &hdr); |
| 2308 | encode_open_downgrade(xdr, args, &hdr); |
| 2309 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2310 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | /* |
| 2314 | * Encode a LOCK request |
| 2315 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2316 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2317 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2319 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2320 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2323 | encode_compound_hdr(xdr, req, &hdr); |
| 2324 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2325 | encode_putfh(xdr, args->fh, &hdr); |
| 2326 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2327 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | } |
| 2329 | |
| 2330 | /* |
| 2331 | * Encode a LOCKT request |
| 2332 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2333 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2334 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2337 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2340 | encode_compound_hdr(xdr, req, &hdr); |
| 2341 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2342 | encode_putfh(xdr, args->fh, &hdr); |
| 2343 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2344 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | /* |
| 2348 | * Encode a LOCKU request |
| 2349 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2350 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2351 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2354 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2357 | encode_compound_hdr(xdr, req, &hdr); |
| 2358 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2359 | encode_putfh(xdr, args->fh, &hdr); |
| 2360 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2361 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | } |
| 2363 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2364 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2365 | struct xdr_stream *xdr, |
| 2366 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2367 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2368 | struct compound_hdr hdr = { |
| 2369 | .minorversion = 0, |
| 2370 | }; |
| 2371 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2372 | encode_compound_hdr(xdr, req, &hdr); |
| 2373 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2374 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2375 | } |
| 2376 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2377 | /* |
| 2378 | * Encode a READLINK request |
| 2379 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2380 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2381 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2384 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2386 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2387 | encode_compound_hdr(xdr, req, &hdr); |
| 2388 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2389 | encode_putfh(xdr, args->fh, &hdr); |
| 2390 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2391 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2392 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2393 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2394 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2395 | } |
| 2396 | |
| 2397 | /* |
| 2398 | * Encode a READDIR request |
| 2399 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2400 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2401 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2404 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2407 | encode_compound_hdr(xdr, req, &hdr); |
| 2408 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2409 | encode_putfh(xdr, args->fh, &hdr); |
| 2410 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2411 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2412 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2413 | args->pgbase, args->count); |
| 2414 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2415 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2416 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2417 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2418 | } |
| 2419 | |
| 2420 | /* |
| 2421 | * Encode a READ request |
| 2422 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2423 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2424 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2425 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2427 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2428 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2430 | encode_compound_hdr(xdr, req, &hdr); |
| 2431 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2432 | encode_putfh(xdr, args->fh, &hdr); |
| 2433 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2435 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2437 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2438 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | } |
| 2440 | |
| 2441 | /* |
| 2442 | * Encode an SETATTR request |
| 2443 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2444 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2445 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2446 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2447 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2448 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2449 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2450 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2451 | encode_compound_hdr(xdr, req, &hdr); |
| 2452 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2453 | encode_putfh(xdr, args->fh, &hdr); |
| 2454 | encode_setattr(xdr, args, args->server, &hdr); |
| 2455 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2456 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | } |
| 2458 | |
| 2459 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2460 | * Encode a GETACL request |
| 2461 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2462 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2463 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2464 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2465 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2466 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2467 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2468 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2469 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2470 | encode_compound_hdr(xdr, req, &hdr); |
| 2471 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2472 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2473 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2474 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2475 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2476 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2477 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2478 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2479 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2480 | } |
| 2481 | |
| 2482 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2483 | * Encode a WRITE request |
| 2484 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2485 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2486 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2487 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2488 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2489 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2491 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2492 | encode_compound_hdr(xdr, req, &hdr); |
| 2493 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2494 | encode_putfh(xdr, args->fh, &hdr); |
| 2495 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2496 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2497 | if (args->bitmask) |
| 2498 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2499 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2500 | } |
| 2501 | |
| 2502 | /* |
| 2503 | * a COMMIT request |
| 2504 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2505 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 2506 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2507 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2508 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2509 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2512 | encode_compound_hdr(xdr, req, &hdr); |
| 2513 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2514 | encode_putfh(xdr, args->fh, &hdr); |
| 2515 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2516 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | } |
| 2518 | |
| 2519 | /* |
| 2520 | * FSINFO request |
| 2521 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2522 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2523 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2524 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2526 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2527 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2529 | encode_compound_hdr(xdr, req, &hdr); |
| 2530 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2531 | encode_putfh(xdr, args->fh, &hdr); |
| 2532 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2533 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | } |
| 2535 | |
| 2536 | /* |
| 2537 | * a PATHCONF request |
| 2538 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2539 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2540 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2542 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2543 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2546 | encode_compound_hdr(xdr, req, &hdr); |
| 2547 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2548 | encode_putfh(xdr, args->fh, &hdr); |
| 2549 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2550 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2551 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2552 | } |
| 2553 | |
| 2554 | /* |
| 2555 | * a STATFS request |
| 2556 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2557 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2558 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2561 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2562 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2564 | encode_compound_hdr(xdr, req, &hdr); |
| 2565 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2566 | encode_putfh(xdr, args->fh, &hdr); |
| 2567 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2568 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2569 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | } |
| 2571 | |
| 2572 | /* |
| 2573 | * GETATTR_BITMAP request |
| 2574 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2575 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2576 | struct xdr_stream *xdr, |
| 2577 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2580 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2583 | encode_compound_hdr(xdr, req, &hdr); |
| 2584 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2585 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2586 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2587 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2588 | FATTR4_WORD0_LINK_SUPPORT| |
| 2589 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2590 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2591 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | /* |
| 2595 | * a RENEW request |
| 2596 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2597 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2598 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2599 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2600 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2601 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2602 | }; |
| 2603 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2604 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2605 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2606 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2607 | } |
| 2608 | |
| 2609 | /* |
| 2610 | * a SETCLIENTID request |
| 2611 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2612 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2613 | struct xdr_stream *xdr, |
| 2614 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2617 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | }; |
| 2619 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2620 | encode_compound_hdr(xdr, req, &hdr); |
| 2621 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2622 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | } |
| 2624 | |
| 2625 | /* |
| 2626 | * a SETCLIENTID_CONFIRM request |
| 2627 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2628 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2629 | struct xdr_stream *xdr, |
| 2630 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2633 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2634 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2635 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2636 | encode_compound_hdr(xdr, req, &hdr); |
| 2637 | encode_setclientid_confirm(xdr, arg, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2638 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2639 | } |
| 2640 | |
| 2641 | /* |
| 2642 | * DELEGRETURN request |
| 2643 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2644 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2645 | struct xdr_stream *xdr, |
| 2646 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2648 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2649 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2652 | encode_compound_hdr(xdr, req, &hdr); |
| 2653 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2654 | encode_putfh(xdr, args->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2655 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2656 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2657 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | } |
| 2659 | |
| 2660 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2661 | * Encode FS_LOCATIONS request |
| 2662 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2663 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2664 | struct xdr_stream *xdr, |
| 2665 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2666 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2667 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2668 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2669 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2670 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2671 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2672 | encode_compound_hdr(xdr, req, &hdr); |
| 2673 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2674 | if (args->migration) { |
| 2675 | encode_putfh(xdr, args->fh, &hdr); |
| 2676 | replen = hdr.replen; |
| 2677 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2678 | if (args->renew) |
| 2679 | encode_renew(xdr, args->clientid, &hdr); |
| 2680 | } else { |
| 2681 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2682 | encode_lookup(xdr, args->name, &hdr); |
| 2683 | replen = hdr.replen; |
| 2684 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2685 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2686 | |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2687 | /* Set up reply kvec to capture returned fs_locations array. */ |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2688 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2689 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2690 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2691 | } |
| 2692 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2693 | /* |
| 2694 | * Encode SECINFO request |
| 2695 | */ |
| 2696 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2697 | struct xdr_stream *xdr, |
| 2698 | struct nfs4_secinfo_arg *args) |
| 2699 | { |
| 2700 | struct compound_hdr hdr = { |
| 2701 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2702 | }; |
| 2703 | |
| 2704 | encode_compound_hdr(xdr, req, &hdr); |
| 2705 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2706 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2707 | encode_secinfo(xdr, args->name, &hdr); |
| 2708 | encode_nops(&hdr); |
| 2709 | } |
| 2710 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2711 | /* |
| 2712 | * Encode FSID_PRESENT request |
| 2713 | */ |
| 2714 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2715 | struct xdr_stream *xdr, |
| 2716 | struct nfs4_fsid_present_arg *args) |
| 2717 | { |
| 2718 | struct compound_hdr hdr = { |
| 2719 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2720 | }; |
| 2721 | |
| 2722 | encode_compound_hdr(xdr, req, &hdr); |
| 2723 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2724 | encode_putfh(xdr, args->fh, &hdr); |
| 2725 | encode_getfh(xdr, &hdr); |
| 2726 | if (args->renew) |
| 2727 | encode_renew(xdr, args->clientid, &hdr); |
| 2728 | encode_nops(&hdr); |
| 2729 | } |
| 2730 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2731 | #if defined(CONFIG_NFS_V4_1) |
| 2732 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2733 | * BIND_CONN_TO_SESSION request |
| 2734 | */ |
| 2735 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2736 | struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2737 | struct nfs41_bind_conn_to_session_args *args) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2738 | { |
| 2739 | struct compound_hdr hdr = { |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2740 | .minorversion = args->client->cl_mvops->minor_version, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2741 | }; |
| 2742 | |
| 2743 | encode_compound_hdr(xdr, req, &hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2744 | encode_bind_conn_to_session(xdr, args, &hdr); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2745 | encode_nops(&hdr); |
| 2746 | } |
| 2747 | |
| 2748 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2749 | * EXCHANGE_ID request |
| 2750 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2751 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2752 | struct xdr_stream *xdr, |
| 2753 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2754 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2755 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2756 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2757 | }; |
| 2758 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2759 | encode_compound_hdr(xdr, req, &hdr); |
| 2760 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2761 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2762 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2763 | |
| 2764 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2765 | * a CREATE_SESSION request |
| 2766 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2767 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2768 | struct xdr_stream *xdr, |
| 2769 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2770 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2771 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2772 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2773 | }; |
| 2774 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2775 | encode_compound_hdr(xdr, req, &hdr); |
| 2776 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2777 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2778 | } |
| 2779 | |
| 2780 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2781 | * a DESTROY_SESSION request |
| 2782 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2783 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2784 | struct xdr_stream *xdr, |
| 2785 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2786 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2787 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2788 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2789 | }; |
| 2790 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2791 | encode_compound_hdr(xdr, req, &hdr); |
| 2792 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2793 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2797 | * a DESTROY_CLIENTID request |
| 2798 | */ |
| 2799 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2800 | struct xdr_stream *xdr, |
| 2801 | struct nfs_client *clp) |
| 2802 | { |
| 2803 | struct compound_hdr hdr = { |
| 2804 | .minorversion = clp->cl_mvops->minor_version, |
| 2805 | }; |
| 2806 | |
| 2807 | encode_compound_hdr(xdr, req, &hdr); |
| 2808 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2809 | encode_nops(&hdr); |
| 2810 | } |
| 2811 | |
| 2812 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2813 | * a SEQUENCE request |
| 2814 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2815 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2816 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2817 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2818 | struct compound_hdr hdr = { |
| 2819 | .minorversion = nfs4_xdr_minorversion(args), |
| 2820 | }; |
| 2821 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2822 | encode_compound_hdr(xdr, req, &hdr); |
| 2823 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2824 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2825 | } |
| 2826 | |
| 2827 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2828 | * a GET_LEASE_TIME request |
| 2829 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2830 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2831 | struct xdr_stream *xdr, |
| 2832 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2833 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2834 | struct compound_hdr hdr = { |
| 2835 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2836 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2837 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2838 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2839 | encode_compound_hdr(xdr, req, &hdr); |
| 2840 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2841 | encode_putrootfh(xdr, &hdr); |
| 2842 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2843 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2844 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2845 | |
| 2846 | /* |
| 2847 | * a RECLAIM_COMPLETE request |
| 2848 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2849 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2850 | struct xdr_stream *xdr, |
| 2851 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2852 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2853 | struct compound_hdr hdr = { |
| 2854 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2855 | }; |
| 2856 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2857 | encode_compound_hdr(xdr, req, &hdr); |
| 2858 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2859 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2860 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2861 | } |
| 2862 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2863 | /* |
| 2864 | * Encode GETDEVICEINFO request |
| 2865 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2866 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2867 | struct xdr_stream *xdr, |
| 2868 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2869 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2870 | struct compound_hdr hdr = { |
| 2871 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2872 | }; |
| 2873 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2874 | encode_compound_hdr(xdr, req, &hdr); |
| 2875 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2876 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2877 | |
| 2878 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2879 | * so that notification bitmap is put in xdr_buf tail */ |
| 2880 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2881 | args->pdev->pages, args->pdev->pgbase, |
| 2882 | args->pdev->pglen); |
| 2883 | |
| 2884 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2885 | } |
| 2886 | |
| 2887 | /* |
| 2888 | * Encode LAYOUTGET request |
| 2889 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2890 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2891 | struct xdr_stream *xdr, |
| 2892 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2893 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2894 | struct compound_hdr hdr = { |
| 2895 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2896 | }; |
| 2897 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2898 | encode_compound_hdr(xdr, req, &hdr); |
| 2899 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2900 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2901 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2902 | |
| 2903 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2904 | args->layout.pages, 0, args->layout.pglen); |
| 2905 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2906 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2907 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2908 | |
| 2909 | /* |
| 2910 | * Encode LAYOUTCOMMIT request |
| 2911 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2912 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2913 | struct xdr_stream *xdr, |
| 2914 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2915 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2916 | struct nfs4_layoutcommit_data *data = |
| 2917 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2918 | struct compound_hdr hdr = { |
| 2919 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2920 | }; |
| 2921 | |
| 2922 | encode_compound_hdr(xdr, req, &hdr); |
| 2923 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2924 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2925 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2926 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2927 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2928 | } |
| 2929 | |
| 2930 | /* |
| 2931 | * Encode LAYOUTRETURN request |
| 2932 | */ |
| 2933 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2934 | struct xdr_stream *xdr, |
| 2935 | struct nfs4_layoutreturn_args *args) |
| 2936 | { |
| 2937 | struct compound_hdr hdr = { |
| 2938 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2939 | }; |
| 2940 | |
| 2941 | encode_compound_hdr(xdr, req, &hdr); |
| 2942 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2943 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2944 | encode_layoutreturn(xdr, args, &hdr); |
| 2945 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2946 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2947 | |
| 2948 | /* |
| 2949 | * Encode SECINFO_NO_NAME request |
| 2950 | */ |
| 2951 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2952 | struct xdr_stream *xdr, |
| 2953 | struct nfs41_secinfo_no_name_args *args) |
| 2954 | { |
| 2955 | struct compound_hdr hdr = { |
| 2956 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2957 | }; |
| 2958 | |
| 2959 | encode_compound_hdr(xdr, req, &hdr); |
| 2960 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2961 | encode_putrootfh(xdr, &hdr); |
| 2962 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2963 | encode_nops(&hdr); |
| 2964 | return 0; |
| 2965 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2966 | |
| 2967 | /* |
| 2968 | * Encode TEST_STATEID request |
| 2969 | */ |
| 2970 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2971 | struct xdr_stream *xdr, |
| 2972 | struct nfs41_test_stateid_args *args) |
| 2973 | { |
| 2974 | struct compound_hdr hdr = { |
| 2975 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2976 | }; |
| 2977 | |
| 2978 | encode_compound_hdr(xdr, req, &hdr); |
| 2979 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2980 | encode_test_stateid(xdr, args, &hdr); |
| 2981 | encode_nops(&hdr); |
| 2982 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2983 | |
| 2984 | /* |
| 2985 | * Encode FREE_STATEID request |
| 2986 | */ |
| 2987 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2988 | struct xdr_stream *xdr, |
| 2989 | struct nfs41_free_stateid_args *args) |
| 2990 | { |
| 2991 | struct compound_hdr hdr = { |
| 2992 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2993 | }; |
| 2994 | |
| 2995 | encode_compound_hdr(xdr, req, &hdr); |
| 2996 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2997 | encode_free_stateid(xdr, args, &hdr); |
| 2998 | encode_nops(&hdr); |
| 2999 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3000 | #endif /* CONFIG_NFS_V4_1 */ |
| 3001 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3002 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3003 | { |
| 3004 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3005 | "Remaining buffer length is %tu words.\n", |
| 3006 | func, xdr->end - xdr->p); |
| 3007 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3008 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3009 | 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] | 3010 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3011 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3013 | p = xdr_inline_decode(xdr, 4); |
| 3014 | if (unlikely(!p)) |
| 3015 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3016 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3017 | p = xdr_inline_decode(xdr, *len); |
| 3018 | if (unlikely(!p)) |
| 3019 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3020 | *string = (char *)p; |
| 3021 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3022 | out_overflow: |
| 3023 | print_overflow_msg(__func__, xdr); |
| 3024 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3025 | } |
| 3026 | |
| 3027 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3028 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3029 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3030 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3031 | p = xdr_inline_decode(xdr, 8); |
| 3032 | if (unlikely(!p)) |
| 3033 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3034 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3035 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3036 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3037 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3038 | if (unlikely(!p)) |
| 3039 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3040 | hdr->tag = (char *)p; |
| 3041 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3042 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3043 | if (unlikely(hdr->nops < 1)) |
| 3044 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3046 | out_overflow: |
| 3047 | print_overflow_msg(__func__, xdr); |
| 3048 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3049 | } |
| 3050 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3051 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3052 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3053 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3054 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3055 | uint32_t opnum; |
| 3056 | int32_t nfserr; |
| 3057 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3058 | p = xdr_inline_decode(xdr, 8); |
| 3059 | if (unlikely(!p)) |
| 3060 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3061 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3062 | if (unlikely(opnum != expected)) |
| 3063 | goto out_bad_operation; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3064 | nfserr = be32_to_cpup(p); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3065 | if (nfserr == NFS_OK) |
| 3066 | *nfs_retval = 0; |
| 3067 | else |
| 3068 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
| 3069 | return true; |
| 3070 | out_bad_operation: |
| 3071 | dprintk("nfs: Server returned operation" |
| 3072 | " %d but we issued a request for %d\n", |
| 3073 | opnum, expected); |
| 3074 | *nfs_retval = -EREMOTEIO; |
| 3075 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3076 | out_overflow: |
| 3077 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3078 | *nfs_retval = -EIO; |
| 3079 | return false; |
| 3080 | } |
| 3081 | |
| 3082 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3083 | { |
| 3084 | int retval; |
| 3085 | |
| 3086 | __decode_op_hdr(xdr, expected, &retval); |
| 3087 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3088 | } |
| 3089 | |
| 3090 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3091 | 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] | 3092 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3093 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3094 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3095 | char *str; |
| 3096 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3097 | p = xdr_inline_decode(xdr, 12); |
| 3098 | if (likely(p)) |
| 3099 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3100 | print_overflow_msg(__func__, xdr); |
| 3101 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3105 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3106 | uint32_t bmlen; |
| 3107 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3108 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3109 | p = xdr_inline_decode(xdr, 4); |
| 3110 | if (unlikely(!p)) |
| 3111 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3112 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3113 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3114 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3115 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3116 | if (unlikely(!p)) |
| 3117 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3118 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3119 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3120 | if (bmlen > 1) { |
| 3121 | bitmap[1] = be32_to_cpup(p++); |
| 3122 | if (bmlen > 2) |
| 3123 | bitmap[2] = be32_to_cpup(p); |
| 3124 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3125 | } |
| 3126 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3127 | out_overflow: |
| 3128 | print_overflow_msg(__func__, xdr); |
| 3129 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | } |
| 3131 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3132 | static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3133 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3134 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3135 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3136 | p = xdr_inline_decode(xdr, 4); |
| 3137 | if (unlikely(!p)) |
| 3138 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3139 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3140 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3142 | out_overflow: |
| 3143 | print_overflow_msg(__func__, xdr); |
| 3144 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3145 | } |
| 3146 | |
| 3147 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3148 | { |
| 3149 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3150 | int ret; |
| 3151 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3152 | if (unlikely(ret < 0)) |
| 3153 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3154 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3155 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3156 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3157 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3158 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3159 | return 0; |
| 3160 | } |
| 3161 | |
| 3162 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3163 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3164 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3165 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | |
| 3167 | *type = 0; |
| 3168 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3169 | return -EIO; |
| 3170 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3171 | p = xdr_inline_decode(xdr, 4); |
| 3172 | if (unlikely(!p)) |
| 3173 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3174 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3175 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3176 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | return -EIO; |
| 3178 | } |
| 3179 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3180 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3182 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3183 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3184 | out_overflow: |
| 3185 | print_overflow_msg(__func__, xdr); |
| 3186 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | } |
| 3188 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3189 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3190 | uint32_t *bitmap, uint32_t *type) |
| 3191 | { |
| 3192 | __be32 *p; |
| 3193 | |
| 3194 | *type = 0; |
| 3195 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3196 | return -EIO; |
| 3197 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3198 | p = xdr_inline_decode(xdr, 4); |
| 3199 | if (unlikely(!p)) |
| 3200 | goto out_overflow; |
| 3201 | *type = be32_to_cpup(p); |
| 3202 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3203 | } |
| 3204 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3205 | return 0; |
| 3206 | out_overflow: |
| 3207 | print_overflow_msg(__func__, xdr); |
| 3208 | return -EIO; |
| 3209 | } |
| 3210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3211 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3212 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3213 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3214 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3215 | |
| 3216 | *change = 0; |
| 3217 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3218 | return -EIO; |
| 3219 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3220 | p = xdr_inline_decode(xdr, 8); |
| 3221 | if (unlikely(!p)) |
| 3222 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3223 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3224 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3225 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3226 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3227 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3228 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3229 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3230 | out_overflow: |
| 3231 | print_overflow_msg(__func__, xdr); |
| 3232 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3233 | } |
| 3234 | |
| 3235 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3236 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3237 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3238 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | |
| 3240 | *size = 0; |
| 3241 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3242 | return -EIO; |
| 3243 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3244 | p = xdr_inline_decode(xdr, 8); |
| 3245 | if (unlikely(!p)) |
| 3246 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3247 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3248 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3249 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3250 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3251 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3252 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3253 | out_overflow: |
| 3254 | print_overflow_msg(__func__, xdr); |
| 3255 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3256 | } |
| 3257 | |
| 3258 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3259 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3260 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
| 3262 | *res = 0; |
| 3263 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3264 | return -EIO; |
| 3265 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3266 | p = xdr_inline_decode(xdr, 4); |
| 3267 | if (unlikely(!p)) |
| 3268 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3269 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3271 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3272 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3274 | out_overflow: |
| 3275 | print_overflow_msg(__func__, xdr); |
| 3276 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | } |
| 3278 | |
| 3279 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3280 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3281 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3282 | |
| 3283 | *res = 0; |
| 3284 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3285 | return -EIO; |
| 3286 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3287 | p = xdr_inline_decode(xdr, 4); |
| 3288 | if (unlikely(!p)) |
| 3289 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3290 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3291 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3292 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3293 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3295 | out_overflow: |
| 3296 | print_overflow_msg(__func__, xdr); |
| 3297 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | } |
| 3299 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3300 | 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] | 3301 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3302 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3303 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | |
| 3305 | fsid->major = 0; |
| 3306 | fsid->minor = 0; |
| 3307 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3308 | return -EIO; |
| 3309 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3310 | p = xdr_inline_decode(xdr, 16); |
| 3311 | if (unlikely(!p)) |
| 3312 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3313 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3314 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3315 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3316 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3317 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3318 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3319 | (unsigned long long)fsid->major, |
| 3320 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3321 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3322 | out_overflow: |
| 3323 | print_overflow_msg(__func__, xdr); |
| 3324 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | } |
| 3326 | |
| 3327 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3328 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3329 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3330 | |
| 3331 | *res = 60; |
| 3332 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3333 | return -EIO; |
| 3334 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3335 | p = xdr_inline_decode(xdr, 4); |
| 3336 | if (unlikely(!p)) |
| 3337 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3338 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3340 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3341 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3342 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3343 | out_overflow: |
| 3344 | print_overflow_msg(__func__, xdr); |
| 3345 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 | } |
| 3347 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3348 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3349 | { |
| 3350 | __be32 *p; |
| 3351 | |
| 3352 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3353 | return -EIO; |
| 3354 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3355 | p = xdr_inline_decode(xdr, 4); |
| 3356 | if (unlikely(!p)) |
| 3357 | goto out_overflow; |
| 3358 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3359 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3360 | } |
| 3361 | return 0; |
| 3362 | out_overflow: |
| 3363 | print_overflow_msg(__func__, xdr); |
| 3364 | return -EIO; |
| 3365 | } |
| 3366 | |
| 3367 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3368 | { |
| 3369 | __be32 *p; |
| 3370 | int len; |
| 3371 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3372 | if (fh != NULL) |
| 3373 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3374 | |
| 3375 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3376 | return -EIO; |
| 3377 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3378 | p = xdr_inline_decode(xdr, 4); |
| 3379 | if (unlikely(!p)) |
| 3380 | goto out_overflow; |
| 3381 | len = be32_to_cpup(p); |
| 3382 | if (len > NFS4_FHSIZE) |
| 3383 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3384 | p = xdr_inline_decode(xdr, len); |
| 3385 | if (unlikely(!p)) |
| 3386 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3387 | if (fh != NULL) { |
| 3388 | memcpy(fh->data, p, len); |
| 3389 | fh->size = len; |
| 3390 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3391 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3392 | } |
| 3393 | return 0; |
| 3394 | out_overflow: |
| 3395 | print_overflow_msg(__func__, xdr); |
| 3396 | return -EIO; |
| 3397 | } |
| 3398 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3400 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3401 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3402 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3403 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3404 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3405 | return -EIO; |
| 3406 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3407 | p = xdr_inline_decode(xdr, 4); |
| 3408 | if (unlikely(!p)) |
| 3409 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3410 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3411 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3412 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3413 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3414 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3415 | out_overflow: |
| 3416 | print_overflow_msg(__func__, xdr); |
| 3417 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3418 | } |
| 3419 | |
| 3420 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3421 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3422 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3423 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3424 | |
| 3425 | *fileid = 0; |
| 3426 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3427 | return -EIO; |
| 3428 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3429 | p = xdr_inline_decode(xdr, 8); |
| 3430 | if (unlikely(!p)) |
| 3431 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3432 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3433 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3434 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3435 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3436 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3437 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3438 | out_overflow: |
| 3439 | print_overflow_msg(__func__, xdr); |
| 3440 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3441 | } |
| 3442 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3443 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3444 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3445 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3446 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3447 | |
| 3448 | *fileid = 0; |
| 3449 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3450 | return -EIO; |
| 3451 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3452 | p = xdr_inline_decode(xdr, 8); |
| 3453 | if (unlikely(!p)) |
| 3454 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3455 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3456 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3457 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3458 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3459 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3460 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3461 | out_overflow: |
| 3462 | print_overflow_msg(__func__, xdr); |
| 3463 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3464 | } |
| 3465 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3466 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3467 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3468 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3469 | int status = 0; |
| 3470 | |
| 3471 | *res = 0; |
| 3472 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3473 | return -EIO; |
| 3474 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3475 | p = xdr_inline_decode(xdr, 8); |
| 3476 | if (unlikely(!p)) |
| 3477 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3478 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3480 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3481 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3482 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3483 | out_overflow: |
| 3484 | print_overflow_msg(__func__, xdr); |
| 3485 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3486 | } |
| 3487 | |
| 3488 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3489 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3490 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3491 | int status = 0; |
| 3492 | |
| 3493 | *res = 0; |
| 3494 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3495 | return -EIO; |
| 3496 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3497 | p = xdr_inline_decode(xdr, 8); |
| 3498 | if (unlikely(!p)) |
| 3499 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3500 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3501 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3502 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3503 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3504 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3505 | out_overflow: |
| 3506 | print_overflow_msg(__func__, xdr); |
| 3507 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3508 | } |
| 3509 | |
| 3510 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3511 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3512 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | int status = 0; |
| 3514 | |
| 3515 | *res = 0; |
| 3516 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3517 | return -EIO; |
| 3518 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3519 | p = xdr_inline_decode(xdr, 8); |
| 3520 | if (unlikely(!p)) |
| 3521 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3522 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3524 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3525 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3526 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3527 | out_overflow: |
| 3528 | print_overflow_msg(__func__, xdr); |
| 3529 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3530 | } |
| 3531 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3532 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3533 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3534 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3535 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3536 | int status = 0; |
| 3537 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3538 | p = xdr_inline_decode(xdr, 4); |
| 3539 | if (unlikely(!p)) |
| 3540 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3541 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3542 | if (n == 0) |
| 3543 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3544 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3545 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3546 | dprintk("cannot parse %d components in path\n", n); |
| 3547 | goto out_eio; |
| 3548 | } |
| 3549 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3550 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3551 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3552 | if (unlikely(status != 0)) |
| 3553 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3554 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3555 | pr_cont("%s%.*s ", |
| 3556 | (path->ncomponents != n ? "/ " : ""), |
| 3557 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3558 | } |
| 3559 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3560 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3561 | root_path: |
| 3562 | /* a root pathname is sent as a zero component4 */ |
| 3563 | path->ncomponents = 1; |
| 3564 | path->components[0].len=0; |
| 3565 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3566 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3567 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3568 | out_eio: |
| 3569 | dprintk(" status %d", status); |
| 3570 | status = -EIO; |
| 3571 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3572 | out_overflow: |
| 3573 | print_overflow_msg(__func__, xdr); |
| 3574 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3575 | } |
| 3576 | |
| 3577 | 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] | 3578 | { |
| 3579 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3580 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3581 | int status = -EIO; |
| 3582 | |
| 3583 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3584 | goto out; |
| 3585 | status = 0; |
| 3586 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3587 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3588 | status = -EIO; |
| 3589 | /* Ignore borken servers that return unrequested attrs */ |
| 3590 | if (unlikely(res == NULL)) |
| 3591 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3592 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3593 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3594 | if (unlikely(status != 0)) |
| 3595 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3596 | p = xdr_inline_decode(xdr, 4); |
| 3597 | if (unlikely(!p)) |
| 3598 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3599 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3600 | if (n <= 0) |
| 3601 | goto out_eio; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3602 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3603 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3604 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3605 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3606 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3607 | break; |
| 3608 | loc = &res->locations[res->nlocations]; |
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 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3613 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3614 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3615 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3616 | struct nfs4_string *server; |
| 3617 | |
| 3618 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3619 | unsigned int i; |
| 3620 | dprintk("%s: using first %u of %u servers " |
| 3621 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3622 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3623 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3624 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3625 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3626 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3627 | char *data; |
| 3628 | status = decode_opaque_inline(xdr, &len, &data); |
| 3629 | if (unlikely(status != 0)) |
| 3630 | goto out_eio; |
| 3631 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3632 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3633 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3634 | server = &loc->servers[loc->nservers]; |
| 3635 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3636 | if (unlikely(status != 0)) |
| 3637 | goto out_eio; |
| 3638 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3639 | } |
| 3640 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3641 | if (unlikely(status != 0)) |
| 3642 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3643 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3644 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3645 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3646 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3647 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3648 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3649 | out_overflow: |
| 3650 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3651 | out_eio: |
| 3652 | status = -EIO; |
| 3653 | goto out; |
| 3654 | } |
| 3655 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3656 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3657 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3658 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3659 | int status = 0; |
| 3660 | |
| 3661 | *res = 0; |
| 3662 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3663 | return -EIO; |
| 3664 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3665 | p = xdr_inline_decode(xdr, 8); |
| 3666 | if (unlikely(!p)) |
| 3667 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3668 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3669 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3670 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3671 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3672 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3673 | out_overflow: |
| 3674 | print_overflow_msg(__func__, xdr); |
| 3675 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | } |
| 3677 | |
| 3678 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3679 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3680 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3681 | int status = 0; |
| 3682 | |
| 3683 | *maxlink = 1; |
| 3684 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3685 | return -EIO; |
| 3686 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3687 | p = xdr_inline_decode(xdr, 4); |
| 3688 | if (unlikely(!p)) |
| 3689 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3690 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3691 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3692 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3693 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3694 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3695 | out_overflow: |
| 3696 | print_overflow_msg(__func__, xdr); |
| 3697 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3698 | } |
| 3699 | |
| 3700 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3701 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3702 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | int status = 0; |
| 3704 | |
| 3705 | *maxname = 1024; |
| 3706 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3707 | return -EIO; |
| 3708 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3709 | p = xdr_inline_decode(xdr, 4); |
| 3710 | if (unlikely(!p)) |
| 3711 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3712 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3713 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3714 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3715 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3716 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3717 | out_overflow: |
| 3718 | print_overflow_msg(__func__, xdr); |
| 3719 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3723 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3724 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3725 | int status = 0; |
| 3726 | |
| 3727 | *res = 1024; |
| 3728 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3729 | return -EIO; |
| 3730 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3731 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3732 | p = xdr_inline_decode(xdr, 8); |
| 3733 | if (unlikely(!p)) |
| 3734 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3735 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3736 | if (maxread > 0x7FFFFFFF) |
| 3737 | maxread = 0x7FFFFFFF; |
| 3738 | *res = (uint32_t)maxread; |
| 3739 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3740 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3741 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3742 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3743 | out_overflow: |
| 3744 | print_overflow_msg(__func__, xdr); |
| 3745 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3749 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3750 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | int status = 0; |
| 3752 | |
| 3753 | *res = 1024; |
| 3754 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3755 | return -EIO; |
| 3756 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3757 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3758 | p = xdr_inline_decode(xdr, 8); |
| 3759 | if (unlikely(!p)) |
| 3760 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3761 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3762 | if (maxwrite > 0x7FFFFFFF) |
| 3763 | maxwrite = 0x7FFFFFFF; |
| 3764 | *res = (uint32_t)maxwrite; |
| 3765 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3766 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3767 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3768 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3769 | out_overflow: |
| 3770 | print_overflow_msg(__func__, xdr); |
| 3771 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3772 | } |
| 3773 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3774 | 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] | 3775 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3776 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3777 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3778 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | |
| 3780 | *mode = 0; |
| 3781 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3782 | return -EIO; |
| 3783 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3784 | p = xdr_inline_decode(xdr, 4); |
| 3785 | if (unlikely(!p)) |
| 3786 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3787 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3788 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3789 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3790 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3791 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3792 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3793 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3794 | out_overflow: |
| 3795 | print_overflow_msg(__func__, xdr); |
| 3796 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3797 | } |
| 3798 | |
| 3799 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3800 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3801 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3802 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | |
| 3804 | *nlink = 1; |
| 3805 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3806 | return -EIO; |
| 3807 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3808 | p = xdr_inline_decode(xdr, 4); |
| 3809 | if (unlikely(!p)) |
| 3810 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3811 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3812 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3813 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3815 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3816 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3817 | out_overflow: |
| 3818 | print_overflow_msg(__func__, xdr); |
| 3819 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | } |
| 3821 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3822 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3823 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3824 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3826 | uint32_t len; |
| 3827 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3828 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3830 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3831 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3832 | return -EIO; |
| 3833 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3834 | p = xdr_inline_decode(xdr, 4); |
| 3835 | if (unlikely(!p)) |
| 3836 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3837 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3838 | p = xdr_inline_decode(xdr, len); |
| 3839 | if (unlikely(!p)) |
| 3840 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3841 | if (owner_name != NULL) { |
| 3842 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3843 | if (owner_name->data != NULL) { |
| 3844 | owner_name->len = len; |
| 3845 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3846 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3847 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3848 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3849 | ret = NFS_ATTR_FATTR_OWNER; |
| 3850 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3851 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3852 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3853 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3854 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3855 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3856 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3857 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3858 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3859 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3860 | out_overflow: |
| 3861 | print_overflow_msg(__func__, xdr); |
| 3862 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | } |
| 3864 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3865 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3866 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3867 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3869 | uint32_t len; |
| 3870 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3871 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3872 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3873 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3874 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3875 | return -EIO; |
| 3876 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3877 | p = xdr_inline_decode(xdr, 4); |
| 3878 | if (unlikely(!p)) |
| 3879 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3880 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3881 | p = xdr_inline_decode(xdr, len); |
| 3882 | if (unlikely(!p)) |
| 3883 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3884 | if (group_name != NULL) { |
| 3885 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3886 | if (group_name->data != NULL) { |
| 3887 | group_name->len = len; |
| 3888 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3889 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3890 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3891 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3892 | ret = NFS_ATTR_FATTR_GROUP; |
| 3893 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3894 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3895 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3896 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3897 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3898 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3899 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3900 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3901 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3902 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3903 | out_overflow: |
| 3904 | print_overflow_msg(__func__, xdr); |
| 3905 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3906 | } |
| 3907 | |
| 3908 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3909 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3910 | uint32_t major = 0, minor = 0; |
| 3911 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3912 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3913 | |
| 3914 | *rdev = MKDEV(0,0); |
| 3915 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3916 | return -EIO; |
| 3917 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3918 | dev_t tmp; |
| 3919 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3920 | p = xdr_inline_decode(xdr, 8); |
| 3921 | if (unlikely(!p)) |
| 3922 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3923 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3924 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3925 | tmp = MKDEV(major, minor); |
| 3926 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3927 | *rdev = tmp; |
| 3928 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3929 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3930 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3931 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3932 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3933 | out_overflow: |
| 3934 | print_overflow_msg(__func__, xdr); |
| 3935 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | } |
| 3937 | |
| 3938 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3939 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3940 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3941 | int status = 0; |
| 3942 | |
| 3943 | *res = 0; |
| 3944 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3945 | return -EIO; |
| 3946 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3947 | p = xdr_inline_decode(xdr, 8); |
| 3948 | if (unlikely(!p)) |
| 3949 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3950 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3951 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3952 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3953 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3955 | out_overflow: |
| 3956 | print_overflow_msg(__func__, xdr); |
| 3957 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | } |
| 3959 | |
| 3960 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3961 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3962 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3963 | int status = 0; |
| 3964 | |
| 3965 | *res = 0; |
| 3966 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3967 | return -EIO; |
| 3968 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3969 | p = xdr_inline_decode(xdr, 8); |
| 3970 | if (unlikely(!p)) |
| 3971 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3972 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3974 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3975 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3976 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3977 | out_overflow: |
| 3978 | print_overflow_msg(__func__, xdr); |
| 3979 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3980 | } |
| 3981 | |
| 3982 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3983 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3984 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3985 | int status = 0; |
| 3986 | |
| 3987 | *res = 0; |
| 3988 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3989 | return -EIO; |
| 3990 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3991 | p = xdr_inline_decode(xdr, 8); |
| 3992 | if (unlikely(!p)) |
| 3993 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3994 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3995 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 3996 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3997 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3998 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3999 | out_overflow: |
| 4000 | print_overflow_msg(__func__, xdr); |
| 4001 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
| 4004 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4005 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4006 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4007 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | |
| 4009 | *used = 0; |
| 4010 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4011 | return -EIO; |
| 4012 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4013 | p = xdr_inline_decode(xdr, 8); |
| 4014 | if (unlikely(!p)) |
| 4015 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4016 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4017 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4018 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4019 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4020 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4021 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4022 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4023 | out_overflow: |
| 4024 | print_overflow_msg(__func__, xdr); |
| 4025 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4026 | } |
| 4027 | |
| 4028 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4029 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4030 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4031 | uint64_t sec; |
| 4032 | uint32_t nsec; |
| 4033 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4034 | p = xdr_inline_decode(xdr, 12); |
| 4035 | if (unlikely(!p)) |
| 4036 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4037 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4038 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4039 | time->tv_sec = (time_t)sec; |
| 4040 | time->tv_nsec = (long)nsec; |
| 4041 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4042 | out_overflow: |
| 4043 | print_overflow_msg(__func__, xdr); |
| 4044 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4045 | } |
| 4046 | |
| 4047 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4048 | { |
| 4049 | int status = 0; |
| 4050 | |
| 4051 | time->tv_sec = 0; |
| 4052 | time->tv_nsec = 0; |
| 4053 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4054 | return -EIO; |
| 4055 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4056 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4057 | if (status == 0) |
| 4058 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4060 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4061 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4062 | return status; |
| 4063 | } |
| 4064 | |
| 4065 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4066 | { |
| 4067 | int status = 0; |
| 4068 | |
| 4069 | time->tv_sec = 0; |
| 4070 | time->tv_nsec = 0; |
| 4071 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4072 | return -EIO; |
| 4073 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4074 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4075 | if (status == 0) |
| 4076 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4077 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4078 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4079 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4080 | return status; |
| 4081 | } |
| 4082 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4083 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4084 | struct timespec *time) |
| 4085 | { |
| 4086 | int status = 0; |
| 4087 | |
| 4088 | time->tv_sec = 0; |
| 4089 | time->tv_nsec = 0; |
| 4090 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4091 | return -EIO; |
| 4092 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4093 | status = decode_attr_time(xdr, time); |
| 4094 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4095 | } |
| 4096 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4097 | (long)time->tv_nsec); |
| 4098 | return status; |
| 4099 | } |
| 4100 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4101 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4102 | struct nfs4_label *label) |
| 4103 | { |
| 4104 | uint32_t pi = 0; |
| 4105 | uint32_t lfs = 0; |
| 4106 | __u32 len; |
| 4107 | __be32 *p; |
| 4108 | int status = 0; |
| 4109 | |
| 4110 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4111 | return -EIO; |
| 4112 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4113 | p = xdr_inline_decode(xdr, 4); |
| 4114 | if (unlikely(!p)) |
| 4115 | goto out_overflow; |
| 4116 | lfs = be32_to_cpup(p++); |
| 4117 | p = xdr_inline_decode(xdr, 4); |
| 4118 | if (unlikely(!p)) |
| 4119 | goto out_overflow; |
| 4120 | pi = be32_to_cpup(p++); |
| 4121 | p = xdr_inline_decode(xdr, 4); |
| 4122 | if (unlikely(!p)) |
| 4123 | goto out_overflow; |
| 4124 | len = be32_to_cpup(p++); |
| 4125 | p = xdr_inline_decode(xdr, len); |
| 4126 | if (unlikely(!p)) |
| 4127 | goto out_overflow; |
| 4128 | if (len < NFS4_MAXLABELLEN) { |
| 4129 | if (label) { |
| 4130 | memcpy(label->label, p, len); |
| 4131 | label->len = len; |
| 4132 | label->pi = pi; |
| 4133 | label->lfs = lfs; |
| 4134 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4135 | } |
| 4136 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4137 | } else |
| 4138 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4139 | __func__, len); |
| 4140 | } |
| 4141 | if (label && label->label) |
| 4142 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4143 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4144 | return status; |
| 4145 | |
| 4146 | out_overflow: |
| 4147 | print_overflow_msg(__func__, xdr); |
| 4148 | return -EIO; |
| 4149 | } |
| 4150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4151 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4152 | { |
| 4153 | int status = 0; |
| 4154 | |
| 4155 | time->tv_sec = 0; |
| 4156 | time->tv_nsec = 0; |
| 4157 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4158 | return -EIO; |
| 4159 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4160 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4161 | if (status == 0) |
| 4162 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4163 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4164 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4165 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4166 | return status; |
| 4167 | } |
| 4168 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4169 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4170 | { |
| 4171 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4172 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4173 | |
| 4174 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4175 | dprintk("%s: server returned incorrect attribute length: " |
| 4176 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4177 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4178 | attrwords << 2, |
| 4179 | (attrwords < nwords) ? '<' : '>', |
| 4180 | nwords << 2); |
| 4181 | return -EIO; |
| 4182 | } |
| 4183 | return 0; |
| 4184 | } |
| 4185 | |
| 4186 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4187 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4188 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4189 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4190 | p = xdr_inline_decode(xdr, 20); |
| 4191 | if (unlikely(!p)) |
| 4192 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4193 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4194 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4195 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4196 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4197 | out_overflow: |
| 4198 | print_overflow_msg(__func__, xdr); |
| 4199 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4200 | } |
| 4201 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4202 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4203 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4204 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4205 | uint32_t supp, acc; |
| 4206 | int status; |
| 4207 | |
| 4208 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4209 | if (status) |
| 4210 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4211 | p = xdr_inline_decode(xdr, 8); |
| 4212 | if (unlikely(!p)) |
| 4213 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4214 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4215 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4216 | *supported = supp; |
| 4217 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4218 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4219 | out_overflow: |
| 4220 | print_overflow_msg(__func__, xdr); |
| 4221 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4222 | } |
| 4223 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4224 | 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] | 4225 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4226 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4227 | |
| 4228 | p = xdr_inline_decode(xdr, len); |
| 4229 | if (likely(p)) { |
| 4230 | memcpy(buf, p, len); |
| 4231 | return 0; |
| 4232 | } |
| 4233 | print_overflow_msg(__func__, xdr); |
| 4234 | return -EIO; |
| 4235 | } |
| 4236 | |
| 4237 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4238 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4239 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4240 | } |
| 4241 | |
| 4242 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4243 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4244 | int status; |
| 4245 | |
| 4246 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4247 | if (status != -EIO) |
| 4248 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4249 | if (!status) |
| 4250 | status = decode_stateid(xdr, &res->stateid); |
| 4251 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4252 | } |
| 4253 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4254 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4255 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4256 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4257 | } |
| 4258 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4259 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4260 | { |
| 4261 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4262 | } |
| 4263 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4264 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4265 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4266 | int status; |
| 4267 | |
| 4268 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4269 | if (!status) |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4270 | status = decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4271 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4272 | } |
| 4273 | |
| 4274 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4275 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4276 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4277 | uint32_t bmlen; |
| 4278 | int status; |
| 4279 | |
| 4280 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4281 | if (status) |
| 4282 | return status; |
| 4283 | if ((status = decode_change_info(xdr, cinfo))) |
| 4284 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4285 | p = xdr_inline_decode(xdr, 4); |
| 4286 | if (unlikely(!p)) |
| 4287 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4288 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4289 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4290 | if (likely(p)) |
| 4291 | return 0; |
| 4292 | out_overflow: |
| 4293 | print_overflow_msg(__func__, xdr); |
| 4294 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4295 | } |
| 4296 | |
| 4297 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4298 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4299 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4300 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4301 | int status; |
| 4302 | |
| 4303 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4304 | goto xdr_error; |
| 4305 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4306 | goto xdr_error; |
| 4307 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4308 | goto xdr_error; |
| 4309 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4310 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4311 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4312 | &res->fh_expire_type)) != 0) |
| 4313 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4314 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4315 | goto xdr_error; |
| 4316 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4317 | goto xdr_error; |
| 4318 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4319 | goto xdr_error; |
| 4320 | status = verify_attr_len(xdr, savep, attrlen); |
| 4321 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4322 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4323 | return status; |
| 4324 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4326 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4327 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4328 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4329 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4330 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4331 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4332 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4333 | goto xdr_error; |
| 4334 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4335 | goto xdr_error; |
| 4336 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4337 | goto xdr_error; |
| 4338 | |
| 4339 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4340 | goto xdr_error; |
| 4341 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4342 | goto xdr_error; |
| 4343 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4344 | goto xdr_error; |
| 4345 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4346 | goto xdr_error; |
| 4347 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4348 | goto xdr_error; |
| 4349 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4350 | goto xdr_error; |
| 4351 | |
| 4352 | status = verify_attr_len(xdr, savep, attrlen); |
| 4353 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4354 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4355 | return status; |
| 4356 | } |
| 4357 | |
| 4358 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4359 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4360 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4361 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4362 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4363 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4364 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4365 | goto xdr_error; |
| 4366 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4367 | goto xdr_error; |
| 4368 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4369 | goto xdr_error; |
| 4370 | |
| 4371 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4372 | goto xdr_error; |
| 4373 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4374 | goto xdr_error; |
| 4375 | |
| 4376 | status = verify_attr_len(xdr, savep, attrlen); |
| 4377 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4378 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4379 | return status; |
| 4380 | } |
| 4381 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4382 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4383 | uint32_t *bitmap, |
| 4384 | uint64_t *res, |
| 4385 | uint32_t hint_bit) |
| 4386 | { |
| 4387 | __be32 *p; |
| 4388 | |
| 4389 | *res = 0; |
| 4390 | if (likely(bitmap[0] & hint_bit)) { |
| 4391 | p = xdr_inline_decode(xdr, 8); |
| 4392 | if (unlikely(!p)) |
| 4393 | goto out_overflow; |
| 4394 | xdr_decode_hyper(p, res); |
| 4395 | } |
| 4396 | return 0; |
| 4397 | out_overflow: |
| 4398 | print_overflow_msg(__func__, xdr); |
| 4399 | return -EIO; |
| 4400 | } |
| 4401 | |
| 4402 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4403 | struct nfs4_threshold *res) |
| 4404 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4405 | __be32 *p; |
| 4406 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4407 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4408 | int status; |
| 4409 | |
| 4410 | /* layout type */ |
| 4411 | p = xdr_inline_decode(xdr, 4); |
| 4412 | if (unlikely(!p)) { |
| 4413 | print_overflow_msg(__func__, xdr); |
| 4414 | return -EIO; |
| 4415 | } |
| 4416 | res->l_type = be32_to_cpup(p); |
| 4417 | |
| 4418 | /* thi_hintset bitmap */ |
| 4419 | status = decode_attr_bitmap(xdr, bitmap); |
| 4420 | if (status < 0) |
| 4421 | goto xdr_error; |
| 4422 | |
| 4423 | /* thi_hintlist length */ |
| 4424 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4425 | if (status < 0) |
| 4426 | goto xdr_error; |
| 4427 | /* thi_hintlist */ |
| 4428 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4429 | if (status < 0) |
| 4430 | goto xdr_error; |
| 4431 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4432 | if (status < 0) |
| 4433 | goto xdr_error; |
| 4434 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4435 | THRESHOLD_RD_IO); |
| 4436 | if (status < 0) |
| 4437 | goto xdr_error; |
| 4438 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4439 | THRESHOLD_WR_IO); |
| 4440 | if (status < 0) |
| 4441 | goto xdr_error; |
| 4442 | |
| 4443 | status = verify_attr_len(xdr, savep, attrlen); |
| 4444 | res->bm = bitmap[0]; |
| 4445 | |
| 4446 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4447 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4448 | res->wr_io_sz); |
| 4449 | xdr_error: |
| 4450 | dprintk("%s ret=%d!\n", __func__, status); |
| 4451 | return status; |
| 4452 | } |
| 4453 | |
| 4454 | /* |
| 4455 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4456 | */ |
| 4457 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4458 | uint32_t *bitmap, |
| 4459 | struct nfs4_threshold *res) |
| 4460 | { |
| 4461 | __be32 *p; |
| 4462 | int status = 0; |
| 4463 | uint32_t num; |
| 4464 | |
| 4465 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4466 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4467 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4468 | /* Did the server return an unrequested attribute? */ |
| 4469 | if (unlikely(res == NULL)) |
| 4470 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4471 | p = xdr_inline_decode(xdr, 4); |
| 4472 | if (unlikely(!p)) |
| 4473 | goto out_overflow; |
| 4474 | num = be32_to_cpup(p); |
| 4475 | if (num == 0) |
| 4476 | return 0; |
| 4477 | if (num > 1) |
| 4478 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4479 | "drivers per filesystem not supported\n", |
| 4480 | __func__); |
| 4481 | |
| 4482 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4483 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4484 | } |
| 4485 | return status; |
| 4486 | out_overflow: |
| 4487 | print_overflow_msg(__func__, xdr); |
| 4488 | return -EIO; |
| 4489 | } |
| 4490 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4491 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4492 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4493 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4494 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4495 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4496 | int status; |
| 4497 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4498 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4499 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4500 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4501 | status = decode_attr_type(xdr, bitmap, &type); |
| 4502 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4503 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4504 | fattr->mode = 0; |
| 4505 | if (status != 0) { |
| 4506 | fattr->mode |= nfs_type2fmt[type]; |
| 4507 | fattr->valid |= status; |
| 4508 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4509 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4510 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4511 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4512 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4513 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4514 | |
| 4515 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4516 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4517 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4518 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4519 | |
| 4520 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4521 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4522 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4523 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4524 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4525 | err = 0; |
| 4526 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4527 | if (status < 0) |
| 4528 | goto xdr_error; |
| 4529 | |
| 4530 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4531 | if (status < 0) |
| 4532 | goto xdr_error; |
| 4533 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4534 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4535 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4536 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4537 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4538 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4539 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4540 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4541 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4542 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4543 | |
| 4544 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4545 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4546 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4547 | if (status != 0) { |
| 4548 | fattr->mode |= fmode; |
| 4549 | fattr->valid |= status; |
| 4550 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4551 | |
| 4552 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4553 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4554 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4555 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4556 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4557 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4558 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4559 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4560 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4561 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4562 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4563 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4564 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4565 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4566 | |
| 4567 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4568 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4569 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4570 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4571 | |
| 4572 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4573 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4574 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4575 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4576 | |
| 4577 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4578 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4579 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4580 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4581 | |
| 4582 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4583 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4584 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4585 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4586 | |
| 4587 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4588 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4589 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4590 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4591 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4592 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4593 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4594 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4595 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4596 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4597 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4598 | if (status < 0) |
| 4599 | goto xdr_error; |
| 4600 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4601 | if (label) { |
| 4602 | status = decode_attr_security_label(xdr, bitmap, label); |
| 4603 | if (status < 0) |
| 4604 | goto xdr_error; |
| 4605 | fattr->valid |= status; |
| 4606 | } |
| 4607 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4608 | xdr_error: |
| 4609 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4610 | return status; |
| 4611 | } |
| 4612 | |
| 4613 | static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4614 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4615 | struct nfs4_label *label, const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4616 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4617 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4618 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4619 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4620 | int status; |
| 4621 | |
| 4622 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4623 | if (status < 0) |
| 4624 | goto xdr_error; |
| 4625 | |
| 4626 | status = decode_attr_bitmap(xdr, bitmap); |
| 4627 | if (status < 0) |
| 4628 | goto xdr_error; |
| 4629 | |
| 4630 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4631 | if (status < 0) |
| 4632 | goto xdr_error; |
| 4633 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4634 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
| 4635 | label, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4636 | if (status < 0) |
| 4637 | goto xdr_error; |
| 4638 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4639 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4640 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4641 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4642 | return status; |
| 4643 | } |
| 4644 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4645 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 4646 | struct nfs4_label *label, const struct nfs_server *server) |
| 4647 | { |
| 4648 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); |
| 4649 | } |
| 4650 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4651 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4652 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4653 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4654 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4655 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4657 | /* |
| 4658 | * Decode potentially multiple layout types. Currently we only support |
| 4659 | * one layout driver per file system. |
| 4660 | */ |
| 4661 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4662 | uint32_t *layouttype) |
| 4663 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4664 | __be32 *p; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4665 | int num; |
| 4666 | |
| 4667 | p = xdr_inline_decode(xdr, 4); |
| 4668 | if (unlikely(!p)) |
| 4669 | goto out_overflow; |
| 4670 | num = be32_to_cpup(p); |
| 4671 | |
| 4672 | /* pNFS is not supported by the underlying file system */ |
| 4673 | if (num == 0) { |
| 4674 | *layouttype = 0; |
| 4675 | return 0; |
| 4676 | } |
| 4677 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4678 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4679 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4680 | |
| 4681 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4682 | p = xdr_inline_decode(xdr, num * 4); |
| 4683 | if (unlikely(!p)) |
| 4684 | goto out_overflow; |
| 4685 | *layouttype = be32_to_cpup(p); |
| 4686 | return 0; |
| 4687 | out_overflow: |
| 4688 | print_overflow_msg(__func__, xdr); |
| 4689 | return -EIO; |
| 4690 | } |
| 4691 | |
| 4692 | /* |
| 4693 | * The type of file system exported. |
| 4694 | * Note we must ensure that layouttype is set in any non-error case. |
| 4695 | */ |
| 4696 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4697 | uint32_t *layouttype) |
| 4698 | { |
| 4699 | int status = 0; |
| 4700 | |
| 4701 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4702 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4703 | return -EIO; |
| 4704 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4705 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4706 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4707 | } else |
| 4708 | *layouttype = 0; |
| 4709 | return status; |
| 4710 | } |
| 4711 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4712 | /* |
| 4713 | * The prefered block size for layout directed io |
| 4714 | */ |
| 4715 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4716 | uint32_t *res) |
| 4717 | { |
| 4718 | __be32 *p; |
| 4719 | |
| 4720 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4721 | *res = 0; |
| 4722 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4723 | p = xdr_inline_decode(xdr, 4); |
| 4724 | if (unlikely(!p)) { |
| 4725 | print_overflow_msg(__func__, xdr); |
| 4726 | return -EIO; |
| 4727 | } |
| 4728 | *res = be32_to_cpup(p); |
| 4729 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4730 | } |
| 4731 | return 0; |
| 4732 | } |
| 4733 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4734 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4735 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4736 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4737 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4738 | int status; |
| 4739 | |
| 4740 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4741 | goto xdr_error; |
| 4742 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4743 | goto xdr_error; |
| 4744 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4745 | goto xdr_error; |
| 4746 | |
| 4747 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4748 | |
| 4749 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4750 | goto xdr_error; |
| 4751 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4752 | goto xdr_error; |
| 4753 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4754 | goto xdr_error; |
| 4755 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4756 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4757 | goto xdr_error; |
| 4758 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4759 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4760 | if (status != 0) |
| 4761 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4762 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4763 | if (status != 0) |
| 4764 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4765 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4766 | if (status) |
| 4767 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4768 | |
| 4769 | status = verify_attr_len(xdr, savep, attrlen); |
| 4770 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4771 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4772 | return status; |
| 4773 | } |
| 4774 | |
| 4775 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4776 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4777 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4778 | uint32_t len; |
| 4779 | int status; |
| 4780 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4781 | /* Zero handle first to allow comparisons */ |
| 4782 | memset(fh, 0, sizeof(*fh)); |
| 4783 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4784 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4785 | if (status) |
| 4786 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4787 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4788 | p = xdr_inline_decode(xdr, 4); |
| 4789 | if (unlikely(!p)) |
| 4790 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4791 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4792 | if (len > NFS4_FHSIZE) |
| 4793 | return -EIO; |
| 4794 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4795 | p = xdr_inline_decode(xdr, len); |
| 4796 | if (unlikely(!p)) |
| 4797 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4798 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4799 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4800 | out_overflow: |
| 4801 | print_overflow_msg(__func__, xdr); |
| 4802 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4803 | } |
| 4804 | |
| 4805 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4806 | { |
| 4807 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4808 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4809 | status = decode_op_hdr(xdr, OP_LINK); |
| 4810 | if (status) |
| 4811 | return status; |
| 4812 | return decode_change_info(xdr, cinfo); |
| 4813 | } |
| 4814 | |
| 4815 | /* |
| 4816 | * We create the owner, so we know a proper owner.id length is 4. |
| 4817 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4818 | 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] | 4819 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4820 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4821 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4822 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4823 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4824 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4825 | if (unlikely(!p)) |
| 4826 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4827 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4828 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4829 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4830 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4831 | fl->fl_start = (loff_t)offset; |
| 4832 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4833 | if (length == ~(uint64_t)0) |
| 4834 | fl->fl_end = OFFSET_MAX; |
| 4835 | fl->fl_type = F_WRLCK; |
| 4836 | if (type & 1) |
| 4837 | fl->fl_type = F_RDLCK; |
| 4838 | fl->fl_pid = 0; |
| 4839 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4840 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4841 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4842 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4843 | if (likely(p)) |
| 4844 | return -NFS4ERR_DENIED; |
| 4845 | out_overflow: |
| 4846 | print_overflow_msg(__func__, xdr); |
| 4847 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4848 | } |
| 4849 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4850 | 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] | 4851 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4852 | int status; |
| 4853 | |
| 4854 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4855 | if (status == -EIO) |
| 4856 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4857 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4858 | status = decode_stateid(xdr, &res->stateid); |
| 4859 | if (unlikely(status)) |
| 4860 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4861 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4862 | status = decode_lock_denied(xdr, NULL); |
| 4863 | if (res->open_seqid != NULL) |
| 4864 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4865 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4866 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4867 | return status; |
| 4868 | } |
| 4869 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4870 | 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] | 4871 | { |
| 4872 | int status; |
| 4873 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4874 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4875 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4876 | return status; |
| 4877 | } |
| 4878 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4879 | 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] | 4880 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4881 | int status; |
| 4882 | |
| 4883 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4884 | if (status != -EIO) |
| 4885 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4886 | if (status == 0) |
| 4887 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4888 | return status; |
| 4889 | } |
| 4890 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4891 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4892 | { |
| 4893 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4894 | } |
| 4895 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4896 | static int decode_lookup(struct xdr_stream *xdr) |
| 4897 | { |
| 4898 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4899 | } |
| 4900 | |
| 4901 | /* This is too sick! */ |
| 4902 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4903 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4904 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4905 | uint32_t limit_type, nblocks, blocksize; |
| 4906 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4907 | p = xdr_inline_decode(xdr, 12); |
| 4908 | if (unlikely(!p)) |
| 4909 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4910 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4911 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4912 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4913 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4914 | break; |
| 4915 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4916 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4917 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4918 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4919 | } |
| 4920 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4921 | out_overflow: |
| 4922 | print_overflow_msg(__func__, xdr); |
| 4923 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4924 | } |
| 4925 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 4926 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| 4927 | uint32_t delegation_type, |
| 4928 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4929 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4930 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4931 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4932 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4933 | status = decode_stateid(xdr, &res->delegation); |
| 4934 | if (unlikely(status)) |
| 4935 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4936 | p = xdr_inline_decode(xdr, 4); |
| 4937 | if (unlikely(!p)) |
| 4938 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4939 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4940 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4941 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4942 | case NFS4_OPEN_DELEGATE_READ: |
| 4943 | res->delegation_type = FMODE_READ; |
| 4944 | break; |
| 4945 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4946 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4947 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4948 | return -EIO; |
| 4949 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4950 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4951 | out_overflow: |
| 4952 | print_overflow_msg(__func__, xdr); |
| 4953 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4954 | } |
| 4955 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 4956 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4957 | { |
| 4958 | __be32 *p; |
| 4959 | uint32_t why_no_delegation; |
| 4960 | |
| 4961 | p = xdr_inline_decode(xdr, 4); |
| 4962 | if (unlikely(!p)) |
| 4963 | goto out_overflow; |
| 4964 | why_no_delegation = be32_to_cpup(p); |
| 4965 | switch (why_no_delegation) { |
| 4966 | case WND4_CONTENTION: |
| 4967 | case WND4_RESOURCE: |
| 4968 | xdr_inline_decode(xdr, 4); |
| 4969 | /* Ignore for now */ |
| 4970 | } |
| 4971 | return 0; |
| 4972 | out_overflow: |
| 4973 | print_overflow_msg(__func__, xdr); |
| 4974 | return -EIO; |
| 4975 | } |
| 4976 | |
| 4977 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4978 | { |
| 4979 | __be32 *p; |
| 4980 | uint32_t delegation_type; |
| 4981 | |
| 4982 | p = xdr_inline_decode(xdr, 4); |
| 4983 | if (unlikely(!p)) |
| 4984 | goto out_overflow; |
| 4985 | delegation_type = be32_to_cpup(p); |
| 4986 | res->delegation_type = 0; |
| 4987 | switch (delegation_type) { |
| 4988 | case NFS4_OPEN_DELEGATE_NONE: |
| 4989 | return 0; |
| 4990 | case NFS4_OPEN_DELEGATE_READ: |
| 4991 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4992 | return decode_rw_delegation(xdr, delegation_type, res); |
| 4993 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
| 4994 | return decode_no_delegation(xdr, res); |
| 4995 | } |
| 4996 | return -EIO; |
| 4997 | out_overflow: |
| 4998 | print_overflow_msg(__func__, xdr); |
| 4999 | return -EIO; |
| 5000 | } |
| 5001 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5002 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5003 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5004 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5005 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5006 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5007 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5008 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 5009 | return status; |
| 5010 | nfs_increment_open_seqid(status, res->seqid); |
| 5011 | if (status) |
| 5012 | return status; |
| 5013 | status = decode_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5014 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5015 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5016 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5017 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5018 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5019 | p = xdr_inline_decode(xdr, 8); |
| 5020 | if (unlikely(!p)) |
| 5021 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5022 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5023 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5024 | if (bmlen > 10) |
| 5025 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5026 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5027 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5028 | if (unlikely(!p)) |
| 5029 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5030 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5031 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5032 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5033 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5034 | res->attrset[i] = 0; |
| 5035 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5036 | return decode_delegation(xdr, res); |
| 5037 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5038 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5039 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5040 | out_overflow: |
| 5041 | print_overflow_msg(__func__, xdr); |
| 5042 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5043 | } |
| 5044 | |
| 5045 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5046 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5047 | int status; |
| 5048 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5049 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5050 | if (status != -EIO) |
| 5051 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5052 | if (!status) |
| 5053 | status = decode_stateid(xdr, &res->stateid); |
| 5054 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5055 | } |
| 5056 | |
| 5057 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5058 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5059 | int status; |
| 5060 | |
| 5061 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5062 | if (status != -EIO) |
| 5063 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5064 | if (!status) |
| 5065 | status = decode_stateid(xdr, &res->stateid); |
| 5066 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5067 | } |
| 5068 | |
| 5069 | static int decode_putfh(struct xdr_stream *xdr) |
| 5070 | { |
| 5071 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5072 | } |
| 5073 | |
| 5074 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5075 | { |
| 5076 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5077 | } |
| 5078 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5079 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5080 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5081 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5082 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5083 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5084 | int status; |
| 5085 | |
| 5086 | status = decode_op_hdr(xdr, OP_READ); |
| 5087 | if (status) |
| 5088 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5089 | p = xdr_inline_decode(xdr, 8); |
| 5090 | if (unlikely(!p)) |
| 5091 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5092 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5093 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5094 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5095 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5096 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5097 | "count %u > recvd %u\n", count, recvd); |
| 5098 | count = recvd; |
| 5099 | eof = 0; |
| 5100 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5101 | res->eof = eof; |
| 5102 | res->count = count; |
| 5103 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5104 | out_overflow: |
| 5105 | print_overflow_msg(__func__, xdr); |
| 5106 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5107 | } |
| 5108 | |
| 5109 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5110 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5111 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5112 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5113 | |
| 5114 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5115 | if (!status) |
| 5116 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5117 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5118 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5119 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5120 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5121 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5122 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5123 | } |
| 5124 | |
| 5125 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5126 | { |
| 5127 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5128 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5129 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5130 | int status; |
| 5131 | |
| 5132 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5133 | if (status) |
| 5134 | return status; |
| 5135 | |
| 5136 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5137 | p = xdr_inline_decode(xdr, 4); |
| 5138 | if (unlikely(!p)) |
| 5139 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5140 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5141 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5142 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5143 | return -ENAMETOOLONG; |
| 5144 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5145 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5146 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5147 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5148 | "count %u > recvd %u\n", len, recvd); |
| 5149 | return -EIO; |
| 5150 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | /* |
| 5152 | * The XDR encode routine has set things up so that |
| 5153 | * the link text will be copied directly into the |
| 5154 | * buffer. We just have to do overflow-checking, |
| 5155 | * and and null-terminate the text (the VFS expects |
| 5156 | * null-termination). |
| 5157 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5158 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5159 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5160 | out_overflow: |
| 5161 | print_overflow_msg(__func__, xdr); |
| 5162 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5163 | } |
| 5164 | |
| 5165 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5166 | { |
| 5167 | int status; |
| 5168 | |
| 5169 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5170 | if (status) |
| 5171 | goto out; |
| 5172 | status = decode_change_info(xdr, cinfo); |
| 5173 | out: |
| 5174 | return status; |
| 5175 | } |
| 5176 | |
| 5177 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5178 | struct nfs4_change_info *new_cinfo) |
| 5179 | { |
| 5180 | int status; |
| 5181 | |
| 5182 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5183 | if (status) |
| 5184 | goto out; |
| 5185 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5186 | goto out; |
| 5187 | status = decode_change_info(xdr, new_cinfo); |
| 5188 | out: |
| 5189 | return status; |
| 5190 | } |
| 5191 | |
| 5192 | static int decode_renew(struct xdr_stream *xdr) |
| 5193 | { |
| 5194 | return decode_op_hdr(xdr, OP_RENEW); |
| 5195 | } |
| 5196 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5197 | static int |
| 5198 | decode_restorefh(struct xdr_stream *xdr) |
| 5199 | { |
| 5200 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5201 | } |
| 5202 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5203 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5204 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5205 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5206 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5207 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5208 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5209 | int status; |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5210 | unsigned int pg_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5211 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5212 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5213 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5214 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5215 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5216 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5217 | |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5218 | /* Calculate the offset of the page data */ |
| 5219 | pg_offset = xdr->buf->head[0].iov_len; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5220 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5221 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5222 | goto out; |
| 5223 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5224 | goto out; |
| 5225 | |
| 5226 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5227 | return -EIO; |
| 5228 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5229 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5230 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5231 | * are stored with the acl data to handle the problem of |
| 5232 | * variable length bitmaps.*/ |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5233 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5234 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5235 | |
| 5236 | /* Check for receive buffer overflow */ |
| 5237 | if (res->acl_len > (xdr->nwords << 2) || |
| 5238 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5239 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5240 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5241 | attrlen, xdr->nwords << 2); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5242 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5243 | } else |
| 5244 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5245 | |
| 5246 | out: |
| 5247 | return status; |
| 5248 | } |
| 5249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5250 | static int |
| 5251 | decode_savefh(struct xdr_stream *xdr) |
| 5252 | { |
| 5253 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5254 | } |
| 5255 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5256 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5257 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5258 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | uint32_t bmlen; |
| 5260 | int status; |
| 5261 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5262 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5263 | if (status) |
| 5264 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5265 | p = xdr_inline_decode(xdr, 4); |
| 5266 | if (unlikely(!p)) |
| 5267 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5268 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5269 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5270 | if (likely(p)) |
| 5271 | return 0; |
| 5272 | out_overflow: |
| 5273 | print_overflow_msg(__func__, xdr); |
| 5274 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5275 | } |
| 5276 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5277 | 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] | 5278 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5279 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5280 | uint32_t opnum; |
| 5281 | int32_t nfserr; |
| 5282 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5283 | p = xdr_inline_decode(xdr, 8); |
| 5284 | if (unlikely(!p)) |
| 5285 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5286 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5287 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5288 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5289 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5290 | return -EIO; |
| 5291 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5292 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5293 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5294 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5295 | if (unlikely(!p)) |
| 5296 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5297 | p = xdr_decode_hyper(p, &res->clientid); |
| 5298 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5299 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5300 | uint32_t len; |
| 5301 | |
| 5302 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5303 | p = xdr_inline_decode(xdr, 4); |
| 5304 | if (unlikely(!p)) |
| 5305 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5306 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5307 | p = xdr_inline_decode(xdr, len); |
| 5308 | if (unlikely(!p)) |
| 5309 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5310 | |
| 5311 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5312 | p = xdr_inline_decode(xdr, 4); |
| 5313 | if (unlikely(!p)) |
| 5314 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5315 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5316 | p = xdr_inline_decode(xdr, len); |
| 5317 | if (unlikely(!p)) |
| 5318 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5319 | return -NFSERR_CLID_INUSE; |
| 5320 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5321 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5322 | |
| 5323 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5324 | out_overflow: |
| 5325 | print_overflow_msg(__func__, xdr); |
| 5326 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | } |
| 5328 | |
| 5329 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5330 | { |
| 5331 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5332 | } |
| 5333 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5334 | static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5335 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5336 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5337 | int status; |
| 5338 | |
| 5339 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5340 | if (status) |
| 5341 | return status; |
| 5342 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5343 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5344 | if (unlikely(!p)) |
| 5345 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5346 | res->count = be32_to_cpup(p++); |
| 5347 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5348 | return decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5349 | out_overflow: |
| 5350 | print_overflow_msg(__func__, xdr); |
| 5351 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5352 | } |
| 5353 | |
| 5354 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5355 | { |
| 5356 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5357 | } |
| 5358 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5359 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5360 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5361 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5362 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5363 | __be32 *p; |
| 5364 | |
| 5365 | p = xdr_inline_decode(xdr, 4); |
| 5366 | if (unlikely(!p)) |
| 5367 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5368 | oid_len = be32_to_cpup(p); |
| 5369 | if (oid_len > GSS_OID_MAX_LEN) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5370 | goto out_err; |
| 5371 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5372 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5373 | if (unlikely(!p)) |
| 5374 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5375 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5376 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5377 | |
| 5378 | p = xdr_inline_decode(xdr, 8); |
| 5379 | if (unlikely(!p)) |
| 5380 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5381 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5382 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5383 | |
| 5384 | return 0; |
| 5385 | |
| 5386 | out_overflow: |
| 5387 | print_overflow_msg(__func__, xdr); |
| 5388 | return -EIO; |
| 5389 | out_err: |
| 5390 | return -EINVAL; |
| 5391 | } |
| 5392 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5393 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5394 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5395 | struct nfs4_secinfo4 *sec_flavor; |
| 5396 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5397 | int status; |
| 5398 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5399 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5400 | p = xdr_inline_decode(xdr, 4); |
| 5401 | if (unlikely(!p)) |
| 5402 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5403 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5404 | res->flavors->num_flavors = 0; |
| 5405 | num_flavors = be32_to_cpup(p); |
| 5406 | |
| 5407 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5408 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5409 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5410 | break; |
| 5411 | |
| 5412 | p = xdr_inline_decode(xdr, 4); |
| 5413 | if (unlikely(!p)) |
| 5414 | goto out_overflow; |
| 5415 | sec_flavor->flavor = be32_to_cpup(p); |
| 5416 | |
| 5417 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5418 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5419 | if (status) |
| 5420 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5421 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5422 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5423 | } |
| 5424 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5425 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5426 | out: |
| 5427 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5428 | out_overflow: |
| 5429 | print_overflow_msg(__func__, xdr); |
| 5430 | return -EIO; |
| 5431 | } |
| 5432 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5433 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5434 | { |
| 5435 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5436 | if (status) |
| 5437 | return status; |
| 5438 | return decode_secinfo_common(xdr, res); |
| 5439 | } |
| 5440 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5441 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5442 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5443 | { |
| 5444 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5445 | if (status) |
| 5446 | return status; |
| 5447 | return decode_secinfo_common(xdr, res); |
| 5448 | } |
| 5449 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5450 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5451 | { |
| 5452 | __be32 *p; |
| 5453 | uint32_t bitmap_words; |
| 5454 | unsigned int i; |
| 5455 | |
| 5456 | p = xdr_inline_decode(xdr, 4); |
| 5457 | bitmap_words = be32_to_cpup(p++); |
| 5458 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) |
| 5459 | return -EIO; |
| 5460 | p = xdr_inline_decode(xdr, 4 * bitmap_words); |
| 5461 | for (i = 0; i < bitmap_words; i++) |
| 5462 | op_map->u.words[i] = be32_to_cpup(p++); |
| 5463 | |
| 5464 | return 0; |
| 5465 | } |
| 5466 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5467 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5468 | struct nfs41_exchange_id_res *res) |
| 5469 | { |
| 5470 | __be32 *p; |
| 5471 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5472 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5473 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5474 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5475 | |
| 5476 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5477 | if (status) |
| 5478 | return status; |
| 5479 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5480 | p = xdr_inline_decode(xdr, 8); |
| 5481 | if (unlikely(!p)) |
| 5482 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5483 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5484 | p = xdr_inline_decode(xdr, 12); |
| 5485 | if (unlikely(!p)) |
| 5486 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5487 | res->seqid = be32_to_cpup(p++); |
| 5488 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5489 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5490 | res->state_protect.how = be32_to_cpup(p); |
| 5491 | switch (res->state_protect.how) { |
| 5492 | case SP4_NONE: |
| 5493 | break; |
| 5494 | case SP4_MACH_CRED: |
| 5495 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5496 | if (status) |
| 5497 | return status; |
| 5498 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5499 | if (status) |
| 5500 | return status; |
| 5501 | break; |
| 5502 | default: |
| 5503 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5504 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5505 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5506 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5507 | /* server_owner4.so_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5508 | p = xdr_inline_decode(xdr, 8); |
| 5509 | if (unlikely(!p)) |
| 5510 | goto out_overflow; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5511 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5512 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5513 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5514 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5515 | if (unlikely(status)) |
| 5516 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5517 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5518 | return -EIO; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5519 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5520 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5521 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5522 | /* server_scope4 */ |
| 5523 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5524 | if (unlikely(status)) |
| 5525 | return status; |
| 5526 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5527 | return -EIO; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5528 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5529 | res->server_scope->server_scope_sz = dummy; |
| 5530 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5531 | /* Implementation Id */ |
| 5532 | p = xdr_inline_decode(xdr, 4); |
| 5533 | if (unlikely(!p)) |
| 5534 | goto out_overflow; |
| 5535 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5536 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5537 | if (impl_id_count) { |
| 5538 | /* nii_domain */ |
| 5539 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5540 | if (unlikely(status)) |
| 5541 | return status; |
| 5542 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5543 | return -EIO; |
| 5544 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5545 | |
| 5546 | /* nii_name */ |
| 5547 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5548 | if (unlikely(status)) |
| 5549 | return status; |
| 5550 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5551 | return -EIO; |
| 5552 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5553 | |
| 5554 | /* nii_date */ |
| 5555 | p = xdr_inline_decode(xdr, 12); |
| 5556 | if (unlikely(!p)) |
| 5557 | goto out_overflow; |
| 5558 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5559 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5560 | |
| 5561 | /* if there's more than one entry, ignore the rest */ |
| 5562 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5563 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5564 | out_overflow: |
| 5565 | print_overflow_msg(__func__, xdr); |
| 5566 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5567 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5568 | |
| 5569 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5570 | struct nfs4_channel_attrs *attrs) |
| 5571 | { |
| 5572 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5573 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5574 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5575 | p = xdr_inline_decode(xdr, 28); |
| 5576 | if (unlikely(!p)) |
| 5577 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5578 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5579 | if (val) |
| 5580 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5581 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5582 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5583 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5584 | attrs->max_ops = be32_to_cpup(p++); |
| 5585 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5586 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5587 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5588 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5589 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5590 | return -EINVAL; |
| 5591 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5592 | if (nr_attrs == 1) { |
| 5593 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5594 | if (unlikely(!p)) |
| 5595 | goto out_overflow; |
| 5596 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5597 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5598 | out_overflow: |
| 5599 | print_overflow_msg(__func__, xdr); |
| 5600 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5601 | } |
| 5602 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5603 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5604 | { |
| 5605 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5606 | } |
| 5607 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5608 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5609 | struct nfs41_bind_conn_to_session_res *res) |
| 5610 | { |
| 5611 | __be32 *p; |
| 5612 | int status; |
| 5613 | |
| 5614 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5615 | if (!status) |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5616 | status = decode_sessionid(xdr, &res->sessionid); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5617 | if (unlikely(status)) |
| 5618 | return status; |
| 5619 | |
| 5620 | /* dir flags, rdma mode bool */ |
| 5621 | p = xdr_inline_decode(xdr, 8); |
| 5622 | if (unlikely(!p)) |
| 5623 | goto out_overflow; |
| 5624 | |
| 5625 | res->dir = be32_to_cpup(p++); |
| 5626 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5627 | return -EIO; |
| 5628 | if (be32_to_cpup(p) == 0) |
| 5629 | res->use_conn_in_rdma_mode = false; |
| 5630 | else |
| 5631 | res->use_conn_in_rdma_mode = true; |
| 5632 | |
| 5633 | return 0; |
| 5634 | out_overflow: |
| 5635 | print_overflow_msg(__func__, xdr); |
| 5636 | return -EIO; |
| 5637 | } |
| 5638 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5639 | static int decode_create_session(struct xdr_stream *xdr, |
| 5640 | struct nfs41_create_session_res *res) |
| 5641 | { |
| 5642 | __be32 *p; |
| 5643 | int status; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5644 | |
| 5645 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5646 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5647 | status = decode_sessionid(xdr, &res->sessionid); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5648 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5649 | return status; |
| 5650 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5651 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5652 | p = xdr_inline_decode(xdr, 8); |
| 5653 | if (unlikely(!p)) |
| 5654 | goto out_overflow; |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5655 | res->seqid = be32_to_cpup(p++); |
| 5656 | res->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5657 | |
| 5658 | /* Channel attributes */ |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5659 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5660 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5661 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5662 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5663 | out_overflow: |
| 5664 | print_overflow_msg(__func__, xdr); |
| 5665 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5666 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5667 | |
| 5668 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5669 | { |
| 5670 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5671 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5672 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5673 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5674 | { |
| 5675 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5676 | } |
| 5677 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5678 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5679 | { |
| 5680 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5681 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5682 | #endif /* CONFIG_NFS_V4_1 */ |
| 5683 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5684 | static int decode_sequence(struct xdr_stream *xdr, |
| 5685 | struct nfs4_sequence_res *res, |
| 5686 | struct rpc_rqst *rqstp) |
| 5687 | { |
| 5688 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5689 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5690 | struct nfs4_sessionid id; |
| 5691 | u32 dummy; |
| 5692 | int status; |
| 5693 | __be32 *p; |
| 5694 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5695 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5696 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5697 | if (!res->sr_slot->table->session) |
| 5698 | return 0; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5699 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5700 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5701 | if (!status) |
| 5702 | status = decode_sessionid(xdr, &id); |
| 5703 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5704 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5705 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5706 | /* |
| 5707 | * If the server returns different values for sessionID, slotID or |
| 5708 | * sequence number, the server is looney tunes. |
| 5709 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5710 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5711 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5712 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5713 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5714 | NFS4_MAX_SESSIONID_LEN)) { |
| 5715 | dprintk("%s Invalid session id\n", __func__); |
| 5716 | goto out_err; |
| 5717 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5718 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5719 | p = xdr_inline_decode(xdr, 20); |
| 5720 | if (unlikely(!p)) |
| 5721 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5722 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5723 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5724 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5725 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5726 | dprintk("%s Invalid sequence number\n", __func__); |
| 5727 | goto out_err; |
| 5728 | } |
| 5729 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5730 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5731 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5732 | dprintk("%s Invalid slot id\n", __func__); |
| 5733 | goto out_err; |
| 5734 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5735 | /* highest slot id */ |
| 5736 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5737 | /* target highest slot id */ |
| 5738 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5739 | /* result flags */ |
| 5740 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5741 | status = 0; |
| 5742 | out_err: |
| 5743 | res->sr_status = status; |
| 5744 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5745 | out_overflow: |
| 5746 | print_overflow_msg(__func__, xdr); |
| 5747 | status = -EIO; |
| 5748 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5749 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5750 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5751 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5752 | } |
| 5753 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5754 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5755 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5756 | struct pnfs_device *pdev) |
| 5757 | { |
| 5758 | __be32 *p; |
| 5759 | uint32_t len, type; |
| 5760 | int status; |
| 5761 | |
| 5762 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5763 | if (status) { |
| 5764 | if (status == -ETOOSMALL) { |
| 5765 | p = xdr_inline_decode(xdr, 4); |
| 5766 | if (unlikely(!p)) |
| 5767 | goto out_overflow; |
| 5768 | pdev->mincount = be32_to_cpup(p); |
| 5769 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5770 | __func__, pdev->mincount); |
| 5771 | } |
| 5772 | return status; |
| 5773 | } |
| 5774 | |
| 5775 | p = xdr_inline_decode(xdr, 8); |
| 5776 | if (unlikely(!p)) |
| 5777 | goto out_overflow; |
| 5778 | type = be32_to_cpup(p++); |
| 5779 | if (type != pdev->layout_type) { |
| 5780 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5781 | __func__, pdev->layout_type, type); |
| 5782 | return -EINVAL; |
| 5783 | } |
| 5784 | /* |
| 5785 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5786 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5787 | * and places the remaining xdr data in xdr_buf->tail |
| 5788 | */ |
| 5789 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5790 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 5791 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5792 | |
| 5793 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5794 | p = xdr_inline_decode(xdr, 4); |
| 5795 | if (unlikely(!p)) |
| 5796 | goto out_overflow; |
| 5797 | len = be32_to_cpup(p); |
| 5798 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5799 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5800 | |
| 5801 | p = xdr_inline_decode(xdr, 4 * len); |
| 5802 | if (unlikely(!p)) |
| 5803 | goto out_overflow; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5804 | |
| 5805 | if (be32_to_cpup(p++) & |
| 5806 | ~(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE)) { |
| 5807 | dprintk("%s: unsupported notification\n", |
| 5808 | __func__); |
| 5809 | } |
| 5810 | |
| 5811 | for (i = 1; i < len; i++) { |
| 5812 | if (be32_to_cpup(p++)) { |
| 5813 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5814 | __func__); |
| 5815 | return -EIO; |
| 5816 | } |
| 5817 | } |
| 5818 | } |
| 5819 | return 0; |
| 5820 | out_overflow: |
| 5821 | print_overflow_msg(__func__, xdr); |
| 5822 | return -EIO; |
| 5823 | } |
| 5824 | |
| 5825 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5826 | struct nfs4_layoutget_res *res) |
| 5827 | { |
| 5828 | __be32 *p; |
| 5829 | int status; |
| 5830 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5831 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5832 | |
| 5833 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5834 | if (status) |
| 5835 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5836 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5837 | if (unlikely(!p)) |
| 5838 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5839 | res->return_on_close = be32_to_cpup(p); |
| 5840 | decode_stateid(xdr, &res->stateid); |
| 5841 | p = xdr_inline_decode(xdr, 4); |
| 5842 | if (unlikely(!p)) |
| 5843 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5844 | layout_count = be32_to_cpup(p); |
| 5845 | if (!layout_count) { |
| 5846 | dprintk("%s: server responded with empty layout array\n", |
| 5847 | __func__); |
| 5848 | return -EINVAL; |
| 5849 | } |
| 5850 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5851 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5852 | if (unlikely(!p)) |
| 5853 | goto out_overflow; |
| 5854 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5855 | p = xdr_decode_hyper(p, &res->range.length); |
| 5856 | res->range.iomode = be32_to_cpup(p++); |
| 5857 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5858 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5859 | |
| 5860 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5861 | __func__, |
| 5862 | (unsigned long)res->range.offset, |
| 5863 | (unsigned long)res->range.length, |
| 5864 | res->range.iomode, |
| 5865 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5866 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5867 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5868 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5869 | if (res->layoutp->len > recvd) { |
| 5870 | dprintk("NFS: server cheating in layoutget reply: " |
| 5871 | "layout len %u > recvd %u\n", |
| 5872 | res->layoutp->len, recvd); |
| 5873 | return -EINVAL; |
| 5874 | } |
| 5875 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5876 | if (layout_count > 1) { |
| 5877 | /* We only handle a length one array at the moment. Any |
| 5878 | * further entries are just ignored. Note that this means |
| 5879 | * the client may see a response that is less than the |
| 5880 | * minimum it requested. |
| 5881 | */ |
| 5882 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5883 | __func__, layout_count); |
| 5884 | } |
| 5885 | |
| 5886 | return 0; |
| 5887 | out_overflow: |
| 5888 | print_overflow_msg(__func__, xdr); |
| 5889 | return -EIO; |
| 5890 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5891 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5892 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5893 | struct nfs4_layoutreturn_res *res) |
| 5894 | { |
| 5895 | __be32 *p; |
| 5896 | int status; |
| 5897 | |
| 5898 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5899 | if (status) |
| 5900 | return status; |
| 5901 | p = xdr_inline_decode(xdr, 4); |
| 5902 | if (unlikely(!p)) |
| 5903 | goto out_overflow; |
| 5904 | res->lrs_present = be32_to_cpup(p); |
| 5905 | if (res->lrs_present) |
| 5906 | status = decode_stateid(xdr, &res->stateid); |
| 5907 | return status; |
| 5908 | out_overflow: |
| 5909 | print_overflow_msg(__func__, xdr); |
| 5910 | return -EIO; |
| 5911 | } |
| 5912 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5913 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5914 | struct rpc_rqst *req, |
| 5915 | struct nfs4_layoutcommit_res *res) |
| 5916 | { |
| 5917 | __be32 *p; |
| 5918 | __u32 sizechanged; |
| 5919 | int status; |
| 5920 | |
| 5921 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5922 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5923 | if (status) |
| 5924 | return status; |
| 5925 | |
| 5926 | p = xdr_inline_decode(xdr, 4); |
| 5927 | if (unlikely(!p)) |
| 5928 | goto out_overflow; |
| 5929 | sizechanged = be32_to_cpup(p); |
| 5930 | |
| 5931 | if (sizechanged) { |
| 5932 | /* throw away new size */ |
| 5933 | p = xdr_inline_decode(xdr, 8); |
| 5934 | if (unlikely(!p)) |
| 5935 | goto out_overflow; |
| 5936 | } |
| 5937 | return 0; |
| 5938 | out_overflow: |
| 5939 | print_overflow_msg(__func__, xdr); |
| 5940 | return -EIO; |
| 5941 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5942 | |
| 5943 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5944 | struct nfs41_test_stateid_res *res) |
| 5945 | { |
| 5946 | __be32 *p; |
| 5947 | int status; |
| 5948 | int num_res; |
| 5949 | |
| 5950 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5951 | if (status) |
| 5952 | return status; |
| 5953 | |
| 5954 | p = xdr_inline_decode(xdr, 4); |
| 5955 | if (unlikely(!p)) |
| 5956 | goto out_overflow; |
| 5957 | num_res = be32_to_cpup(p++); |
| 5958 | if (num_res != 1) |
| 5959 | goto out; |
| 5960 | |
| 5961 | p = xdr_inline_decode(xdr, 4); |
| 5962 | if (unlikely(!p)) |
| 5963 | goto out_overflow; |
| 5964 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5965 | |
| 5966 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5967 | out_overflow: |
| 5968 | print_overflow_msg(__func__, xdr); |
| 5969 | out: |
| 5970 | return -EIO; |
| 5971 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5972 | |
| 5973 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5974 | struct nfs41_free_stateid_res *res) |
| 5975 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 5976 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5977 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5978 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5979 | #endif /* CONFIG_NFS_V4_1 */ |
| 5980 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5981 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5982 | * END OF "GENERIC" DECODE ROUTINES. |
| 5983 | */ |
| 5984 | |
| 5985 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5986 | * Decode OPEN_DOWNGRADE response |
| 5987 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5988 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5989 | struct xdr_stream *xdr, |
| 5990 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5991 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5992 | struct compound_hdr hdr; |
| 5993 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5994 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5995 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5996 | if (status) |
| 5997 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5998 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5999 | if (status) |
| 6000 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6001 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6002 | if (status) |
| 6003 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6004 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6005 | if (status != 0) |
| 6006 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6007 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6008 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6009 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6010 | } |
| 6011 | |
| 6012 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6013 | * Decode ACCESS response |
| 6014 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6015 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6016 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6017 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6018 | struct compound_hdr hdr; |
| 6019 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6020 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6021 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6022 | if (status) |
| 6023 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6024 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6025 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6026 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6027 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6028 | if (status != 0) |
| 6029 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6030 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6031 | if (status != 0) |
| 6032 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6033 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6034 | out: |
| 6035 | return status; |
| 6036 | } |
| 6037 | |
| 6038 | /* |
| 6039 | * Decode LOOKUP response |
| 6040 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6041 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6042 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6043 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6044 | struct compound_hdr hdr; |
| 6045 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6046 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6047 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6048 | if (status) |
| 6049 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6050 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6051 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6052 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6053 | status = decode_putfh(xdr); |
| 6054 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6055 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6056 | status = decode_lookup(xdr); |
| 6057 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6058 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6059 | status = decode_getfh(xdr, res->fh); |
| 6060 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6061 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6062 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6063 | out: |
| 6064 | return status; |
| 6065 | } |
| 6066 | |
| 6067 | /* |
| 6068 | * Decode LOOKUP_ROOT response |
| 6069 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6070 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6071 | struct xdr_stream *xdr, |
| 6072 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6074 | struct compound_hdr hdr; |
| 6075 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6076 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6077 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6078 | if (status) |
| 6079 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6080 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6081 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6082 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6083 | status = decode_putrootfh(xdr); |
| 6084 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6085 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6086 | status = decode_getfh(xdr, res->fh); |
| 6087 | if (status == 0) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6088 | status = decode_getfattr_label(xdr, res->fattr, |
| 6089 | res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6090 | out: |
| 6091 | return status; |
| 6092 | } |
| 6093 | |
| 6094 | /* |
| 6095 | * Decode REMOVE response |
| 6096 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6097 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6098 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6099 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6100 | struct compound_hdr hdr; |
| 6101 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6102 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6103 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6104 | if (status) |
| 6105 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6106 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6107 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6108 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6109 | status = decode_putfh(xdr); |
| 6110 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6111 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6112 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6113 | out: |
| 6114 | return status; |
| 6115 | } |
| 6116 | |
| 6117 | /* |
| 6118 | * Decode RENAME response |
| 6119 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6120 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6121 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6122 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6123 | struct compound_hdr hdr; |
| 6124 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6125 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6126 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6127 | if (status) |
| 6128 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6129 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6130 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6131 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6132 | status = decode_putfh(xdr); |
| 6133 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6134 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6135 | status = decode_savefh(xdr); |
| 6136 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6137 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6138 | status = decode_putfh(xdr); |
| 6139 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6140 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6141 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | out: |
| 6143 | return status; |
| 6144 | } |
| 6145 | |
| 6146 | /* |
| 6147 | * Decode LINK response |
| 6148 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6149 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6150 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6151 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6152 | struct compound_hdr hdr; |
| 6153 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6154 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6155 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6156 | if (status) |
| 6157 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6158 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6159 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6160 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6161 | status = decode_putfh(xdr); |
| 6162 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6163 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6164 | status = decode_savefh(xdr); |
| 6165 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6166 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6167 | status = decode_putfh(xdr); |
| 6168 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6170 | status = decode_link(xdr, &res->cinfo); |
| 6171 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6172 | goto out; |
| 6173 | /* |
| 6174 | * Note order: OP_LINK leaves the directory as the current |
| 6175 | * filehandle. |
| 6176 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6177 | status = decode_restorefh(xdr); |
| 6178 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6179 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6180 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | out: |
| 6182 | return status; |
| 6183 | } |
| 6184 | |
| 6185 | /* |
| 6186 | * Decode CREATE response |
| 6187 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6188 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6189 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6190 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6191 | struct compound_hdr hdr; |
| 6192 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6193 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6194 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6195 | if (status) |
| 6196 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6197 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6198 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6199 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6200 | status = decode_putfh(xdr); |
| 6201 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6203 | status = decode_create(xdr, &res->dir_cinfo); |
| 6204 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6205 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6206 | status = decode_getfh(xdr, res->fh); |
| 6207 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6208 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6209 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6210 | out: |
| 6211 | return status; |
| 6212 | } |
| 6213 | |
| 6214 | /* |
| 6215 | * Decode SYMLINK response |
| 6216 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6217 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6218 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6219 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6220 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6221 | } |
| 6222 | |
| 6223 | /* |
| 6224 | * Decode GETATTR response |
| 6225 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6226 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6227 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | struct compound_hdr hdr; |
| 6230 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6231 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6232 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6233 | if (status) |
| 6234 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6235 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6236 | if (status) |
| 6237 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6238 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6239 | if (status) |
| 6240 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6241 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6242 | out: |
| 6243 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | } |
| 6245 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6246 | /* |
| 6247 | * Encode an SETACL request |
| 6248 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6249 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6250 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6251 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6252 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6253 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6254 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6255 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6256 | encode_compound_hdr(xdr, req, &hdr); |
| 6257 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6258 | encode_putfh(xdr, args->fh, &hdr); |
| 6259 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6260 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6261 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6262 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6263 | /* |
| 6264 | * Decode SETACL response |
| 6265 | */ |
| 6266 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6267 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6268 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6269 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6270 | struct compound_hdr hdr; |
| 6271 | int status; |
| 6272 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6273 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6274 | if (status) |
| 6275 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6276 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6277 | if (status) |
| 6278 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6279 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6280 | if (status) |
| 6281 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6282 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6283 | out: |
| 6284 | return status; |
| 6285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6286 | |
| 6287 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6288 | * Decode GETACL response |
| 6289 | */ |
| 6290 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6291 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6292 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6293 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6294 | struct compound_hdr hdr; |
| 6295 | int status; |
| 6296 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6297 | if (res->acl_scratch != NULL) { |
| 6298 | void *p = page_address(res->acl_scratch); |
| 6299 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6300 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6301 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6302 | if (status) |
| 6303 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6304 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6305 | if (status) |
| 6306 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6307 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6308 | if (status) |
| 6309 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6310 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6311 | |
| 6312 | out: |
| 6313 | return status; |
| 6314 | } |
| 6315 | |
| 6316 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6317 | * Decode CLOSE response |
| 6318 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6319 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6320 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6321 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6322 | struct compound_hdr hdr; |
| 6323 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6324 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6326 | if (status) |
| 6327 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6328 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6329 | if (status) |
| 6330 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6332 | if (status) |
| 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6335 | if (status != 0) |
| 6336 | goto out; |
| 6337 | /* |
| 6338 | * Note: Server may do delete on close for this file |
| 6339 | * in which case the getattr call will fail with |
| 6340 | * an ESTALE error. Shouldn't be a problem, |
| 6341 | * though, since fattr->valid will remain unset. |
| 6342 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6343 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6344 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6345 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6346 | } |
| 6347 | |
| 6348 | /* |
| 6349 | * Decode OPEN response |
| 6350 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6351 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6352 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6353 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6354 | struct compound_hdr hdr; |
| 6355 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6356 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6357 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6358 | if (status) |
| 6359 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6360 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6361 | if (status) |
| 6362 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6363 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6364 | if (status) |
| 6365 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6366 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6367 | if (status) |
| 6368 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6369 | status = decode_getfh(xdr, &res->fh); |
| 6370 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6372 | if (res->access_request) |
| 6373 | decode_access(xdr, &res->access_supported, &res->access_result); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6374 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6376 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6377 | } |
| 6378 | |
| 6379 | /* |
| 6380 | * Decode OPEN_CONFIRM response |
| 6381 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6382 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6383 | struct xdr_stream *xdr, |
| 6384 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6385 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6386 | struct compound_hdr hdr; |
| 6387 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6388 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6389 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6390 | if (status) |
| 6391 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6392 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6393 | if (status) |
| 6394 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6395 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6396 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6397 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | } |
| 6399 | |
| 6400 | /* |
| 6401 | * Decode OPEN response |
| 6402 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6403 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6404 | struct xdr_stream *xdr, |
| 6405 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6406 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6407 | struct compound_hdr hdr; |
| 6408 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6409 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6410 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6411 | if (status) |
| 6412 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6413 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6414 | if (status) |
| 6415 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6416 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6417 | if (status) |
| 6418 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6419 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6420 | if (status) |
| 6421 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6422 | if (res->access_request) |
| 6423 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6424 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6425 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6426 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6427 | } |
| 6428 | |
| 6429 | /* |
| 6430 | * Decode SETATTR response |
| 6431 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6432 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6433 | struct xdr_stream *xdr, |
| 6434 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6435 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6436 | struct compound_hdr hdr; |
| 6437 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6438 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6439 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6440 | if (status) |
| 6441 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6442 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6443 | if (status) |
| 6444 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6445 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6446 | if (status) |
| 6447 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6448 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6449 | if (status) |
| 6450 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6451 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6452 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6453 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6454 | } |
| 6455 | |
| 6456 | /* |
| 6457 | * Decode LOCK response |
| 6458 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6459 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6460 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6461 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6462 | struct compound_hdr hdr; |
| 6463 | int status; |
| 6464 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6465 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6466 | if (status) |
| 6467 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6468 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6469 | if (status) |
| 6470 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6471 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6472 | if (status) |
| 6473 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6474 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | out: |
| 6476 | return status; |
| 6477 | } |
| 6478 | |
| 6479 | /* |
| 6480 | * Decode LOCKT response |
| 6481 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6482 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6483 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6484 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6485 | struct compound_hdr hdr; |
| 6486 | int status; |
| 6487 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6488 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6489 | if (status) |
| 6490 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6491 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6492 | if (status) |
| 6493 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6494 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | if (status) |
| 6496 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6497 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6498 | out: |
| 6499 | return status; |
| 6500 | } |
| 6501 | |
| 6502 | /* |
| 6503 | * Decode LOCKU response |
| 6504 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6505 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6506 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6507 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6508 | struct compound_hdr hdr; |
| 6509 | int status; |
| 6510 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6511 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6512 | if (status) |
| 6513 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6514 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6515 | if (status) |
| 6516 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6517 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | if (status) |
| 6519 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6520 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6521 | out: |
| 6522 | return status; |
| 6523 | } |
| 6524 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6525 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6526 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6527 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6528 | struct compound_hdr hdr; |
| 6529 | int status; |
| 6530 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6531 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6532 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6533 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6534 | return status; |
| 6535 | } |
| 6536 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6537 | /* |
| 6538 | * Decode READLINK response |
| 6539 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6540 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6541 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6542 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6543 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6544 | struct compound_hdr hdr; |
| 6545 | int status; |
| 6546 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6547 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6548 | if (status) |
| 6549 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6550 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6551 | if (status) |
| 6552 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6553 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | if (status) |
| 6555 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6556 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6557 | out: |
| 6558 | return status; |
| 6559 | } |
| 6560 | |
| 6561 | /* |
| 6562 | * Decode READDIR response |
| 6563 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6564 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6565 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6566 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6567 | struct compound_hdr hdr; |
| 6568 | int status; |
| 6569 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6570 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6571 | if (status) |
| 6572 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6573 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6574 | if (status) |
| 6575 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6576 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | if (status) |
| 6578 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6579 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6580 | out: |
| 6581 | return status; |
| 6582 | } |
| 6583 | |
| 6584 | /* |
| 6585 | * Decode Read response |
| 6586 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6587 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6588 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6589 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6590 | struct compound_hdr hdr; |
| 6591 | int status; |
| 6592 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6593 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6594 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6595 | if (status) |
| 6596 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6597 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6598 | if (status) |
| 6599 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6600 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6601 | if (status) |
| 6602 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6603 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6604 | if (!status) |
| 6605 | status = res->count; |
| 6606 | out: |
| 6607 | return status; |
| 6608 | } |
| 6609 | |
| 6610 | /* |
| 6611 | * Decode WRITE response |
| 6612 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6613 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6614 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6615 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6616 | struct compound_hdr hdr; |
| 6617 | int status; |
| 6618 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6619 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6620 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6621 | if (status) |
| 6622 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6623 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6624 | if (status) |
| 6625 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6626 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6627 | if (status) |
| 6628 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6629 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6630 | if (status) |
| 6631 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6632 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6633 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6634 | if (!status) |
| 6635 | status = res->count; |
| 6636 | out: |
| 6637 | return status; |
| 6638 | } |
| 6639 | |
| 6640 | /* |
| 6641 | * Decode COMMIT response |
| 6642 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6643 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 6644 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6645 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6646 | struct compound_hdr hdr; |
| 6647 | int status; |
| 6648 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6649 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6650 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6651 | if (status) |
| 6652 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6653 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6654 | if (status) |
| 6655 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6656 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6657 | if (status) |
| 6658 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6659 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6660 | out: |
| 6661 | return status; |
| 6662 | } |
| 6663 | |
| 6664 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6665 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6666 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | 3dda5e4 | 2009-04-01 09:21:57 -0400 | [diff] [blame] | 6668 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6669 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6670 | struct compound_hdr hdr; |
| 6671 | int status; |
| 6672 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6673 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6674 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6675 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6676 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6677 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6678 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6679 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6680 | return status; |
| 6681 | } |
| 6682 | |
| 6683 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6684 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6685 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6686 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | d45b298 | 2009-04-01 09:21:58 -0400 | [diff] [blame] | 6687 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6688 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6689 | struct compound_hdr hdr; |
| 6690 | int status; |
| 6691 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6692 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6693 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6695 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6696 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6697 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6698 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6699 | return status; |
| 6700 | } |
| 6701 | |
| 6702 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6703 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6704 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6705 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | 24ad148 | 2009-04-01 09:21:56 -0400 | [diff] [blame] | 6706 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6707 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6708 | struct compound_hdr hdr; |
| 6709 | int status; |
| 6710 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6711 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6712 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6713 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6714 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6715 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6716 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6717 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6718 | return status; |
| 6719 | } |
| 6720 | |
| 6721 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6722 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6723 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6724 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6725 | struct xdr_stream *xdr, |
| 6726 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6727 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6728 | struct compound_hdr hdr; |
| 6729 | int status; |
| 6730 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6731 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6732 | if (status) |
| 6733 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6734 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6735 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6736 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6737 | status = decode_putfh(xdr); |
| 6738 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6739 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6740 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6741 | out: |
| 6742 | return status; |
| 6743 | } |
| 6744 | |
| 6745 | /* |
| 6746 | * Decode RENEW response |
| 6747 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6748 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6749 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6750 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6751 | struct compound_hdr hdr; |
| 6752 | int status; |
| 6753 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6754 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6755 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6756 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6757 | return status; |
| 6758 | } |
| 6759 | |
| 6760 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6761 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6762 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6763 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6764 | struct xdr_stream *xdr, |
| 6765 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6766 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6767 | struct compound_hdr hdr; |
| 6768 | int status; |
| 6769 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6770 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6771 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6772 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6773 | return status; |
| 6774 | } |
| 6775 | |
| 6776 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6777 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6778 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6779 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 6780 | struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6781 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6782 | struct compound_hdr hdr; |
| 6783 | int status; |
| 6784 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6785 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6786 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6787 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6788 | return status; |
| 6789 | } |
| 6790 | |
| 6791 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6792 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6793 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6794 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6795 | struct xdr_stream *xdr, |
| 6796 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6797 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6798 | struct compound_hdr hdr; |
| 6799 | int status; |
| 6800 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6801 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6802 | if (status) |
| 6803 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6804 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6805 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6806 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6807 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6808 | if (status != 0) |
| 6809 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6810 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6811 | if (status != 0) |
| 6812 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6813 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6814 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6815 | return status; |
| 6816 | } |
| 6817 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6818 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6819 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6820 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6821 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6822 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6823 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6824 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6825 | struct compound_hdr hdr; |
| 6826 | int status; |
| 6827 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6828 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6829 | if (status) |
| 6830 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6831 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6832 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6833 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6834 | status = decode_putfh(xdr); |
| 6835 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6836 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6837 | if (res->migration) { |
| 6838 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6839 | status = decode_getfattr_generic(xdr, |
| 6840 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6841 | NULL, res->fs_locations, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6842 | NULL, res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6843 | if (status) |
| 6844 | goto out; |
| 6845 | if (res->renew) |
| 6846 | status = decode_renew(xdr); |
| 6847 | } else { |
| 6848 | status = decode_lookup(xdr); |
| 6849 | if (status) |
| 6850 | goto out; |
| 6851 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6852 | status = decode_getfattr_generic(xdr, |
| 6853 | &res->fs_locations->fattr, |
| 6854 | NULL, res->fs_locations, |
| 6855 | NULL, res->fs_locations->server); |
| 6856 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6857 | out: |
| 6858 | return status; |
| 6859 | } |
| 6860 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6861 | /* |
| 6862 | * Decode SECINFO response |
| 6863 | */ |
| 6864 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6865 | struct xdr_stream *xdr, |
| 6866 | struct nfs4_secinfo_res *res) |
| 6867 | { |
| 6868 | struct compound_hdr hdr; |
| 6869 | int status; |
| 6870 | |
| 6871 | status = decode_compound_hdr(xdr, &hdr); |
| 6872 | if (status) |
| 6873 | goto out; |
| 6874 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6875 | if (status) |
| 6876 | goto out; |
| 6877 | status = decode_putfh(xdr); |
| 6878 | if (status) |
| 6879 | goto out; |
| 6880 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6881 | out: |
| 6882 | return status; |
| 6883 | } |
| 6884 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 6885 | /* |
| 6886 | * Decode FSID_PRESENT response |
| 6887 | */ |
| 6888 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 6889 | struct xdr_stream *xdr, |
| 6890 | struct nfs4_fsid_present_res *res) |
| 6891 | { |
| 6892 | struct compound_hdr hdr; |
| 6893 | int status; |
| 6894 | |
| 6895 | status = decode_compound_hdr(xdr, &hdr); |
| 6896 | if (status) |
| 6897 | goto out; |
| 6898 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6899 | if (status) |
| 6900 | goto out; |
| 6901 | status = decode_putfh(xdr); |
| 6902 | if (status) |
| 6903 | goto out; |
| 6904 | status = decode_getfh(xdr, res->fh); |
| 6905 | if (status) |
| 6906 | goto out; |
| 6907 | if (res->renew) |
| 6908 | status = decode_renew(xdr); |
| 6909 | out: |
| 6910 | return status; |
| 6911 | } |
| 6912 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6913 | #if defined(CONFIG_NFS_V4_1) |
| 6914 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 6915 | * Decode BIND_CONN_TO_SESSION response |
| 6916 | */ |
| 6917 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 6918 | struct xdr_stream *xdr, |
| 6919 | void *res) |
| 6920 | { |
| 6921 | struct compound_hdr hdr; |
| 6922 | int status; |
| 6923 | |
| 6924 | status = decode_compound_hdr(xdr, &hdr); |
| 6925 | if (!status) |
| 6926 | status = decode_bind_conn_to_session(xdr, res); |
| 6927 | return status; |
| 6928 | } |
| 6929 | |
| 6930 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6931 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6932 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6933 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6934 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6935 | void *res) |
| 6936 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6937 | struct compound_hdr hdr; |
| 6938 | int status; |
| 6939 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6940 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6941 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6942 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6943 | return status; |
| 6944 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6945 | |
| 6946 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6947 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6948 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6949 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6950 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6951 | struct nfs41_create_session_res *res) |
| 6952 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6953 | struct compound_hdr hdr; |
| 6954 | int status; |
| 6955 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6956 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6957 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6958 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6959 | return status; |
| 6960 | } |
| 6961 | |
| 6962 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6963 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6964 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6965 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6966 | struct xdr_stream *xdr, |
| 6967 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6968 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6969 | struct compound_hdr hdr; |
| 6970 | int status; |
| 6971 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6972 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6973 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6974 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6975 | return status; |
| 6976 | } |
| 6977 | |
| 6978 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 6979 | * Decode DESTROY_CLIENTID response |
| 6980 | */ |
| 6981 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 6982 | struct xdr_stream *xdr, |
| 6983 | void *res) |
| 6984 | { |
| 6985 | struct compound_hdr hdr; |
| 6986 | int status; |
| 6987 | |
| 6988 | status = decode_compound_hdr(xdr, &hdr); |
| 6989 | if (!status) |
| 6990 | status = decode_destroy_clientid(xdr, res); |
| 6991 | return status; |
| 6992 | } |
| 6993 | |
| 6994 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6995 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6996 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6997 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6998 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6999 | struct nfs4_sequence_res *res) |
| 7000 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7001 | struct compound_hdr hdr; |
| 7002 | int status; |
| 7003 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7004 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7005 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7006 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7007 | return status; |
| 7008 | } |
| 7009 | |
| 7010 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7011 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7012 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7013 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 7014 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7015 | struct nfs4_get_lease_time_res *res) |
| 7016 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7017 | struct compound_hdr hdr; |
| 7018 | int status; |
| 7019 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7020 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7021 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7022 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7023 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7024 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7025 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7026 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7027 | return status; |
| 7028 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7029 | |
| 7030 | /* |
| 7031 | * Decode RECLAIM_COMPLETE response |
| 7032 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7033 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7034 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7035 | struct nfs41_reclaim_complete_res *res) |
| 7036 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7037 | struct compound_hdr hdr; |
| 7038 | int status; |
| 7039 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7040 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7041 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7042 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7043 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7044 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7045 | return status; |
| 7046 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7047 | |
| 7048 | /* |
| 7049 | * Decode GETDEVINFO response |
| 7050 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7051 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7052 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7053 | struct nfs4_getdeviceinfo_res *res) |
| 7054 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7055 | struct compound_hdr hdr; |
| 7056 | int status; |
| 7057 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7058 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7059 | if (status != 0) |
| 7060 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7061 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7062 | if (status != 0) |
| 7063 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7064 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7065 | out: |
| 7066 | return status; |
| 7067 | } |
| 7068 | |
| 7069 | /* |
| 7070 | * Decode LAYOUTGET response |
| 7071 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7072 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7073 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7074 | struct nfs4_layoutget_res *res) |
| 7075 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7076 | struct compound_hdr hdr; |
| 7077 | int status; |
| 7078 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7079 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7080 | if (status) |
| 7081 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7082 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7083 | if (status) |
| 7084 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7085 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7086 | if (status) |
| 7087 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7088 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7089 | out: |
| 7090 | return status; |
| 7091 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7092 | |
| 7093 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7094 | * Decode LAYOUTRETURN response |
| 7095 | */ |
| 7096 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7097 | struct xdr_stream *xdr, |
| 7098 | struct nfs4_layoutreturn_res *res) |
| 7099 | { |
| 7100 | struct compound_hdr hdr; |
| 7101 | int status; |
| 7102 | |
| 7103 | status = decode_compound_hdr(xdr, &hdr); |
| 7104 | if (status) |
| 7105 | goto out; |
| 7106 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7107 | if (status) |
| 7108 | goto out; |
| 7109 | status = decode_putfh(xdr); |
| 7110 | if (status) |
| 7111 | goto out; |
| 7112 | status = decode_layoutreturn(xdr, res); |
| 7113 | out: |
| 7114 | return status; |
| 7115 | } |
| 7116 | |
| 7117 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7118 | * Decode LAYOUTCOMMIT response |
| 7119 | */ |
| 7120 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7121 | struct xdr_stream *xdr, |
| 7122 | struct nfs4_layoutcommit_res *res) |
| 7123 | { |
| 7124 | struct compound_hdr hdr; |
| 7125 | int status; |
| 7126 | |
| 7127 | status = decode_compound_hdr(xdr, &hdr); |
| 7128 | if (status) |
| 7129 | goto out; |
| 7130 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7131 | if (status) |
| 7132 | goto out; |
| 7133 | status = decode_putfh(xdr); |
| 7134 | if (status) |
| 7135 | goto out; |
| 7136 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7137 | if (status) |
| 7138 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7139 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7140 | out: |
| 7141 | return status; |
| 7142 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7143 | |
| 7144 | /* |
| 7145 | * Decode SECINFO_NO_NAME response |
| 7146 | */ |
| 7147 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7148 | struct xdr_stream *xdr, |
| 7149 | struct nfs4_secinfo_res *res) |
| 7150 | { |
| 7151 | struct compound_hdr hdr; |
| 7152 | int status; |
| 7153 | |
| 7154 | status = decode_compound_hdr(xdr, &hdr); |
| 7155 | if (status) |
| 7156 | goto out; |
| 7157 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7158 | if (status) |
| 7159 | goto out; |
| 7160 | status = decode_putrootfh(xdr); |
| 7161 | if (status) |
| 7162 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7163 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7164 | out: |
| 7165 | return status; |
| 7166 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7167 | |
| 7168 | /* |
| 7169 | * Decode TEST_STATEID response |
| 7170 | */ |
| 7171 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7172 | struct xdr_stream *xdr, |
| 7173 | struct nfs41_test_stateid_res *res) |
| 7174 | { |
| 7175 | struct compound_hdr hdr; |
| 7176 | int status; |
| 7177 | |
| 7178 | status = decode_compound_hdr(xdr, &hdr); |
| 7179 | if (status) |
| 7180 | goto out; |
| 7181 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7182 | if (status) |
| 7183 | goto out; |
| 7184 | status = decode_test_stateid(xdr, res); |
| 7185 | out: |
| 7186 | return status; |
| 7187 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7188 | |
| 7189 | /* |
| 7190 | * Decode FREE_STATEID response |
| 7191 | */ |
| 7192 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7193 | struct xdr_stream *xdr, |
| 7194 | struct nfs41_free_stateid_res *res) |
| 7195 | { |
| 7196 | struct compound_hdr hdr; |
| 7197 | int status; |
| 7198 | |
| 7199 | status = decode_compound_hdr(xdr, &hdr); |
| 7200 | if (status) |
| 7201 | goto out; |
| 7202 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7203 | if (status) |
| 7204 | goto out; |
| 7205 | status = decode_free_stateid(xdr, res); |
| 7206 | out: |
| 7207 | return status; |
| 7208 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7209 | #endif /* CONFIG_NFS_V4_1 */ |
| 7210 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7211 | /** |
| 7212 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7213 | * the local page cache. |
| 7214 | * @xdr: XDR stream where entry resides |
| 7215 | * @entry: buffer to fill in with entry data |
| 7216 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7217 | * |
| 7218 | * Returns zero if successful, otherwise a negative errno value is |
| 7219 | * returned. |
| 7220 | * |
| 7221 | * This function is not invoked during READDIR reply decoding, but |
| 7222 | * rather whenever an application invokes the getdents(2) system call |
| 7223 | * on a directory already in our cache. |
| 7224 | */ |
| 7225 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 7226 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7227 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7228 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7229 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7230 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7231 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7232 | if (unlikely(!p)) |
| 7233 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7234 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7235 | p = xdr_inline_decode(xdr, 4); |
| 7236 | if (unlikely(!p)) |
| 7237 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7238 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7239 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7240 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7241 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7242 | } |
| 7243 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7244 | p = xdr_inline_decode(xdr, 12); |
| 7245 | if (unlikely(!p)) |
| 7246 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7247 | entry->prev_cookie = entry->cookie; |
| 7248 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7249 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7250 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7251 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7252 | if (unlikely(!p)) |
| 7253 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7254 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7255 | |
| 7256 | /* |
| 7257 | * In case the server doesn't return an inode number, |
| 7258 | * we fake one here. (We don't use inode number 0, |
| 7259 | * since glibc seems to choke on it...) |
| 7260 | */ |
| 7261 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7262 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7263 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7264 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7265 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7266 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7267 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7268 | goto out_overflow; |
| 7269 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7270 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7271 | NULL, entry->label, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7272 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7273 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7274 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7275 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7276 | entry->ino = entry->fattr->fileid; |
| 7277 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7278 | entry->d_type = DT_UNKNOWN; |
| 7279 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7280 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7281 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7282 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7283 | |
| 7284 | out_overflow: |
| 7285 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7286 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7287 | } |
| 7288 | |
| 7289 | /* |
| 7290 | * We need to translate between nfs status return values and |
| 7291 | * the local errno values which may not be the same. |
| 7292 | */ |
| 7293 | static struct { |
| 7294 | int stat; |
| 7295 | int errno; |
| 7296 | } nfs_errtbl[] = { |
| 7297 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7298 | { NFS4ERR_PERM, -EPERM }, |
| 7299 | { NFS4ERR_NOENT, -ENOENT }, |
| 7300 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7301 | { NFS4ERR_NXIO, -ENXIO }, |
| 7302 | { NFS4ERR_ACCESS, -EACCES }, |
| 7303 | { NFS4ERR_EXIST, -EEXIST }, |
| 7304 | { NFS4ERR_XDEV, -EXDEV }, |
| 7305 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7306 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7307 | { NFS4ERR_INVAL, -EINVAL }, |
| 7308 | { NFS4ERR_FBIG, -EFBIG }, |
| 7309 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7310 | { NFS4ERR_ROFS, -EROFS }, |
| 7311 | { NFS4ERR_MLINK, -EMLINK }, |
| 7312 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7313 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7314 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7315 | { NFS4ERR_STALE, -ESTALE }, |
| 7316 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7317 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7318 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7319 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7320 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7321 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7322 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7323 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7324 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7325 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7326 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7327 | }; |
| 7328 | |
| 7329 | /* |
| 7330 | * Convert an NFS error code to a local one. |
| 7331 | * This one is used jointly by NFSv2 and NFSv3. |
| 7332 | */ |
| 7333 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7334 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7335 | { |
| 7336 | int i; |
| 7337 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7338 | if (nfs_errtbl[i].stat == stat) |
| 7339 | return nfs_errtbl[i].errno; |
| 7340 | } |
| 7341 | if (stat <= 10000 || stat > 10100) { |
| 7342 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7343 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7344 | } |
| 7345 | /* If we cannot translate the error, the recovery routines should |
| 7346 | * handle it. |
| 7347 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7348 | * not conflict with native Linux error codes. |
| 7349 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7350 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7351 | } |
| 7352 | |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7353 | #ifdef CONFIG_NFS_V4_2 |
| 7354 | #include "nfs42xdr.c" |
| 7355 | #endif /* CONFIG_NFS_V4_2 */ |
| 7356 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7357 | #define PROC(proc, argtype, restype) \ |
| 7358 | [NFSPROC4_CLNT_##proc] = { \ |
| 7359 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7360 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7361 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7362 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7363 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7364 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7365 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7366 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7367 | |
| 7368 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7369 | PROC(READ, enc_read, dec_read), |
| 7370 | PROC(WRITE, enc_write, dec_write), |
| 7371 | PROC(COMMIT, enc_commit, dec_commit), |
| 7372 | PROC(OPEN, enc_open, dec_open), |
| 7373 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7374 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7375 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7376 | PROC(CLOSE, enc_close, dec_close), |
| 7377 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7378 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7379 | PROC(RENEW, enc_renew, dec_renew), |
| 7380 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7381 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7382 | PROC(LOCK, enc_lock, dec_lock), |
| 7383 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7384 | PROC(LOCKU, enc_locku, dec_locku), |
| 7385 | PROC(ACCESS, enc_access, dec_access), |
| 7386 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7387 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7388 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7389 | PROC(REMOVE, enc_remove, dec_remove), |
| 7390 | PROC(RENAME, enc_rename, dec_rename), |
| 7391 | PROC(LINK, enc_link, dec_link), |
| 7392 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7393 | PROC(CREATE, enc_create, dec_create), |
| 7394 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7395 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7396 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7397 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7398 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7399 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7400 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7401 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7402 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7403 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7404 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7405 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7406 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7407 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7408 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7409 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7410 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7411 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7412 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7413 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7414 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7415 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7416 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7417 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7418 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7419 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7420 | PROC(BIND_CONN_TO_SESSION, |
| 7421 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7422 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7423 | #endif /* CONFIG_NFS_V4_1 */ |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7424 | #ifdef CONFIG_NFS_V4_2 |
| 7425 | PROC(SEEK, enc_seek, dec_seek), |
Anna Schumaker | f4ac167 | 2014-11-25 13:18:15 -0500 | [diff] [blame] | 7426 | PROC(ALLOCATE, enc_allocate, dec_allocate), |
Anna Schumaker | 624bd5b | 2014-11-25 13:18:16 -0500 | [diff] [blame] | 7427 | PROC(DEALLOCATE, enc_deallocate, dec_deallocate), |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7428 | #endif /* CONFIG_NFS_V4_2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7429 | }; |
| 7430 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7431 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7432 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7433 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7434 | .procs = nfs4_procedures |
| 7435 | }; |
| 7436 | |
| 7437 | /* |
| 7438 | * Local variables: |
| 7439 | * c-basic-offset: 8 |
| 7440 | * End: |
| 7441 | */ |