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> |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 55 | |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 56 | #include "nfs4_fs.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 57 | #include "internal.h" |
Anna Schumaker | 40c64c2 | 2015-04-15 13:00:05 -0400 | [diff] [blame] | 58 | #include "nfs4idmap.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) + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 142 | /* client name */ \ |
| 143 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 144 | 1 /* sc_prog */ + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 145 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 146 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 147 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #define decode_setclientid_maxsz \ |
| 149 | (op_decode_hdr_maxsz + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 150 | 2 /* clientid */ + \ |
| 151 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 152 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 153 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define encode_setclientid_confirm_maxsz \ |
| 155 | (op_encode_hdr_maxsz + \ |
| 156 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 157 | #define decode_setclientid_confirm_maxsz \ |
| 158 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 159 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 160 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 161 | #define encode_share_access_maxsz \ |
| 162 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 163 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 164 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 165 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 166 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 167 | 2 + encode_share_access_maxsz + 2 + \ |
| 168 | open_owner_id_maxsz + \ |
| 169 | encode_opentype_maxsz + \ |
| 170 | encode_claim_null_maxsz) |
| 171 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 172 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 173 | decode_ace_maxsz) |
| 174 | #define decode_change_info_maxsz (5) |
| 175 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 176 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 177 | decode_change_info_maxsz + 1 + \ |
| 178 | nfs4_fattr_bitmap_maxsz + \ |
| 179 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 180 | #define encode_open_confirm_maxsz \ |
| 181 | (op_encode_hdr_maxsz + \ |
| 182 | encode_stateid_maxsz + 1) |
| 183 | #define decode_open_confirm_maxsz \ |
| 184 | (op_decode_hdr_maxsz + \ |
| 185 | decode_stateid_maxsz) |
| 186 | #define encode_open_downgrade_maxsz \ |
| 187 | (op_encode_hdr_maxsz + \ |
| 188 | encode_stateid_maxsz + 1 + \ |
| 189 | encode_share_access_maxsz) |
| 190 | #define decode_open_downgrade_maxsz \ |
| 191 | (op_decode_hdr_maxsz + \ |
| 192 | decode_stateid_maxsz) |
| 193 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 194 | 1 + encode_stateid_maxsz) |
| 195 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 196 | decode_stateid_maxsz) |
| 197 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 198 | encode_stateid_maxsz + \ |
| 199 | encode_attrs_maxsz) |
| 200 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 201 | nfs4_fattr_bitmap_maxsz) |
| 202 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 203 | encode_stateid_maxsz + 3) |
| 204 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 205 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 206 | 2 + encode_verifier_maxsz + 5 + \ |
| 207 | nfs4_label_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 208 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
Chuck Lever | a7697f6 | 2014-03-12 12:51:17 -0400 | [diff] [blame] | 209 | decode_verifier_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 210 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 211 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 212 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 213 | encode_stateid_maxsz + 4) |
| 214 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 215 | 2 + decode_verifier_maxsz) |
| 216 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 217 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 218 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 220 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 221 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 222 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 224 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 225 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 226 | decode_change_info_maxsz + \ |
| 227 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 229 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 230 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 231 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 232 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 233 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 234 | 1 + encode_stateid_maxsz + 1 + \ |
| 235 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 236 | #define decode_lock_denied_maxsz \ |
| 237 | (8 + decode_lockowner_maxsz) |
| 238 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 239 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 240 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 241 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 242 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 243 | decode_lock_denied_maxsz) |
| 244 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 245 | encode_stateid_maxsz + \ |
| 246 | 4) |
| 247 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 248 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 249 | #define encode_release_lockowner_maxsz \ |
| 250 | (op_encode_hdr_maxsz + \ |
| 251 | encode_lockowner_maxsz) |
| 252 | #define decode_release_lockowner_maxsz \ |
| 253 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 254 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 255 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 257 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 258 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 259 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 261 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 262 | 1 + 2 + nfs4_name_maxsz + \ |
| 263 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 264 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 265 | decode_change_info_maxsz + \ |
| 266 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 267 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 268 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 270 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 271 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 272 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 273 | nfs4_fattr_bitmap_maxsz + 1) |
| 274 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 275 | encode_stateid_maxsz + 3) |
| 276 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 277 | #define encode_fs_locations_maxsz \ |
| 278 | (encode_getattr_maxsz) |
| 279 | #define decode_fs_locations_maxsz \ |
| 280 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 281 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 282 | #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] | 283 | |
| 284 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 285 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 286 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
| 287 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 288 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 289 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 290 | encode_verifier_maxsz + \ |
| 291 | 1 /* co_ownerid.len */ + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 292 | /* eia_clientowner */ \ |
| 293 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 294 | 1 /* flags */ + \ |
| 295 | 1 /* spa_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 296 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 297 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 298 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 299 | 1 /* implementation id array of size 1 */ + \ |
| 300 | 1 /* nii_domain */ + \ |
| 301 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 302 | 1 /* nii_name */ + \ |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 303 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 304 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 305 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 306 | 2 /* eir_clientid */ + \ |
| 307 | 1 /* eir_sequenceid */ + \ |
| 308 | 1 /* eir_flags */ + \ |
| 309 | 1 /* spr_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 310 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 311 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 312 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 313 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 314 | /* eir_server_owner.so_major_id<> */ \ |
| 315 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 316 | /* eir_server_scope<> */ \ |
| 317 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 318 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 319 | 1 /* nii_domain */ + \ |
| 320 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 321 | 1 /* nii_name */ + \ |
| 322 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 323 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 324 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 325 | #define decode_channel_attrs_maxsz (6 + \ |
| 326 | 1 /* ca_rdma_ird.len */ + \ |
| 327 | 1 /* ca_rdma_ird */) |
| 328 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 329 | 2 /* csa_clientid */ + \ |
| 330 | 1 /* csa_sequence */ + \ |
| 331 | 1 /* csa_flags */ + \ |
| 332 | encode_channel_attrs_maxsz + \ |
| 333 | encode_channel_attrs_maxsz + \ |
| 334 | 1 /* csa_cb_program */ + \ |
| 335 | 1 /* csa_sec_parms.len (1) */ + \ |
| 336 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 337 | 1 /* stamp */ + \ |
| 338 | 1 /* machinename.len */ + \ |
| 339 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 340 | 1 /* uid */ + \ |
| 341 | 1 /* gid */ + \ |
| 342 | 1 /* gids.len (0) */) |
| 343 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 344 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 345 | 1 /* csr_sequence */ + \ |
| 346 | 1 /* csr_flags */ + \ |
| 347 | decode_channel_attrs_maxsz + \ |
| 348 | decode_channel_attrs_maxsz) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 349 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
| 350 | /* bctsa_sessid */ \ |
| 351 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 352 | 1 /* bctsa_dir */ + \ |
| 353 | 1 /* bctsa_use_conn_in_rdma_mode */) |
| 354 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ |
| 355 | /* bctsr_sessid */ \ |
| 356 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 357 | 1 /* bctsr_dir */ + \ |
| 358 | 1 /* bctsr_use_conn_in_rdma_mode */) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 359 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 360 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 361 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
| 362 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 363 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 364 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 365 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 366 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 367 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 368 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 369 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
| 370 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ |
| 371 | 1 /* layout type */ + \ |
| 372 | 1 /* maxcount */ + \ |
| 373 | 1 /* bitmap size */ + \ |
| 374 | 1 /* notification bitmap length */ + \ |
| 375 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 376 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 377 | 1 /* layout type */ + \ |
| 378 | 1 /* opaque devaddr4 length */ + \ |
| 379 | /* devaddr4 payload is read into page */ \ |
| 380 | 1 /* notification bitmap length */ + \ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 381 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 382 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 383 | encode_stateid_maxsz) |
| 384 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 385 | decode_stateid_maxsz + \ |
| 386 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 387 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 388 | 2 /* offset */ + \ |
| 389 | 2 /* length */ + \ |
| 390 | 1 /* reclaim */ + \ |
| 391 | encode_stateid_maxsz + \ |
| 392 | 1 /* new offset (true) */ + \ |
| 393 | 2 /* last byte written */ + \ |
| 394 | 1 /* nt_timechanged (false) */ + \ |
| 395 | 1 /* layoutupdate4 layout type */ + \ |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 396 | 1 /* layoutupdate4 opaqueue len */) |
| 397 | /* the actual content of layoutupdate4 should |
| 398 | be allocated by drivers and spliced in |
| 399 | using xdr_write_pages */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 400 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 401 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 402 | encode_stateid_maxsz + \ |
| 403 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 404 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 405 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 406 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 407 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 408 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 409 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 410 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 411 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 412 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 413 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 414 | #else /* CONFIG_NFS_V4_1 */ |
| 415 | #define encode_sequence_maxsz 0 |
| 416 | #define decode_sequence_maxsz 0 |
| 417 | #endif /* CONFIG_NFS_V4_1 */ |
| 418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 420 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 421 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 422 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 424 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 426 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 428 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 430 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 432 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 434 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 436 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 438 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 440 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 442 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 444 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 446 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 448 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 449 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 451 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 453 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 454 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 456 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 458 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 460 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 462 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 464 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 465 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 466 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 467 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 468 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 469 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 471 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 472 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 473 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 474 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 475 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 476 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 477 | #define NFS4_enc_open_confirm_sz \ |
| 478 | (compound_encode_hdr_maxsz + \ |
| 479 | encode_putfh_maxsz + \ |
| 480 | encode_open_confirm_maxsz) |
| 481 | #define NFS4_dec_open_confirm_sz \ |
| 482 | (compound_decode_hdr_maxsz + \ |
| 483 | decode_putfh_maxsz + \ |
| 484 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 486 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 488 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 489 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 490 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 492 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 494 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 495 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 496 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | #define NFS4_enc_open_downgrade_sz \ |
| 498 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 499 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 500 | encode_putfh_maxsz + \ |
| 501 | encode_open_downgrade_maxsz + \ |
| 502 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | #define NFS4_dec_open_downgrade_sz \ |
| 504 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 505 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 506 | decode_putfh_maxsz + \ |
| 507 | decode_open_downgrade_maxsz + \ |
| 508 | decode_getattr_maxsz) |
| 509 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 510 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 511 | encode_putfh_maxsz + \ |
| 512 | encode_close_maxsz + \ |
| 513 | encode_getattr_maxsz) |
| 514 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 515 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 516 | decode_putfh_maxsz + \ |
| 517 | decode_close_maxsz + \ |
| 518 | decode_getattr_maxsz) |
| 519 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 520 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 521 | encode_putfh_maxsz + \ |
| 522 | encode_setattr_maxsz + \ |
| 523 | encode_getattr_maxsz) |
| 524 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 525 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 526 | decode_putfh_maxsz + \ |
| 527 | decode_setattr_maxsz + \ |
| 528 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | encode_putfh_maxsz + \ |
| 532 | encode_fsinfo_maxsz) |
| 533 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 534 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | decode_putfh_maxsz + \ |
| 536 | decode_fsinfo_maxsz) |
| 537 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 538 | encode_renew_maxsz) |
| 539 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 540 | decode_renew_maxsz) |
| 541 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 542 | encode_setclientid_maxsz) |
| 543 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 544 | decode_setclientid_maxsz) |
| 545 | #define NFS4_enc_setclientid_confirm_sz \ |
| 546 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 547 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | #define NFS4_dec_setclientid_confirm_sz \ |
| 549 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 550 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 552 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 554 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 556 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 558 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 560 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 562 | encode_lockt_maxsz) |
| 563 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 564 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 565 | decode_putfh_maxsz + \ |
| 566 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 568 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 570 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 572 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 574 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 575 | #define NFS4_enc_release_lockowner_sz \ |
| 576 | (compound_encode_hdr_maxsz + \ |
| 577 | encode_lockowner_maxsz) |
| 578 | #define NFS4_dec_release_lockowner_sz \ |
| 579 | (compound_decode_hdr_maxsz + \ |
| 580 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 582 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 584 | encode_access_maxsz + \ |
| 585 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 587 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 589 | decode_access_maxsz + \ |
| 590 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 592 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 594 | encode_getattr_maxsz + \ |
| 595 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 597 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | decode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 599 | decode_getattr_maxsz + \ |
| 600 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 602 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | encode_putfh_maxsz + \ |
| 604 | encode_lookup_maxsz + \ |
| 605 | encode_getattr_maxsz + \ |
| 606 | encode_getfh_maxsz) |
| 607 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 608 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 610 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | decode_getattr_maxsz + \ |
| 612 | decode_getfh_maxsz) |
| 613 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 614 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | encode_putrootfh_maxsz + \ |
| 616 | encode_getattr_maxsz + \ |
| 617 | encode_getfh_maxsz) |
| 618 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 619 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | decode_putrootfh_maxsz + \ |
| 621 | decode_getattr_maxsz + \ |
| 622 | decode_getfh_maxsz) |
| 623 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 624 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 626 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 628 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 630 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 632 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | encode_putfh_maxsz + \ |
| 634 | encode_savefh_maxsz + \ |
| 635 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 636 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 638 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | decode_putfh_maxsz + \ |
| 640 | decode_savefh_maxsz + \ |
| 641 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 642 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 644 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | encode_putfh_maxsz + \ |
| 646 | encode_savefh_maxsz + \ |
| 647 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 648 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 649 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 650 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 652 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | decode_putfh_maxsz + \ |
| 654 | decode_savefh_maxsz + \ |
| 655 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 656 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 657 | decode_restorefh_maxsz + \ |
| 658 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 660 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | encode_putfh_maxsz + \ |
| 662 | encode_symlink_maxsz + \ |
| 663 | encode_getattr_maxsz + \ |
| 664 | encode_getfh_maxsz) |
| 665 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 666 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | decode_putfh_maxsz + \ |
| 668 | decode_symlink_maxsz + \ |
| 669 | decode_getattr_maxsz + \ |
| 670 | decode_getfh_maxsz) |
| 671 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 672 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | encode_putfh_maxsz + \ |
| 674 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 675 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 676 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 678 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | decode_putfh_maxsz + \ |
| 680 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 681 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 682 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | encode_putfh_maxsz + \ |
| 686 | encode_getattr_maxsz) |
| 687 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | decode_putfh_maxsz + \ |
| 690 | decode_getattr_maxsz) |
| 691 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 692 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 694 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 696 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 698 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 700 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 701 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | encode_getattr_maxsz) |
| 703 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 704 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 705 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | decode_getattr_maxsz) |
| 707 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 708 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 710 | encode_delegreturn_maxsz + \ |
| 711 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 713 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 714 | decode_delegreturn_maxsz + \ |
| 715 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 716 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 717 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 718 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 719 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 720 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 721 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 722 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 723 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 724 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 725 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 726 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 727 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 728 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 729 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 730 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 731 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 732 | #define NFS4_enc_fs_locations_sz \ |
| 733 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 734 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 735 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 736 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 737 | encode_fs_locations_maxsz + \ |
| 738 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 739 | #define NFS4_dec_fs_locations_sz \ |
| 740 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 741 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 742 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 743 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 744 | decode_fs_locations_maxsz + \ |
| 745 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 746 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 747 | encode_sequence_maxsz + \ |
| 748 | encode_putfh_maxsz + \ |
| 749 | encode_secinfo_maxsz) |
| 750 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 751 | decode_sequence_maxsz + \ |
| 752 | decode_putfh_maxsz + \ |
| 753 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 754 | #define NFS4_enc_fsid_present_sz \ |
| 755 | (compound_encode_hdr_maxsz + \ |
| 756 | encode_sequence_maxsz + \ |
| 757 | encode_putfh_maxsz + \ |
| 758 | encode_getfh_maxsz + \ |
| 759 | encode_renew_maxsz) |
| 760 | #define NFS4_dec_fsid_present_sz \ |
| 761 | (compound_decode_hdr_maxsz + \ |
| 762 | decode_sequence_maxsz + \ |
| 763 | decode_putfh_maxsz + \ |
| 764 | decode_getfh_maxsz + \ |
| 765 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 766 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 767 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 768 | (compound_encode_hdr_maxsz + \ |
| 769 | encode_bind_conn_to_session_maxsz) |
| 770 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 771 | (compound_decode_hdr_maxsz + \ |
| 772 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 773 | #define NFS4_enc_exchange_id_sz \ |
| 774 | (compound_encode_hdr_maxsz + \ |
| 775 | encode_exchange_id_maxsz) |
| 776 | #define NFS4_dec_exchange_id_sz \ |
| 777 | (compound_decode_hdr_maxsz + \ |
| 778 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 779 | #define NFS4_enc_create_session_sz \ |
| 780 | (compound_encode_hdr_maxsz + \ |
| 781 | encode_create_session_maxsz) |
| 782 | #define NFS4_dec_create_session_sz \ |
| 783 | (compound_decode_hdr_maxsz + \ |
| 784 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 785 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 786 | encode_destroy_session_maxsz) |
| 787 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 788 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 789 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 790 | encode_destroy_clientid_maxsz) |
| 791 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 792 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 793 | #define NFS4_enc_sequence_sz \ |
| 794 | (compound_decode_hdr_maxsz + \ |
| 795 | encode_sequence_maxsz) |
| 796 | #define NFS4_dec_sequence_sz \ |
| 797 | (compound_decode_hdr_maxsz + \ |
| 798 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 799 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 800 | encode_sequence_maxsz + \ |
| 801 | encode_putrootfh_maxsz + \ |
| 802 | encode_fsinfo_maxsz) |
| 803 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 804 | decode_sequence_maxsz + \ |
| 805 | decode_putrootfh_maxsz + \ |
| 806 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 807 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 808 | encode_sequence_maxsz + \ |
| 809 | encode_reclaim_complete_maxsz) |
| 810 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 811 | decode_sequence_maxsz + \ |
| 812 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 813 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 814 | encode_sequence_maxsz +\ |
| 815 | encode_getdeviceinfo_maxsz) |
| 816 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 817 | decode_sequence_maxsz + \ |
| 818 | decode_getdeviceinfo_maxsz) |
| 819 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 820 | encode_sequence_maxsz + \ |
| 821 | encode_putfh_maxsz + \ |
| 822 | encode_layoutget_maxsz) |
| 823 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 824 | decode_sequence_maxsz + \ |
| 825 | decode_putfh_maxsz + \ |
| 826 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 827 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 828 | encode_sequence_maxsz +\ |
| 829 | encode_putfh_maxsz + \ |
| 830 | encode_layoutcommit_maxsz + \ |
| 831 | encode_getattr_maxsz) |
| 832 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 833 | decode_sequence_maxsz + \ |
| 834 | decode_putfh_maxsz + \ |
| 835 | decode_layoutcommit_maxsz + \ |
| 836 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 837 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 838 | encode_sequence_maxsz + \ |
| 839 | encode_putfh_maxsz + \ |
| 840 | encode_layoutreturn_maxsz) |
| 841 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 842 | decode_sequence_maxsz + \ |
| 843 | decode_putfh_maxsz + \ |
| 844 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 845 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 846 | encode_sequence_maxsz + \ |
| 847 | encode_putrootfh_maxsz +\ |
| 848 | encode_secinfo_no_name_maxsz) |
| 849 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 850 | decode_sequence_maxsz + \ |
| 851 | decode_putrootfh_maxsz + \ |
| 852 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 853 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 854 | encode_sequence_maxsz + \ |
| 855 | encode_test_stateid_maxsz) |
| 856 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 857 | decode_sequence_maxsz + \ |
| 858 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 859 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 860 | encode_sequence_maxsz + \ |
| 861 | encode_free_stateid_maxsz) |
| 862 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 863 | decode_sequence_maxsz + \ |
| 864 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 865 | |
| 866 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 867 | compound_encode_hdr_maxsz + |
| 868 | encode_sequence_maxsz + |
| 869 | encode_putfh_maxsz + |
| 870 | encode_getattr_maxsz) * |
| 871 | XDR_UNIT); |
| 872 | |
| 873 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 874 | compound_decode_hdr_maxsz + |
| 875 | decode_sequence_maxsz + |
| 876 | decode_putfh_maxsz) * |
| 877 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 878 | |
| 879 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 880 | compound_decode_hdr_maxsz + |
| 881 | decode_sequence_maxsz) * |
| 882 | XDR_UNIT); |
| 883 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 884 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 886 | static const umode_t nfs_type2fmt[] = { |
| 887 | [NF4BAD] = 0, |
| 888 | [NF4REG] = S_IFREG, |
| 889 | [NF4DIR] = S_IFDIR, |
| 890 | [NF4BLK] = S_IFBLK, |
| 891 | [NF4CHR] = S_IFCHR, |
| 892 | [NF4LNK] = S_IFLNK, |
| 893 | [NF4SOCK] = S_IFSOCK, |
| 894 | [NF4FIFO] = S_IFIFO, |
| 895 | [NF4ATTRDIR] = 0, |
| 896 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | }; |
| 898 | |
| 899 | struct compound_hdr { |
| 900 | int32_t status; |
| 901 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 902 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | uint32_t taglen; |
| 904 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 905 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 906 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | }; |
| 908 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 909 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 910 | { |
| 911 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 912 | BUG_ON(!p); |
| 913 | return p; |
| 914 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 916 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 917 | { |
| 918 | __be32 *p; |
| 919 | |
| 920 | p = xdr_reserve_space(xdr, len); |
| 921 | xdr_encode_opaque_fixed(p, buf, len); |
| 922 | } |
| 923 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 925 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 926 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 928 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | xdr_encode_opaque(p, str, len); |
| 930 | } |
| 931 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 932 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 933 | { |
| 934 | __be32 *p; |
| 935 | |
| 936 | p = reserve_space(xdr, 4); |
| 937 | *p = cpu_to_be32(n); |
| 938 | } |
| 939 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 940 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 941 | { |
| 942 | __be32 *p; |
| 943 | |
| 944 | p = reserve_space(xdr, 8); |
| 945 | xdr_encode_hyper(p, n); |
| 946 | } |
| 947 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 948 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 949 | const struct nfs_seqid *seqid) |
| 950 | { |
Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 951 | if (seqid != NULL) |
| 952 | encode_uint32(xdr, seqid->sequence->counter); |
| 953 | else |
| 954 | encode_uint32(xdr, 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 955 | } |
| 956 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 957 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 958 | struct rpc_rqst *req, |
| 959 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 961 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 962 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 963 | |
| 964 | /* initialize running count of expected bytes in reply. |
| 965 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 966 | * but this is not required as a MUST for the server to do so. */ |
| 967 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 969 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 970 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 971 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 972 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 973 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 974 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 975 | } |
| 976 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 977 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 978 | uint32_t replen, |
| 979 | struct compound_hdr *hdr) |
| 980 | { |
| 981 | encode_uint32(xdr, op); |
| 982 | hdr->nops++; |
| 983 | hdr->replen += replen; |
| 984 | } |
| 985 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 986 | static void encode_nops(struct compound_hdr *hdr) |
| 987 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 988 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 989 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | } |
| 991 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 992 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 993 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 994 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 995 | } |
| 996 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 998 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 999 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1002 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 1003 | const struct nfs4_label *label, |
| 1004 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | { |
| 1006 | char owner_name[IDMAP_NAMESZ]; |
| 1007 | char owner_group[IDMAP_NAMESZ]; |
| 1008 | int owner_namelen = 0; |
| 1009 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1010 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1011 | unsigned i; |
| 1012 | uint32_t len = 0; |
| 1013 | uint32_t bmval_len; |
| 1014 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | |
| 1016 | /* |
| 1017 | * We reserve enough space to write the entire attribute buffer at once. |
| 1018 | * In the worst-case, this would be |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1019 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 1020 | * = 40 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1021 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | */ |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1023 | if (iap->ia_valid & ATTR_SIZE) { |
| 1024 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1026 | } |
| 1027 | if (iap->ia_valid & ATTR_MODE) { |
| 1028 | bmval[1] |= FATTR4_WORD1_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | len += 4; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1030 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1032 | 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] | 1033 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1034 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1035 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | /* XXX */ |
| 1037 | strcpy(owner_name, "nobody"); |
| 1038 | owner_namelen = sizeof("nobody") - 1; |
| 1039 | /* goto out; */ |
| 1040 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1041 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1043 | } |
| 1044 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1045 | 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] | 1046 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1047 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1048 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | strcpy(owner_group, "nobody"); |
| 1050 | owner_grouplen = sizeof("nobody") - 1; |
| 1051 | /* goto out; */ |
| 1052 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1053 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1055 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | if (iap->ia_valid & ATTR_ATIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1057 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1058 | len += 16; |
| 1059 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1060 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1061 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | } |
| 1063 | if (iap->ia_valid & ATTR_MTIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1064 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1065 | len += 16; |
| 1066 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1067 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1068 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1070 | if (label) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1071 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1072 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1073 | } |
| 1074 | |
| 1075 | if (bmval[2] != 0) |
| 1076 | bmval_len = 3; |
| 1077 | else if (bmval[1] != 0) |
| 1078 | bmval_len = 2; |
| 1079 | else |
| 1080 | bmval_len = 1; |
| 1081 | |
| 1082 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); |
| 1083 | |
| 1084 | *p++ = cpu_to_be32(bmval_len); |
| 1085 | for (i = 0; i < bmval_len; i++) |
| 1086 | *p++ = cpu_to_be32(bmval[i]); |
| 1087 | *p++ = cpu_to_be32(len); |
| 1088 | |
| 1089 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1090 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1091 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1092 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1093 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1094 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1095 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1096 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1097 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1098 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1099 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1100 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); |
| 1101 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
| 1102 | } else |
| 1103 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1104 | } |
| 1105 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1106 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1107 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1108 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); |
| 1109 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
| 1110 | } else |
| 1111 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1112 | } |
| 1113 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1114 | *p++ = cpu_to_be32(label->lfs); |
| 1115 | *p++ = cpu_to_be32(label->pi); |
| 1116 | *p++ = cpu_to_be32(label->len); |
| 1117 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1118 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1123 | 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] | 1124 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1125 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1126 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1129 | 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] | 1130 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1131 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1132 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1133 | encode_nfs4_stateid(xdr, &arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | } |
| 1135 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1136 | 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] | 1137 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1138 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1139 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1140 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1141 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1142 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1143 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1146 | 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] | 1147 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1148 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1149 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1150 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1151 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | |
| 1153 | switch (create->ftype) { |
| 1154 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1155 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1156 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 2fcc213 | 2015-08-03 13:04:26 -0400 | [diff] [blame] | 1157 | xdr_write_pages(xdr, create->u.symlink.pages, 0, |
| 1158 | create->u.symlink.len); |
| 1159 | xdr->buf->flags |= XDRBUF_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | break; |
| 1161 | |
| 1162 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1163 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1164 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1165 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | break; |
| 1167 | |
| 1168 | default: |
| 1169 | break; |
| 1170 | } |
| 1171 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1172 | encode_string(xdr, create->name->len, create->name->name); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1173 | encode_attrs(xdr, create->attrs, create->label, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1176 | 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] | 1177 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1178 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1180 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1181 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1182 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1183 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1186 | 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] | 1187 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1188 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1190 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1191 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1192 | *p++ = cpu_to_be32(2); |
| 1193 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1194 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | } |
| 1196 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1197 | static void |
| 1198 | encode_getattr_three(struct xdr_stream *xdr, |
| 1199 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1200 | struct compound_hdr *hdr) |
| 1201 | { |
| 1202 | __be32 *p; |
| 1203 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1204 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1205 | if (bm2) { |
| 1206 | p = reserve_space(xdr, 16); |
| 1207 | *p++ = cpu_to_be32(3); |
| 1208 | *p++ = cpu_to_be32(bm0); |
| 1209 | *p++ = cpu_to_be32(bm1); |
| 1210 | *p = cpu_to_be32(bm2); |
| 1211 | } else if (bm1) { |
| 1212 | p = reserve_space(xdr, 12); |
| 1213 | *p++ = cpu_to_be32(2); |
| 1214 | *p++ = cpu_to_be32(bm0); |
| 1215 | *p = cpu_to_be32(bm1); |
| 1216 | } else { |
| 1217 | p = reserve_space(xdr, 8); |
| 1218 | *p++ = cpu_to_be32(1); |
| 1219 | *p = cpu_to_be32(bm0); |
| 1220 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1221 | } |
| 1222 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1223 | 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] | 1224 | { |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1225 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1226 | bitmask[1] & nfs4_fattr_bitmap[1], |
| 1227 | bitmask[2] & nfs4_fattr_bitmap[2], |
| 1228 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | } |
| 1230 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1231 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1232 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1233 | struct compound_hdr *hdr) |
| 1234 | { |
| 1235 | encode_getattr_three(xdr, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1236 | bitmask[0] & open_bitmap[0], |
| 1237 | bitmask[1] & open_bitmap[1], |
| 1238 | bitmask[2] & open_bitmap[2], |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1239 | hdr); |
| 1240 | } |
| 1241 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1242 | 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] | 1243 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1244 | encode_getattr_three(xdr, |
| 1245 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1246 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1247 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1248 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1251 | 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] | 1252 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1253 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1254 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1255 | } |
| 1256 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1257 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1259 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1262 | 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] | 1263 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1264 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1265 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1268 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1269 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1270 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1271 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1272 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1273 | } |
| 1274 | |
| 1275 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1276 | { |
| 1277 | if (fl->fl_end == OFFSET_MAX) |
| 1278 | return ~(uint64_t)0; |
| 1279 | return fl->fl_end - fl->fl_start + 1; |
| 1280 | } |
| 1281 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1282 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1283 | { |
| 1284 | __be32 *p; |
| 1285 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1286 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1287 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1288 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1289 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1290 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1291 | xdr_encode_hyper(p, lowner->id); |
| 1292 | } |
| 1293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | /* |
| 1295 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1296 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1297 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1298 | 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] | 1299 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1300 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1302 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1303 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1304 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1305 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1306 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1307 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1308 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1309 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1310 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1311 | encode_nfs4_stateid(xdr, &args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1312 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1313 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | } |
| 1315 | else { |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1316 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1317 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | } |
| 1320 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1321 | 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] | 1322 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1323 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1325 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1326 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1327 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1328 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1329 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1330 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1333 | 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] | 1334 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1335 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1337 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1338 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1339 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1340 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1341 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1342 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1343 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
| 1345 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1346 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1347 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1348 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1349 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1350 | } |
| 1351 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1352 | 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] | 1353 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1354 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1355 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | } |
| 1357 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1358 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1360 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1362 | p = reserve_space(xdr, 8); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1363 | *p++ = cpu_to_be32(share_access); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1364 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | } |
| 1366 | |
| 1367 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1368 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1369 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | /* |
| 1371 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1372 | * owner 4 = 32 |
| 1373 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1374 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1375 | encode_share_access(xdr, arg->share_access); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1376 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1377 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1378 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1379 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1380 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1381 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1382 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1386 | { |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1387 | struct iattr dummy; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1388 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1390 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1391 | switch(arg->createmode) { |
| 1392 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1393 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1394 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1395 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1396 | case NFS4_CREATE_GUARDED: |
| 1397 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1398 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1399 | break; |
| 1400 | case NFS4_CREATE_EXCLUSIVE: |
| 1401 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1402 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1403 | break; |
| 1404 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1405 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1406 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1407 | dummy.ia_valid = 0; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1408 | encode_attrs(xdr, &dummy, arg->label, arg->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1413 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1414 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1416 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1418 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1419 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1420 | break; |
| 1421 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1422 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1423 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | } |
| 1425 | } |
| 1426 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1427 | 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] | 1428 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1429 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1431 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1433 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1434 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1435 | break; |
| 1436 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1437 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1438 | break; |
| 1439 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1440 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1441 | break; |
| 1442 | default: |
| 1443 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1448 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1449 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1451 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1452 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | encode_string(xdr, name->len, name->name); |
| 1454 | } |
| 1455 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1456 | 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] | 1457 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1458 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1460 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1461 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | encode_delegation_type(xdr, type); |
| 1463 | } |
| 1464 | |
| 1465 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1466 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1467 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1469 | p = reserve_space(xdr, 4); |
| 1470 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1471 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | encode_string(xdr, name->len, name->name); |
| 1473 | } |
| 1474 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1475 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1476 | { |
| 1477 | __be32 *p; |
| 1478 | |
| 1479 | p = reserve_space(xdr, 4); |
| 1480 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1481 | } |
| 1482 | |
| 1483 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1484 | { |
| 1485 | __be32 *p; |
| 1486 | |
| 1487 | p = reserve_space(xdr, 4); |
| 1488 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1489 | encode_nfs4_stateid(xdr, stateid); |
| 1490 | } |
| 1491 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1492 | 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] | 1493 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1494 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | encode_openhdr(xdr, arg); |
| 1496 | encode_opentype(xdr, arg); |
| 1497 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1498 | case NFS4_OPEN_CLAIM_NULL: |
| 1499 | encode_claim_null(xdr, arg->name); |
| 1500 | break; |
| 1501 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1502 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1503 | break; |
| 1504 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1505 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1506 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1507 | case NFS4_OPEN_CLAIM_FH: |
| 1508 | encode_claim_fh(xdr); |
| 1509 | break; |
| 1510 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1511 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1512 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1513 | default: |
| 1514 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | } |
| 1517 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1518 | 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] | 1519 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1520 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1521 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1522 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | } |
| 1524 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1525 | 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] | 1526 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1527 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1528 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1529 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1530 | encode_share_access(xdr, arg->share_access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1533 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1534 | 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] | 1535 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1536 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1537 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | } |
| 1539 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1540 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1542 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | } |
| 1544 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1545 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1546 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1548 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1550 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1551 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1553 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1554 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1555 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | } |
| 1557 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1558 | 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] | 1559 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1560 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1561 | FATTR4_WORD0_RDATTR_ERROR, |
| 1562 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1563 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1564 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1565 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1566 | uint32_t attrlen = 0; |
| 1567 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1569 | if (readdir->plus) { |
| 1570 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1571 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1572 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1573 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1574 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1575 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1576 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1577 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1578 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1579 | /* Use mounted_on_fileid only if the server supports it */ |
| 1580 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1581 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1582 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1583 | attrs[i] &= readdir->bitmask[i]; |
| 1584 | if (attrs[i] != 0) |
| 1585 | attrlen = i+1; |
| 1586 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1587 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1588 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1589 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1590 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1591 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1592 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1593 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1594 | *p++ = cpu_to_be32(attrlen); |
| 1595 | for (i = 0; i < attrlen; i++) |
| 1596 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1597 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1598 | |
| 1599 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1600 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1601 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1602 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1603 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1604 | attrs[1] & readdir->bitmask[1], |
| 1605 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | } |
| 1607 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1608 | static void encode_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] | 1609 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1610 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | } |
| 1612 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1613 | 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] | 1614 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1615 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1616 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | } |
| 1618 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1619 | 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] | 1620 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1621 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1622 | encode_string(xdr, oldname->len, oldname->name); |
| 1623 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | } |
| 1625 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1626 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1627 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1629 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1630 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1631 | } |
| 1632 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1633 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1634 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1635 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1636 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1637 | } |
| 1638 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1639 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1640 | 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] | 1641 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1642 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1643 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1644 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1645 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1646 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1647 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1648 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1649 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1650 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1651 | 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] | 1652 | } |
| 1653 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1654 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1655 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1656 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1657 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | } |
| 1659 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1660 | 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] | 1661 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1662 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1663 | encode_nfs4_stateid(xdr, &arg->stateid); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1664 | encode_attrs(xdr, arg->iap, arg->label, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | } |
| 1666 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1667 | 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] | 1668 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1669 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1671 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1672 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1674 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), |
| 1675 | setclientid->sc_clnt->cl_owner_id); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1676 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1677 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1679 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1680 | p = reserve_space(xdr, 4); |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1681 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1682 | } |
| 1683 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1684 | 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] | 1685 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1686 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1687 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1688 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1689 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | } |
| 1691 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1692 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1693 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1695 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1697 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1698 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1700 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1701 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1702 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1703 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | |
| 1705 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | } |
| 1707 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1708 | 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] | 1709 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1710 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1711 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1713 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1714 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1715 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1716 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1717 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1718 | } |
| 1719 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1720 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1721 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1722 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1723 | struct nfs41_bind_conn_to_session_args *args, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1724 | struct compound_hdr *hdr) |
| 1725 | { |
| 1726 | __be32 *p; |
| 1727 | |
| 1728 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1729 | decode_bind_conn_to_session_maxsz, hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1730 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1731 | p = xdr_reserve_space(xdr, 8); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1732 | *p++ = cpu_to_be32(args->dir); |
| 1733 | *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] | 1734 | } |
| 1735 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1736 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 1737 | { |
| 1738 | unsigned int i; |
| 1739 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1740 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1741 | encode_uint32(xdr, op_map->u.words[i]); |
| 1742 | } |
| 1743 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1744 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1745 | struct nfs41_exchange_id_args *args, |
| 1746 | struct compound_hdr *hdr) |
| 1747 | { |
| 1748 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1749 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1750 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1751 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1752 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1753 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1754 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1755 | encode_string(xdr, strlen(args->client->cl_owner_id), |
| 1756 | args->client->cl_owner_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1757 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1758 | encode_uint32(xdr, args->flags); |
| 1759 | encode_uint32(xdr, args->state_protect.how); |
| 1760 | |
| 1761 | switch (args->state_protect.how) { |
| 1762 | case SP4_NONE: |
| 1763 | break; |
| 1764 | case SP4_MACH_CRED: |
| 1765 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1766 | encode_op_map(xdr, &args->state_protect.allow); |
| 1767 | break; |
| 1768 | default: |
| 1769 | WARN_ON_ONCE(1); |
| 1770 | break; |
| 1771 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1772 | |
| 1773 | if (send_implementation_id && |
| 1774 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1775 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1776 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1777 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1778 | utsname()->sysname, utsname()->release, |
| 1779 | utsname()->version, utsname()->machine); |
| 1780 | |
| 1781 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1782 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1783 | |
| 1784 | encode_string(xdr, |
| 1785 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1786 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1787 | encode_string(xdr, len, impl_name); |
| 1788 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1789 | p = reserve_space(xdr, 12); |
| 1790 | p = xdr_encode_hyper(p, 0); |
| 1791 | *p = cpu_to_be32(0); |
| 1792 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1793 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1794 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1795 | |
| 1796 | static void encode_create_session(struct xdr_stream *xdr, |
| 1797 | struct nfs41_create_session_args *args, |
| 1798 | struct compound_hdr *hdr) |
| 1799 | { |
| 1800 | __be32 *p; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1801 | struct nfs_client *clp = args->client; |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1802 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1803 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1804 | u32 max_resp_sz_cached; |
| 1805 | |
| 1806 | /* |
| 1807 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1808 | * 2 is the verifier. |
| 1809 | */ |
| 1810 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1811 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1812 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1813 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1814 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1815 | p = xdr_encode_hyper(p, args->clientid); |
| 1816 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1817 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1818 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1819 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1820 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1821 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1822 | *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] | 1823 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1824 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1825 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1826 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1827 | |
| 1828 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1829 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1830 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1831 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1832 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1833 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1834 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1835 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1836 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1837 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1838 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1839 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1840 | |
| 1841 | /* authsys_parms rfc1831 */ |
Trond Myklebust | 17f26b1 | 2013-08-21 15:48:42 -0400 | [diff] [blame] | 1842 | *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */ |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1843 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1844 | *p++ = cpu_to_be32(0); /* UID */ |
| 1845 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1846 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1847 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1848 | |
| 1849 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1850 | struct nfs4_session *session, |
| 1851 | struct compound_hdr *hdr) |
| 1852 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1853 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1854 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1855 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1856 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1857 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1858 | uint64_t clientid, |
| 1859 | struct compound_hdr *hdr) |
| 1860 | { |
| 1861 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1862 | encode_uint64(xdr, clientid); |
| 1863 | } |
| 1864 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1865 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1866 | struct nfs41_reclaim_complete_args *args, |
| 1867 | struct compound_hdr *hdr) |
| 1868 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1869 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1870 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1871 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1872 | #endif /* CONFIG_NFS_V4_1 */ |
| 1873 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1874 | static void encode_sequence(struct xdr_stream *xdr, |
| 1875 | const struct nfs4_sequence_args *args, |
| 1876 | struct compound_hdr *hdr) |
| 1877 | { |
| 1878 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1879 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1880 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1881 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1882 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1883 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1884 | tp = slot->table; |
| 1885 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1886 | if (!session) |
| 1887 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1888 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1889 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1890 | |
| 1891 | /* |
| 1892 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1893 | */ |
| 1894 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1895 | "max_slotid=%d cache_this=%d\n", |
| 1896 | __func__, |
| 1897 | ((u32 *)session->sess_id.data)[0], |
| 1898 | ((u32 *)session->sess_id.data)[1], |
| 1899 | ((u32 *)session->sess_id.data)[2], |
| 1900 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1901 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1902 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1903 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1904 | 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] | 1905 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1906 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1907 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1908 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1909 | #endif /* CONFIG_NFS_V4_1 */ |
| 1910 | } |
| 1911 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1912 | #ifdef CONFIG_NFS_V4_1 |
| 1913 | static void |
| 1914 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1915 | const struct nfs4_getdeviceinfo_args *args, |
| 1916 | struct compound_hdr *hdr) |
| 1917 | { |
| 1918 | __be32 *p; |
| 1919 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1920 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1921 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1922 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1923 | NFS4_DEVICEID4_SIZE); |
| 1924 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1925 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1926 | |
| 1927 | p = reserve_space(xdr, 4 + 4); |
| 1928 | *p++ = cpu_to_be32(1); /* bitmap length */ |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 1929 | *p++ = cpu_to_be32(args->notify_types); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1930 | } |
| 1931 | |
| 1932 | static void |
| 1933 | encode_layoutget(struct xdr_stream *xdr, |
| 1934 | const struct nfs4_layoutget_args *args, |
| 1935 | struct compound_hdr *hdr) |
| 1936 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1937 | __be32 *p; |
| 1938 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1939 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1940 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1941 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1942 | *p++ = cpu_to_be32(args->type); |
| 1943 | *p++ = cpu_to_be32(args->range.iomode); |
| 1944 | p = xdr_encode_hyper(p, args->range.offset); |
| 1945 | p = xdr_encode_hyper(p, args->range.length); |
| 1946 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1947 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1948 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1949 | |
| 1950 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1951 | __func__, |
| 1952 | args->type, |
| 1953 | args->range.iomode, |
| 1954 | (unsigned long)args->range.offset, |
| 1955 | (unsigned long)args->range.length, |
| 1956 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1957 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1958 | |
| 1959 | static int |
| 1960 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1961 | struct inode *inode, |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1962 | struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1963 | struct compound_hdr *hdr) |
| 1964 | { |
| 1965 | __be32 *p; |
| 1966 | |
| 1967 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1968 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1969 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1970 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1971 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1972 | /* Only whole file layouts */ |
| 1973 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1974 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1975 | *p = cpu_to_be32(0); /* reclaim */ |
| 1976 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1977 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1978 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1979 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1980 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1981 | *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] | 1982 | |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1983 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1984 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1985 | NFS_I(inode)->layout, xdr, args); |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1986 | } else { |
| 1987 | encode_uint32(xdr, args->layoutupdate_len); |
| 1988 | if (args->layoutupdate_pages) { |
| 1989 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 1990 | args->layoutupdate_len); |
| 1991 | } |
| 1992 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1993 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1994 | return 0; |
| 1995 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1996 | |
| 1997 | static void |
| 1998 | encode_layoutreturn(struct xdr_stream *xdr, |
| 1999 | const struct nfs4_layoutreturn_args *args, |
| 2000 | struct compound_hdr *hdr) |
| 2001 | { |
| 2002 | __be32 *p; |
| 2003 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2004 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 2005 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2006 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2007 | *p++ = cpu_to_be32(args->layout_type); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2008 | *p++ = cpu_to_be32(args->range.iomode); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2009 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2010 | p = reserve_space(xdr, 16); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2011 | p = xdr_encode_hyper(p, args->range.offset); |
| 2012 | p = xdr_encode_hyper(p, args->range.length); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2013 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2014 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2015 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2016 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2017 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2018 | NFS_I(args->inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2019 | } else |
| 2020 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2021 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2022 | |
| 2023 | static int |
| 2024 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2025 | const struct nfs41_secinfo_no_name_args *args, |
| 2026 | struct compound_hdr *hdr) |
| 2027 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2028 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2029 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2030 | return 0; |
| 2031 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2032 | |
| 2033 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2034 | struct nfs41_test_stateid_args *args, |
| 2035 | struct compound_hdr *hdr) |
| 2036 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2037 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2038 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2039 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2040 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2041 | |
| 2042 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2043 | struct nfs41_free_stateid_args *args, |
| 2044 | struct compound_hdr *hdr) |
| 2045 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2046 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2047 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2048 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2049 | #endif /* CONFIG_NFS_V4_1 */ |
| 2050 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | /* |
| 2052 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2053 | */ |
| 2054 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2055 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2056 | { |
| 2057 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2058 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2059 | if (session) |
| 2060 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2061 | #endif /* CONFIG_NFS_V4_1 */ |
| 2062 | return 0; |
| 2063 | } |
| 2064 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | /* |
| 2066 | * Encode an ACCESS request |
| 2067 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2068 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2069 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2072 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2075 | encode_compound_hdr(xdr, req, &hdr); |
| 2076 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2077 | encode_putfh(xdr, args->fh, &hdr); |
| 2078 | encode_access(xdr, args->access, &hdr); |
| 2079 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2080 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | } |
| 2082 | |
| 2083 | /* |
| 2084 | * Encode LOOKUP request |
| 2085 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2086 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2087 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2088 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2090 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2093 | encode_compound_hdr(xdr, req, &hdr); |
| 2094 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2095 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2096 | encode_lookup(xdr, args->name, &hdr); |
| 2097 | encode_getfh(xdr, &hdr); |
| 2098 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2099 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
| 2102 | /* |
| 2103 | * Encode LOOKUP_ROOT request |
| 2104 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2105 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2106 | struct xdr_stream *xdr, |
| 2107 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2110 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2113 | encode_compound_hdr(xdr, req, &hdr); |
| 2114 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2115 | encode_putrootfh(xdr, &hdr); |
| 2116 | encode_getfh(xdr, &hdr); |
| 2117 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2118 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | } |
| 2120 | |
| 2121 | /* |
| 2122 | * Encode REMOVE request |
| 2123 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2124 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2125 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2128 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2131 | encode_compound_hdr(xdr, req, &hdr); |
| 2132 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2133 | encode_putfh(xdr, args->fh, &hdr); |
| 2134 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2135 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | } |
| 2137 | |
| 2138 | /* |
| 2139 | * Encode RENAME request |
| 2140 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2141 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2142 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2145 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2146 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2148 | encode_compound_hdr(xdr, req, &hdr); |
| 2149 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2150 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2151 | encode_savefh(xdr, &hdr); |
| 2152 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2153 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2154 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | } |
| 2156 | |
| 2157 | /* |
| 2158 | * Encode LINK request |
| 2159 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2160 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2161 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2164 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2167 | encode_compound_hdr(xdr, req, &hdr); |
| 2168 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2169 | encode_putfh(xdr, args->fh, &hdr); |
| 2170 | encode_savefh(xdr, &hdr); |
| 2171 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2172 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2173 | encode_restorefh(xdr, &hdr); |
| 2174 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2175 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | } |
| 2177 | |
| 2178 | /* |
| 2179 | * Encode CREATE request |
| 2180 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2181 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2182 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2183 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2185 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2188 | encode_compound_hdr(xdr, req, &hdr); |
| 2189 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2190 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2191 | encode_create(xdr, args, &hdr); |
| 2192 | encode_getfh(xdr, &hdr); |
| 2193 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2194 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | } |
| 2196 | |
| 2197 | /* |
| 2198 | * Encode SYMLINK request |
| 2199 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2200 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2201 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2202 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2203 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | } |
| 2205 | |
| 2206 | /* |
| 2207 | * Encode GETATTR request |
| 2208 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2209 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2210 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2213 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2216 | encode_compound_hdr(xdr, req, &hdr); |
| 2217 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2218 | encode_putfh(xdr, args->fh, &hdr); |
| 2219 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2220 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | /* |
| 2224 | * Encode a CLOSE request |
| 2225 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2226 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2227 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2229 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2230 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2231 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2233 | encode_compound_hdr(xdr, req, &hdr); |
| 2234 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2235 | encode_putfh(xdr, args->fh, &hdr); |
| 2236 | encode_close(xdr, args, &hdr); |
| 2237 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2238 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | } |
| 2240 | |
| 2241 | /* |
| 2242 | * Encode an OPEN request |
| 2243 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2244 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2245 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2248 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2251 | encode_compound_hdr(xdr, req, &hdr); |
| 2252 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2253 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2254 | encode_open(xdr, args, &hdr); |
| 2255 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2256 | if (args->access) |
| 2257 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2258 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2259 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | } |
| 2261 | |
| 2262 | /* |
| 2263 | * Encode an OPEN_CONFIRM request |
| 2264 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2265 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2266 | struct xdr_stream *xdr, |
| 2267 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2270 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2273 | encode_compound_hdr(xdr, req, &hdr); |
| 2274 | encode_putfh(xdr, args->fh, &hdr); |
| 2275 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2276 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | } |
| 2278 | |
| 2279 | /* |
| 2280 | * Encode an OPEN request with no attributes. |
| 2281 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2282 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2283 | struct xdr_stream *xdr, |
| 2284 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2287 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2289 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2290 | encode_compound_hdr(xdr, req, &hdr); |
| 2291 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2292 | encode_putfh(xdr, args->fh, &hdr); |
| 2293 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2294 | if (args->access) |
| 2295 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2296 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2297 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | /* |
| 2301 | * Encode an OPEN_DOWNGRADE request |
| 2302 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2303 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2304 | struct xdr_stream *xdr, |
| 2305 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2308 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2309 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2311 | encode_compound_hdr(xdr, req, &hdr); |
| 2312 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2313 | encode_putfh(xdr, args->fh, &hdr); |
| 2314 | encode_open_downgrade(xdr, args, &hdr); |
| 2315 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2316 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | } |
| 2318 | |
| 2319 | /* |
| 2320 | * Encode a LOCK request |
| 2321 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2322 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2323 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2325 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2326 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2327 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2329 | encode_compound_hdr(xdr, req, &hdr); |
| 2330 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2331 | encode_putfh(xdr, args->fh, &hdr); |
| 2332 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2333 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | /* |
| 2337 | * Encode a LOCKT request |
| 2338 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2339 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2340 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2343 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2346 | encode_compound_hdr(xdr, req, &hdr); |
| 2347 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2348 | encode_putfh(xdr, args->fh, &hdr); |
| 2349 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2350 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2351 | } |
| 2352 | |
| 2353 | /* |
| 2354 | * Encode a LOCKU request |
| 2355 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2356 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2357 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2359 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2360 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2363 | encode_compound_hdr(xdr, req, &hdr); |
| 2364 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2365 | encode_putfh(xdr, args->fh, &hdr); |
| 2366 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2367 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | } |
| 2369 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2370 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2371 | struct xdr_stream *xdr, |
| 2372 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2373 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2374 | struct compound_hdr hdr = { |
| 2375 | .minorversion = 0, |
| 2376 | }; |
| 2377 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2378 | encode_compound_hdr(xdr, req, &hdr); |
| 2379 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2380 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2381 | } |
| 2382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | /* |
| 2384 | * Encode a READLINK request |
| 2385 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2386 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2387 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2389 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2390 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2393 | encode_compound_hdr(xdr, req, &hdr); |
| 2394 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2395 | encode_putfh(xdr, args->fh, &hdr); |
| 2396 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2397 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2398 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2399 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2400 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | } |
| 2402 | |
| 2403 | /* |
| 2404 | * Encode a READDIR request |
| 2405 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2406 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2407 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2409 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2410 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2413 | encode_compound_hdr(xdr, req, &hdr); |
| 2414 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2415 | encode_putfh(xdr, args->fh, &hdr); |
| 2416 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2417 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2418 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2419 | args->pgbase, args->count); |
| 2420 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2421 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2422 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2423 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2424 | } |
| 2425 | |
| 2426 | /* |
| 2427 | * Encode a READ request |
| 2428 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2429 | 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] | 2430 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2431 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2432 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2433 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2436 | encode_compound_hdr(xdr, req, &hdr); |
| 2437 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2438 | encode_putfh(xdr, args->fh, &hdr); |
| 2439 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2441 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2442 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2443 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2444 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | } |
| 2446 | |
| 2447 | /* |
| 2448 | * Encode an SETATTR request |
| 2449 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2450 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2451 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2453 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2454 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2455 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2457 | encode_compound_hdr(xdr, req, &hdr); |
| 2458 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2459 | encode_putfh(xdr, args->fh, &hdr); |
| 2460 | encode_setattr(xdr, args, args->server, &hdr); |
| 2461 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2462 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2466 | * Encode a GETACL request |
| 2467 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2468 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2469 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2470 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2471 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2472 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2473 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2474 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2475 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2476 | encode_compound_hdr(xdr, req, &hdr); |
| 2477 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2478 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2479 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2480 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2481 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2482 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2483 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2484 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2485 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2486 | } |
| 2487 | |
| 2488 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | * Encode a WRITE request |
| 2490 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2491 | 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] | 2492 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2493 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2495 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2498 | encode_compound_hdr(xdr, req, &hdr); |
| 2499 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2500 | encode_putfh(xdr, args->fh, &hdr); |
| 2501 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2502 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2503 | if (args->bitmask) |
| 2504 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2505 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2506 | } |
| 2507 | |
| 2508 | /* |
| 2509 | * a COMMIT request |
| 2510 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2511 | 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] | 2512 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2513 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2515 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2518 | encode_compound_hdr(xdr, req, &hdr); |
| 2519 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2520 | encode_putfh(xdr, args->fh, &hdr); |
| 2521 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2522 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | /* |
| 2526 | * FSINFO request |
| 2527 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2528 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2529 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2532 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2533 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2535 | encode_compound_hdr(xdr, req, &hdr); |
| 2536 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2537 | encode_putfh(xdr, args->fh, &hdr); |
| 2538 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2539 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2540 | } |
| 2541 | |
| 2542 | /* |
| 2543 | * a PATHCONF request |
| 2544 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2545 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2546 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2549 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2551 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2552 | encode_compound_hdr(xdr, req, &hdr); |
| 2553 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2554 | encode_putfh(xdr, args->fh, &hdr); |
| 2555 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2556 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2557 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | } |
| 2559 | |
| 2560 | /* |
| 2561 | * a STATFS request |
| 2562 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2563 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2564 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2565 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2567 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2569 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2570 | encode_compound_hdr(xdr, req, &hdr); |
| 2571 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2572 | encode_putfh(xdr, args->fh, &hdr); |
| 2573 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2574 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2575 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | } |
| 2577 | |
| 2578 | /* |
| 2579 | * GETATTR_BITMAP request |
| 2580 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2581 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2582 | struct xdr_stream *xdr, |
| 2583 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2585 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2586 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2587 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2588 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2589 | encode_compound_hdr(xdr, req, &hdr); |
| 2590 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2591 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2592 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2593 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2594 | FATTR4_WORD0_LINK_SUPPORT| |
| 2595 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2596 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2597 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | } |
| 2599 | |
| 2600 | /* |
| 2601 | * a RENEW request |
| 2602 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2603 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2604 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2605 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2607 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | }; |
| 2609 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2610 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2611 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2612 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | } |
| 2614 | |
| 2615 | /* |
| 2616 | * a SETCLIENTID request |
| 2617 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2618 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2619 | struct xdr_stream *xdr, |
| 2620 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2623 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | }; |
| 2625 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2626 | encode_compound_hdr(xdr, req, &hdr); |
| 2627 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2628 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | } |
| 2630 | |
| 2631 | /* |
| 2632 | * a SETCLIENTID_CONFIRM request |
| 2633 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2634 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2635 | struct xdr_stream *xdr, |
| 2636 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2639 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2641 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2642 | encode_compound_hdr(xdr, req, &hdr); |
| 2643 | encode_setclientid_confirm(xdr, arg, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2644 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2645 | } |
| 2646 | |
| 2647 | /* |
| 2648 | * DELEGRETURN request |
| 2649 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2650 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2651 | struct xdr_stream *xdr, |
| 2652 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2653 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2654 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2655 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2656 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2658 | encode_compound_hdr(xdr, req, &hdr); |
| 2659 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2660 | encode_putfh(xdr, args->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2661 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2662 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2663 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | } |
| 2665 | |
| 2666 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2667 | * Encode FS_LOCATIONS request |
| 2668 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2669 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2670 | struct xdr_stream *xdr, |
| 2671 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2672 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2673 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2674 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2675 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2676 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2677 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2678 | encode_compound_hdr(xdr, req, &hdr); |
| 2679 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2680 | if (args->migration) { |
| 2681 | encode_putfh(xdr, args->fh, &hdr); |
| 2682 | replen = hdr.replen; |
| 2683 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2684 | if (args->renew) |
| 2685 | encode_renew(xdr, args->clientid, &hdr); |
| 2686 | } else { |
| 2687 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2688 | encode_lookup(xdr, args->name, &hdr); |
| 2689 | replen = hdr.replen; |
| 2690 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2691 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2692 | |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2693 | /* Set up reply kvec to capture returned fs_locations array. */ |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2694 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2695 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2696 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2697 | } |
| 2698 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2699 | /* |
| 2700 | * Encode SECINFO request |
| 2701 | */ |
| 2702 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2703 | struct xdr_stream *xdr, |
| 2704 | struct nfs4_secinfo_arg *args) |
| 2705 | { |
| 2706 | struct compound_hdr hdr = { |
| 2707 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2708 | }; |
| 2709 | |
| 2710 | encode_compound_hdr(xdr, req, &hdr); |
| 2711 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2712 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2713 | encode_secinfo(xdr, args->name, &hdr); |
| 2714 | encode_nops(&hdr); |
| 2715 | } |
| 2716 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2717 | /* |
| 2718 | * Encode FSID_PRESENT request |
| 2719 | */ |
| 2720 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2721 | struct xdr_stream *xdr, |
| 2722 | struct nfs4_fsid_present_arg *args) |
| 2723 | { |
| 2724 | struct compound_hdr hdr = { |
| 2725 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2726 | }; |
| 2727 | |
| 2728 | encode_compound_hdr(xdr, req, &hdr); |
| 2729 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2730 | encode_putfh(xdr, args->fh, &hdr); |
| 2731 | encode_getfh(xdr, &hdr); |
| 2732 | if (args->renew) |
| 2733 | encode_renew(xdr, args->clientid, &hdr); |
| 2734 | encode_nops(&hdr); |
| 2735 | } |
| 2736 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2737 | #if defined(CONFIG_NFS_V4_1) |
| 2738 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2739 | * BIND_CONN_TO_SESSION request |
| 2740 | */ |
| 2741 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2742 | struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2743 | struct nfs41_bind_conn_to_session_args *args) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2744 | { |
| 2745 | struct compound_hdr hdr = { |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2746 | .minorversion = args->client->cl_mvops->minor_version, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2747 | }; |
| 2748 | |
| 2749 | encode_compound_hdr(xdr, req, &hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2750 | encode_bind_conn_to_session(xdr, args, &hdr); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2751 | encode_nops(&hdr); |
| 2752 | } |
| 2753 | |
| 2754 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2755 | * EXCHANGE_ID request |
| 2756 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2757 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2758 | struct xdr_stream *xdr, |
| 2759 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2760 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2761 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2762 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2763 | }; |
| 2764 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2765 | encode_compound_hdr(xdr, req, &hdr); |
| 2766 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2767 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2768 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2769 | |
| 2770 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2771 | * a CREATE_SESSION request |
| 2772 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2773 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2774 | struct xdr_stream *xdr, |
| 2775 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2776 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2777 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2778 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2779 | }; |
| 2780 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2781 | encode_compound_hdr(xdr, req, &hdr); |
| 2782 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2783 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2787 | * a DESTROY_SESSION request |
| 2788 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2789 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2790 | struct xdr_stream *xdr, |
| 2791 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2792 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2793 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2794 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2795 | }; |
| 2796 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2797 | encode_compound_hdr(xdr, req, &hdr); |
| 2798 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2799 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2800 | } |
| 2801 | |
| 2802 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2803 | * a DESTROY_CLIENTID request |
| 2804 | */ |
| 2805 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2806 | struct xdr_stream *xdr, |
| 2807 | struct nfs_client *clp) |
| 2808 | { |
| 2809 | struct compound_hdr hdr = { |
| 2810 | .minorversion = clp->cl_mvops->minor_version, |
| 2811 | }; |
| 2812 | |
| 2813 | encode_compound_hdr(xdr, req, &hdr); |
| 2814 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2815 | encode_nops(&hdr); |
| 2816 | } |
| 2817 | |
| 2818 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2819 | * a SEQUENCE request |
| 2820 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2821 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2822 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2823 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2824 | struct compound_hdr hdr = { |
| 2825 | .minorversion = nfs4_xdr_minorversion(args), |
| 2826 | }; |
| 2827 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2828 | encode_compound_hdr(xdr, req, &hdr); |
| 2829 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2830 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2831 | } |
| 2832 | |
| 2833 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2834 | * a GET_LEASE_TIME request |
| 2835 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2836 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2837 | struct xdr_stream *xdr, |
| 2838 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2839 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2840 | struct compound_hdr hdr = { |
| 2841 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2842 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2843 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2844 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2845 | encode_compound_hdr(xdr, req, &hdr); |
| 2846 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2847 | encode_putrootfh(xdr, &hdr); |
| 2848 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2849 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2850 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2851 | |
| 2852 | /* |
| 2853 | * a RECLAIM_COMPLETE request |
| 2854 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2855 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2856 | struct xdr_stream *xdr, |
| 2857 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2858 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2859 | struct compound_hdr hdr = { |
| 2860 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2861 | }; |
| 2862 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2863 | encode_compound_hdr(xdr, req, &hdr); |
| 2864 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2865 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2866 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2867 | } |
| 2868 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2869 | /* |
| 2870 | * Encode GETDEVICEINFO request |
| 2871 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2872 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2873 | struct xdr_stream *xdr, |
| 2874 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2875 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2876 | struct compound_hdr hdr = { |
| 2877 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2878 | }; |
| 2879 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2880 | encode_compound_hdr(xdr, req, &hdr); |
| 2881 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2882 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2883 | |
| 2884 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2885 | * so that notification bitmap is put in xdr_buf tail */ |
| 2886 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2887 | args->pdev->pages, args->pdev->pgbase, |
| 2888 | args->pdev->pglen); |
| 2889 | |
| 2890 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | /* |
| 2894 | * Encode LAYOUTGET request |
| 2895 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2896 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2897 | struct xdr_stream *xdr, |
| 2898 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2899 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2900 | struct compound_hdr hdr = { |
| 2901 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2902 | }; |
| 2903 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2904 | encode_compound_hdr(xdr, req, &hdr); |
| 2905 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2906 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2907 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2908 | |
| 2909 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2910 | args->layout.pages, 0, args->layout.pglen); |
| 2911 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2912 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2913 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2914 | |
| 2915 | /* |
| 2916 | * Encode LAYOUTCOMMIT request |
| 2917 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2918 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2919 | struct xdr_stream *xdr, |
| 2920 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2921 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2922 | struct nfs4_layoutcommit_data *data = |
| 2923 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2924 | struct compound_hdr hdr = { |
| 2925 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2926 | }; |
| 2927 | |
| 2928 | encode_compound_hdr(xdr, req, &hdr); |
| 2929 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2930 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2931 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2932 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2933 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2934 | } |
| 2935 | |
| 2936 | /* |
| 2937 | * Encode LAYOUTRETURN request |
| 2938 | */ |
| 2939 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2940 | struct xdr_stream *xdr, |
| 2941 | struct nfs4_layoutreturn_args *args) |
| 2942 | { |
| 2943 | struct compound_hdr hdr = { |
| 2944 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2945 | }; |
| 2946 | |
| 2947 | encode_compound_hdr(xdr, req, &hdr); |
| 2948 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2949 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2950 | encode_layoutreturn(xdr, args, &hdr); |
| 2951 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2952 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2953 | |
| 2954 | /* |
| 2955 | * Encode SECINFO_NO_NAME request |
| 2956 | */ |
| 2957 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2958 | struct xdr_stream *xdr, |
| 2959 | struct nfs41_secinfo_no_name_args *args) |
| 2960 | { |
| 2961 | struct compound_hdr hdr = { |
| 2962 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2963 | }; |
| 2964 | |
| 2965 | encode_compound_hdr(xdr, req, &hdr); |
| 2966 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2967 | encode_putrootfh(xdr, &hdr); |
| 2968 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2969 | encode_nops(&hdr); |
| 2970 | return 0; |
| 2971 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2972 | |
| 2973 | /* |
| 2974 | * Encode TEST_STATEID request |
| 2975 | */ |
| 2976 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2977 | struct xdr_stream *xdr, |
| 2978 | struct nfs41_test_stateid_args *args) |
| 2979 | { |
| 2980 | struct compound_hdr hdr = { |
| 2981 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2982 | }; |
| 2983 | |
| 2984 | encode_compound_hdr(xdr, req, &hdr); |
| 2985 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2986 | encode_test_stateid(xdr, args, &hdr); |
| 2987 | encode_nops(&hdr); |
| 2988 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2989 | |
| 2990 | /* |
| 2991 | * Encode FREE_STATEID request |
| 2992 | */ |
| 2993 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2994 | struct xdr_stream *xdr, |
| 2995 | struct nfs41_free_stateid_args *args) |
| 2996 | { |
| 2997 | struct compound_hdr hdr = { |
| 2998 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2999 | }; |
| 3000 | |
| 3001 | encode_compound_hdr(xdr, req, &hdr); |
| 3002 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3003 | encode_free_stateid(xdr, args, &hdr); |
| 3004 | encode_nops(&hdr); |
| 3005 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3006 | #endif /* CONFIG_NFS_V4_1 */ |
| 3007 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3008 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3009 | { |
| 3010 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3011 | "Remaining buffer length is %tu words.\n", |
| 3012 | func, xdr->end - xdr->p); |
| 3013 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3014 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3015 | 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] | 3016 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3017 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3019 | p = xdr_inline_decode(xdr, 4); |
| 3020 | if (unlikely(!p)) |
| 3021 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3022 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3023 | p = xdr_inline_decode(xdr, *len); |
| 3024 | if (unlikely(!p)) |
| 3025 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3026 | *string = (char *)p; |
| 3027 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3028 | out_overflow: |
| 3029 | print_overflow_msg(__func__, xdr); |
| 3030 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | } |
| 3032 | |
| 3033 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3034 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3035 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3037 | p = xdr_inline_decode(xdr, 8); |
| 3038 | if (unlikely(!p)) |
| 3039 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3040 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3041 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3042 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3043 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3044 | if (unlikely(!p)) |
| 3045 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | hdr->tag = (char *)p; |
| 3047 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3048 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3049 | if (unlikely(hdr->nops < 1)) |
| 3050 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3052 | out_overflow: |
| 3053 | print_overflow_msg(__func__, xdr); |
| 3054 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3055 | } |
| 3056 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3057 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3058 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3060 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | uint32_t opnum; |
| 3062 | int32_t nfserr; |
| 3063 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3064 | p = xdr_inline_decode(xdr, 8); |
| 3065 | if (unlikely(!p)) |
| 3066 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3067 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3068 | if (unlikely(opnum != expected)) |
| 3069 | goto out_bad_operation; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3070 | nfserr = be32_to_cpup(p); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3071 | if (nfserr == NFS_OK) |
| 3072 | *nfs_retval = 0; |
| 3073 | else |
| 3074 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
| 3075 | return true; |
| 3076 | out_bad_operation: |
| 3077 | dprintk("nfs: Server returned operation" |
| 3078 | " %d but we issued a request for %d\n", |
| 3079 | opnum, expected); |
| 3080 | *nfs_retval = -EREMOTEIO; |
| 3081 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3082 | out_overflow: |
| 3083 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3084 | *nfs_retval = -EIO; |
| 3085 | return false; |
| 3086 | } |
| 3087 | |
| 3088 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3089 | { |
| 3090 | int retval; |
| 3091 | |
| 3092 | __decode_op_hdr(xdr, expected, &retval); |
| 3093 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3094 | } |
| 3095 | |
| 3096 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3097 | 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] | 3098 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3099 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3100 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3101 | char *str; |
| 3102 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3103 | p = xdr_inline_decode(xdr, 12); |
| 3104 | if (likely(p)) |
| 3105 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3106 | print_overflow_msg(__func__, xdr); |
| 3107 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3108 | } |
| 3109 | |
| 3110 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3111 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3112 | uint32_t bmlen; |
| 3113 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3114 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3115 | p = xdr_inline_decode(xdr, 4); |
| 3116 | if (unlikely(!p)) |
| 3117 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3118 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3119 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3120 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3121 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3122 | if (unlikely(!p)) |
| 3123 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3124 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3125 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3126 | if (bmlen > 1) { |
| 3127 | bitmap[1] = be32_to_cpup(p++); |
| 3128 | if (bmlen > 2) |
| 3129 | bitmap[2] = be32_to_cpup(p); |
| 3130 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3131 | } |
| 3132 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3133 | out_overflow: |
| 3134 | print_overflow_msg(__func__, xdr); |
| 3135 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
| 3137 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3138 | 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] | 3139 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3140 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3142 | p = xdr_inline_decode(xdr, 4); |
| 3143 | if (unlikely(!p)) |
| 3144 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3145 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3146 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3147 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3148 | out_overflow: |
| 3149 | print_overflow_msg(__func__, xdr); |
| 3150 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3151 | } |
| 3152 | |
| 3153 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3154 | { |
| 3155 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3156 | int ret; |
| 3157 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3158 | if (unlikely(ret < 0)) |
| 3159 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3160 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3161 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3162 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3163 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3164 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | return 0; |
| 3166 | } |
| 3167 | |
| 3168 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3169 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3170 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3171 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | |
| 3173 | *type = 0; |
| 3174 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3175 | return -EIO; |
| 3176 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3177 | p = xdr_inline_decode(xdr, 4); |
| 3178 | if (unlikely(!p)) |
| 3179 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3180 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3182 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | return -EIO; |
| 3184 | } |
| 3185 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3186 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3188 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3189 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3190 | out_overflow: |
| 3191 | print_overflow_msg(__func__, xdr); |
| 3192 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3193 | } |
| 3194 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3195 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3196 | uint32_t *bitmap, uint32_t *type) |
| 3197 | { |
| 3198 | __be32 *p; |
| 3199 | |
| 3200 | *type = 0; |
| 3201 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3202 | return -EIO; |
| 3203 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3204 | p = xdr_inline_decode(xdr, 4); |
| 3205 | if (unlikely(!p)) |
| 3206 | goto out_overflow; |
| 3207 | *type = be32_to_cpup(p); |
| 3208 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3209 | } |
| 3210 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3211 | return 0; |
| 3212 | out_overflow: |
| 3213 | print_overflow_msg(__func__, xdr); |
| 3214 | return -EIO; |
| 3215 | } |
| 3216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3217 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3218 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3219 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3220 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3221 | |
| 3222 | *change = 0; |
| 3223 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3224 | return -EIO; |
| 3225 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3226 | p = xdr_inline_decode(xdr, 8); |
| 3227 | if (unlikely(!p)) |
| 3228 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3229 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3231 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3232 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3233 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3234 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3235 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3236 | out_overflow: |
| 3237 | print_overflow_msg(__func__, xdr); |
| 3238 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | } |
| 3240 | |
| 3241 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3242 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3243 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3244 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3245 | |
| 3246 | *size = 0; |
| 3247 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3248 | return -EIO; |
| 3249 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3250 | p = xdr_inline_decode(xdr, 8); |
| 3251 | if (unlikely(!p)) |
| 3252 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3253 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3254 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3255 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3256 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3257 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3258 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3259 | out_overflow: |
| 3260 | print_overflow_msg(__func__, xdr); |
| 3261 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3262 | } |
| 3263 | |
| 3264 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3265 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3266 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3267 | |
| 3268 | *res = 0; |
| 3269 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3270 | return -EIO; |
| 3271 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3272 | p = xdr_inline_decode(xdr, 4); |
| 3273 | if (unlikely(!p)) |
| 3274 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3275 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3277 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3278 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3279 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3280 | out_overflow: |
| 3281 | print_overflow_msg(__func__, xdr); |
| 3282 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | } |
| 3284 | |
| 3285 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3286 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3287 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | |
| 3289 | *res = 0; |
| 3290 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3291 | return -EIO; |
| 3292 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3293 | p = xdr_inline_decode(xdr, 4); |
| 3294 | if (unlikely(!p)) |
| 3295 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3296 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3297 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3298 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3299 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3301 | out_overflow: |
| 3302 | print_overflow_msg(__func__, xdr); |
| 3303 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | } |
| 3305 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3306 | 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] | 3307 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3308 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3309 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | |
| 3311 | fsid->major = 0; |
| 3312 | fsid->minor = 0; |
| 3313 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3314 | return -EIO; |
| 3315 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3316 | p = xdr_inline_decode(xdr, 16); |
| 3317 | if (unlikely(!p)) |
| 3318 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3319 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3320 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3321 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3322 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3323 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3324 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | (unsigned long long)fsid->major, |
| 3326 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3327 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3328 | out_overflow: |
| 3329 | print_overflow_msg(__func__, xdr); |
| 3330 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3331 | } |
| 3332 | |
| 3333 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3334 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3335 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3336 | |
| 3337 | *res = 60; |
| 3338 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3339 | return -EIO; |
| 3340 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3341 | p = xdr_inline_decode(xdr, 4); |
| 3342 | if (unlikely(!p)) |
| 3343 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3344 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3345 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3346 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3347 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3349 | out_overflow: |
| 3350 | print_overflow_msg(__func__, xdr); |
| 3351 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | } |
| 3353 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3354 | 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] | 3355 | { |
| 3356 | __be32 *p; |
| 3357 | |
| 3358 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3359 | return -EIO; |
| 3360 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3361 | p = xdr_inline_decode(xdr, 4); |
| 3362 | if (unlikely(!p)) |
| 3363 | goto out_overflow; |
| 3364 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3365 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3366 | } |
| 3367 | return 0; |
| 3368 | out_overflow: |
| 3369 | print_overflow_msg(__func__, xdr); |
| 3370 | return -EIO; |
| 3371 | } |
| 3372 | |
| 3373 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3374 | { |
| 3375 | __be32 *p; |
| 3376 | int len; |
| 3377 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3378 | if (fh != NULL) |
| 3379 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3380 | |
| 3381 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3382 | return -EIO; |
| 3383 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3384 | p = xdr_inline_decode(xdr, 4); |
| 3385 | if (unlikely(!p)) |
| 3386 | goto out_overflow; |
| 3387 | len = be32_to_cpup(p); |
| 3388 | if (len > NFS4_FHSIZE) |
| 3389 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3390 | p = xdr_inline_decode(xdr, len); |
| 3391 | if (unlikely(!p)) |
| 3392 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3393 | if (fh != NULL) { |
| 3394 | memcpy(fh->data, p, len); |
| 3395 | fh->size = len; |
| 3396 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3397 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3398 | } |
| 3399 | return 0; |
| 3400 | out_overflow: |
| 3401 | print_overflow_msg(__func__, xdr); |
| 3402 | return -EIO; |
| 3403 | } |
| 3404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3405 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3406 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3407 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3408 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3409 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3410 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3411 | return -EIO; |
| 3412 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3413 | p = xdr_inline_decode(xdr, 4); |
| 3414 | if (unlikely(!p)) |
| 3415 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3416 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3417 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3418 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3419 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3420 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3421 | out_overflow: |
| 3422 | print_overflow_msg(__func__, xdr); |
| 3423 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3424 | } |
| 3425 | |
| 3426 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3427 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3428 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3429 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3430 | |
| 3431 | *fileid = 0; |
| 3432 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3433 | return -EIO; |
| 3434 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3435 | p = xdr_inline_decode(xdr, 8); |
| 3436 | if (unlikely(!p)) |
| 3437 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3438 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3439 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3440 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3441 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3442 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3443 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3444 | out_overflow: |
| 3445 | print_overflow_msg(__func__, xdr); |
| 3446 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3447 | } |
| 3448 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3449 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3450 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3451 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3452 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3453 | |
| 3454 | *fileid = 0; |
| 3455 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3456 | return -EIO; |
| 3457 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3458 | p = xdr_inline_decode(xdr, 8); |
| 3459 | if (unlikely(!p)) |
| 3460 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3461 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3462 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3463 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3464 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3465 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3466 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3467 | out_overflow: |
| 3468 | print_overflow_msg(__func__, xdr); |
| 3469 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3470 | } |
| 3471 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3473 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3474 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3475 | int status = 0; |
| 3476 | |
| 3477 | *res = 0; |
| 3478 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3479 | return -EIO; |
| 3480 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3481 | p = xdr_inline_decode(xdr, 8); |
| 3482 | if (unlikely(!p)) |
| 3483 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3484 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3485 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3486 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3487 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3488 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3489 | out_overflow: |
| 3490 | print_overflow_msg(__func__, xdr); |
| 3491 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3492 | } |
| 3493 | |
| 3494 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3495 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3496 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3497 | int status = 0; |
| 3498 | |
| 3499 | *res = 0; |
| 3500 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3501 | return -EIO; |
| 3502 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3503 | p = xdr_inline_decode(xdr, 8); |
| 3504 | if (unlikely(!p)) |
| 3505 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3506 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3507 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3508 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3509 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3510 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3511 | out_overflow: |
| 3512 | print_overflow_msg(__func__, xdr); |
| 3513 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | } |
| 3515 | |
| 3516 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3517 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3518 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3519 | int status = 0; |
| 3520 | |
| 3521 | *res = 0; |
| 3522 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3523 | return -EIO; |
| 3524 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3525 | p = xdr_inline_decode(xdr, 8); |
| 3526 | if (unlikely(!p)) |
| 3527 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3528 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3529 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3530 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3531 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3532 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3533 | out_overflow: |
| 3534 | print_overflow_msg(__func__, xdr); |
| 3535 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | } |
| 3537 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3538 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3539 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3540 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3541 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3542 | int status = 0; |
| 3543 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3544 | p = xdr_inline_decode(xdr, 4); |
| 3545 | if (unlikely(!p)) |
| 3546 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3547 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3548 | if (n == 0) |
| 3549 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3550 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3551 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3552 | dprintk("cannot parse %d components in path\n", n); |
| 3553 | goto out_eio; |
| 3554 | } |
| 3555 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3556 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3557 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3558 | if (unlikely(status != 0)) |
| 3559 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3560 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3561 | pr_cont("%s%.*s ", |
| 3562 | (path->ncomponents != n ? "/ " : ""), |
| 3563 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3564 | } |
| 3565 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3566 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3567 | root_path: |
| 3568 | /* a root pathname is sent as a zero component4 */ |
| 3569 | path->ncomponents = 1; |
| 3570 | path->components[0].len=0; |
| 3571 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3572 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3573 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3574 | out_eio: |
| 3575 | dprintk(" status %d", status); |
| 3576 | status = -EIO; |
| 3577 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3578 | out_overflow: |
| 3579 | print_overflow_msg(__func__, xdr); |
| 3580 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3581 | } |
| 3582 | |
| 3583 | 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] | 3584 | { |
| 3585 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3586 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3587 | int status = -EIO; |
| 3588 | |
| 3589 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3590 | goto out; |
| 3591 | status = 0; |
| 3592 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3593 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3594 | status = -EIO; |
| 3595 | /* Ignore borken servers that return unrequested attrs */ |
| 3596 | if (unlikely(res == NULL)) |
| 3597 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3598 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3599 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3600 | if (unlikely(status != 0)) |
| 3601 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3602 | p = xdr_inline_decode(xdr, 4); |
| 3603 | if (unlikely(!p)) |
| 3604 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3605 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3606 | if (n <= 0) |
| 3607 | goto out_eio; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3608 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3609 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3610 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3611 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3612 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3613 | break; |
| 3614 | loc = &res->locations[res->nlocations]; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3615 | p = xdr_inline_decode(xdr, 4); |
| 3616 | if (unlikely(!p)) |
| 3617 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3618 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3619 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3620 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3621 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3622 | struct nfs4_string *server; |
| 3623 | |
| 3624 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3625 | unsigned int i; |
| 3626 | dprintk("%s: using first %u of %u servers " |
| 3627 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3628 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3629 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3630 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3631 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3632 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3633 | char *data; |
| 3634 | status = decode_opaque_inline(xdr, &len, &data); |
| 3635 | if (unlikely(status != 0)) |
| 3636 | goto out_eio; |
| 3637 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3638 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3639 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3640 | server = &loc->servers[loc->nservers]; |
| 3641 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3642 | if (unlikely(status != 0)) |
| 3643 | goto out_eio; |
| 3644 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3645 | } |
| 3646 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3647 | if (unlikely(status != 0)) |
| 3648 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3649 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3650 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3651 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3652 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3653 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3654 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3655 | out_overflow: |
| 3656 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3657 | out_eio: |
| 3658 | status = -EIO; |
| 3659 | goto out; |
| 3660 | } |
| 3661 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3662 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3663 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3664 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3665 | int status = 0; |
| 3666 | |
| 3667 | *res = 0; |
| 3668 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3669 | return -EIO; |
| 3670 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3671 | p = xdr_inline_decode(xdr, 8); |
| 3672 | if (unlikely(!p)) |
| 3673 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3674 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3675 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3676 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3677 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3678 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3679 | out_overflow: |
| 3680 | print_overflow_msg(__func__, xdr); |
| 3681 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3682 | } |
| 3683 | |
| 3684 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3685 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3686 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | int status = 0; |
| 3688 | |
| 3689 | *maxlink = 1; |
| 3690 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3691 | return -EIO; |
| 3692 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3693 | p = xdr_inline_decode(xdr, 4); |
| 3694 | if (unlikely(!p)) |
| 3695 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3696 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3697 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3698 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3699 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3700 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3701 | out_overflow: |
| 3702 | print_overflow_msg(__func__, xdr); |
| 3703 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3704 | } |
| 3705 | |
| 3706 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3707 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3708 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3709 | int status = 0; |
| 3710 | |
| 3711 | *maxname = 1024; |
| 3712 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3713 | return -EIO; |
| 3714 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3715 | p = xdr_inline_decode(xdr, 4); |
| 3716 | if (unlikely(!p)) |
| 3717 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3718 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3719 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3720 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3721 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3722 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3723 | out_overflow: |
| 3724 | print_overflow_msg(__func__, xdr); |
| 3725 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3726 | } |
| 3727 | |
| 3728 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3729 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3730 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3731 | int status = 0; |
| 3732 | |
| 3733 | *res = 1024; |
| 3734 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3735 | return -EIO; |
| 3736 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3737 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3738 | p = xdr_inline_decode(xdr, 8); |
| 3739 | if (unlikely(!p)) |
| 3740 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3741 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3742 | if (maxread > 0x7FFFFFFF) |
| 3743 | maxread = 0x7FFFFFFF; |
| 3744 | *res = (uint32_t)maxread; |
| 3745 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3746 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3747 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3748 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3749 | out_overflow: |
| 3750 | print_overflow_msg(__func__, xdr); |
| 3751 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3752 | } |
| 3753 | |
| 3754 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3755 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3756 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3757 | int status = 0; |
| 3758 | |
| 3759 | *res = 1024; |
| 3760 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3761 | return -EIO; |
| 3762 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3763 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3764 | p = xdr_inline_decode(xdr, 8); |
| 3765 | if (unlikely(!p)) |
| 3766 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3767 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3768 | if (maxwrite > 0x7FFFFFFF) |
| 3769 | maxwrite = 0x7FFFFFFF; |
| 3770 | *res = (uint32_t)maxwrite; |
| 3771 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3772 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3773 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3774 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3775 | out_overflow: |
| 3776 | print_overflow_msg(__func__, xdr); |
| 3777 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3778 | } |
| 3779 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3780 | 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] | 3781 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3782 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3783 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3784 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3785 | |
| 3786 | *mode = 0; |
| 3787 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3788 | return -EIO; |
| 3789 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3790 | p = xdr_inline_decode(xdr, 4); |
| 3791 | if (unlikely(!p)) |
| 3792 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3793 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3794 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3795 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3796 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3797 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3798 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3799 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3800 | out_overflow: |
| 3801 | print_overflow_msg(__func__, xdr); |
| 3802 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3806 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3807 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3808 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3809 | |
| 3810 | *nlink = 1; |
| 3811 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3812 | return -EIO; |
| 3813 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3814 | p = xdr_inline_decode(xdr, 4); |
| 3815 | if (unlikely(!p)) |
| 3816 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3817 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3818 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3819 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3821 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3822 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3823 | out_overflow: |
| 3824 | print_overflow_msg(__func__, xdr); |
| 3825 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3826 | } |
| 3827 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3828 | 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] | 3829 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3830 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3831 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3832 | uint32_t len; |
| 3833 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3834 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3835 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3836 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3837 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3838 | return -EIO; |
| 3839 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3840 | p = xdr_inline_decode(xdr, 4); |
| 3841 | if (unlikely(!p)) |
| 3842 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3843 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3844 | p = xdr_inline_decode(xdr, len); |
| 3845 | if (unlikely(!p)) |
| 3846 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3847 | if (owner_name != NULL) { |
| 3848 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3849 | if (owner_name->data != NULL) { |
| 3850 | owner_name->len = len; |
| 3851 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3852 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3853 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3854 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3855 | ret = NFS_ATTR_FATTR_OWNER; |
| 3856 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3857 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3858 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3859 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3860 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3861 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3862 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3863 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3864 | 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] | 3865 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3866 | out_overflow: |
| 3867 | print_overflow_msg(__func__, xdr); |
| 3868 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | } |
| 3870 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3871 | 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] | 3872 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3873 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3874 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3875 | uint32_t len; |
| 3876 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3877 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3878 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3879 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3880 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3881 | return -EIO; |
| 3882 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3883 | p = xdr_inline_decode(xdr, 4); |
| 3884 | if (unlikely(!p)) |
| 3885 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3886 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3887 | p = xdr_inline_decode(xdr, len); |
| 3888 | if (unlikely(!p)) |
| 3889 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3890 | if (group_name != NULL) { |
| 3891 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3892 | if (group_name->data != NULL) { |
| 3893 | group_name->len = len; |
| 3894 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3895 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3896 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3897 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3898 | ret = NFS_ATTR_FATTR_GROUP; |
| 3899 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3900 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3901 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3902 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3903 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3904 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3905 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3906 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3907 | 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] | 3908 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3909 | out_overflow: |
| 3910 | print_overflow_msg(__func__, xdr); |
| 3911 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3912 | } |
| 3913 | |
| 3914 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3915 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3916 | uint32_t major = 0, minor = 0; |
| 3917 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3918 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3919 | |
| 3920 | *rdev = MKDEV(0,0); |
| 3921 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3922 | return -EIO; |
| 3923 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3924 | dev_t tmp; |
| 3925 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3926 | p = xdr_inline_decode(xdr, 8); |
| 3927 | if (unlikely(!p)) |
| 3928 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3929 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3930 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3931 | tmp = MKDEV(major, minor); |
| 3932 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3933 | *rdev = tmp; |
| 3934 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3935 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3937 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3938 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3939 | out_overflow: |
| 3940 | print_overflow_msg(__func__, xdr); |
| 3941 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3945 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3946 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3947 | int status = 0; |
| 3948 | |
| 3949 | *res = 0; |
| 3950 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3951 | return -EIO; |
| 3952 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3953 | p = xdr_inline_decode(xdr, 8); |
| 3954 | if (unlikely(!p)) |
| 3955 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3956 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3957 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3958 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3959 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3960 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3961 | out_overflow: |
| 3962 | print_overflow_msg(__func__, xdr); |
| 3963 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | } |
| 3965 | |
| 3966 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3967 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3968 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3969 | int status = 0; |
| 3970 | |
| 3971 | *res = 0; |
| 3972 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3973 | return -EIO; |
| 3974 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3975 | p = xdr_inline_decode(xdr, 8); |
| 3976 | if (unlikely(!p)) |
| 3977 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3978 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3979 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3980 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3981 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3982 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3983 | out_overflow: |
| 3984 | print_overflow_msg(__func__, xdr); |
| 3985 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3986 | } |
| 3987 | |
| 3988 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3989 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3990 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | int status = 0; |
| 3992 | |
| 3993 | *res = 0; |
| 3994 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3995 | return -EIO; |
| 3996 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3997 | p = xdr_inline_decode(xdr, 8); |
| 3998 | if (unlikely(!p)) |
| 3999 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4000 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4001 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4002 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4003 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4005 | out_overflow: |
| 4006 | print_overflow_msg(__func__, xdr); |
| 4007 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4011 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4012 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4013 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4014 | |
| 4015 | *used = 0; |
| 4016 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4017 | return -EIO; |
| 4018 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4019 | p = xdr_inline_decode(xdr, 8); |
| 4020 | if (unlikely(!p)) |
| 4021 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4022 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4023 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4024 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4025 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4026 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4027 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4028 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4029 | out_overflow: |
| 4030 | print_overflow_msg(__func__, xdr); |
| 4031 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4032 | } |
| 4033 | |
| 4034 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4035 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4036 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4037 | uint64_t sec; |
| 4038 | uint32_t nsec; |
| 4039 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4040 | p = xdr_inline_decode(xdr, 12); |
| 4041 | if (unlikely(!p)) |
| 4042 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4043 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4044 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4045 | time->tv_sec = (time_t)sec; |
| 4046 | time->tv_nsec = (long)nsec; |
| 4047 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4048 | out_overflow: |
| 4049 | print_overflow_msg(__func__, xdr); |
| 4050 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4051 | } |
| 4052 | |
| 4053 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4054 | { |
| 4055 | int status = 0; |
| 4056 | |
| 4057 | time->tv_sec = 0; |
| 4058 | time->tv_nsec = 0; |
| 4059 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4060 | return -EIO; |
| 4061 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4062 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4063 | if (status == 0) |
| 4064 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4065 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4066 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4067 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4068 | return status; |
| 4069 | } |
| 4070 | |
| 4071 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4072 | { |
| 4073 | int status = 0; |
| 4074 | |
| 4075 | time->tv_sec = 0; |
| 4076 | time->tv_nsec = 0; |
| 4077 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4078 | return -EIO; |
| 4079 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4080 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4081 | if (status == 0) |
| 4082 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4083 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4084 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4085 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4086 | return status; |
| 4087 | } |
| 4088 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4089 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4090 | struct timespec *time) |
| 4091 | { |
| 4092 | int status = 0; |
| 4093 | |
| 4094 | time->tv_sec = 0; |
| 4095 | time->tv_nsec = 0; |
| 4096 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4097 | return -EIO; |
| 4098 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4099 | status = decode_attr_time(xdr, time); |
| 4100 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4101 | } |
| 4102 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4103 | (long)time->tv_nsec); |
| 4104 | return status; |
| 4105 | } |
| 4106 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4107 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4108 | struct nfs4_label *label) |
| 4109 | { |
| 4110 | uint32_t pi = 0; |
| 4111 | uint32_t lfs = 0; |
| 4112 | __u32 len; |
| 4113 | __be32 *p; |
| 4114 | int status = 0; |
| 4115 | |
| 4116 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4117 | return -EIO; |
| 4118 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4119 | p = xdr_inline_decode(xdr, 4); |
| 4120 | if (unlikely(!p)) |
| 4121 | goto out_overflow; |
| 4122 | lfs = be32_to_cpup(p++); |
| 4123 | p = xdr_inline_decode(xdr, 4); |
| 4124 | if (unlikely(!p)) |
| 4125 | goto out_overflow; |
| 4126 | pi = be32_to_cpup(p++); |
| 4127 | p = xdr_inline_decode(xdr, 4); |
| 4128 | if (unlikely(!p)) |
| 4129 | goto out_overflow; |
| 4130 | len = be32_to_cpup(p++); |
| 4131 | p = xdr_inline_decode(xdr, len); |
| 4132 | if (unlikely(!p)) |
| 4133 | goto out_overflow; |
| 4134 | if (len < NFS4_MAXLABELLEN) { |
| 4135 | if (label) { |
| 4136 | memcpy(label->label, p, len); |
| 4137 | label->len = len; |
| 4138 | label->pi = pi; |
| 4139 | label->lfs = lfs; |
| 4140 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4141 | } |
| 4142 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4143 | } else |
| 4144 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4145 | __func__, len); |
| 4146 | } |
| 4147 | if (label && label->label) |
| 4148 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4149 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4150 | return status; |
| 4151 | |
| 4152 | out_overflow: |
| 4153 | print_overflow_msg(__func__, xdr); |
| 4154 | return -EIO; |
| 4155 | } |
| 4156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4157 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4158 | { |
| 4159 | int status = 0; |
| 4160 | |
| 4161 | time->tv_sec = 0; |
| 4162 | time->tv_nsec = 0; |
| 4163 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4164 | return -EIO; |
| 4165 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4166 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4167 | if (status == 0) |
| 4168 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4169 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4170 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4171 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4172 | return status; |
| 4173 | } |
| 4174 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4175 | 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] | 4176 | { |
| 4177 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4178 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4179 | |
| 4180 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4181 | dprintk("%s: server returned incorrect attribute length: " |
| 4182 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4183 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4184 | attrwords << 2, |
| 4185 | (attrwords < nwords) ? '<' : '>', |
| 4186 | nwords << 2); |
| 4187 | return -EIO; |
| 4188 | } |
| 4189 | return 0; |
| 4190 | } |
| 4191 | |
| 4192 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4193 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4194 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4195 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4196 | p = xdr_inline_decode(xdr, 20); |
| 4197 | if (unlikely(!p)) |
| 4198 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4199 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4200 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4201 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4202 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4203 | out_overflow: |
| 4204 | print_overflow_msg(__func__, xdr); |
| 4205 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 | } |
| 4207 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4208 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4209 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4210 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | uint32_t supp, acc; |
| 4212 | int status; |
| 4213 | |
| 4214 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4215 | if (status) |
| 4216 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4217 | p = xdr_inline_decode(xdr, 8); |
| 4218 | if (unlikely(!p)) |
| 4219 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4220 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4221 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4222 | *supported = supp; |
| 4223 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4224 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4225 | out_overflow: |
| 4226 | print_overflow_msg(__func__, xdr); |
| 4227 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4228 | } |
| 4229 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4230 | 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] | 4231 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4232 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4233 | |
| 4234 | p = xdr_inline_decode(xdr, len); |
| 4235 | if (likely(p)) { |
| 4236 | memcpy(buf, p, len); |
| 4237 | return 0; |
| 4238 | } |
| 4239 | print_overflow_msg(__func__, xdr); |
| 4240 | return -EIO; |
| 4241 | } |
| 4242 | |
| 4243 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4244 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4245 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4246 | } |
| 4247 | |
| 4248 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4249 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4250 | int status; |
| 4251 | |
| 4252 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4253 | if (status != -EIO) |
| 4254 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4255 | if (!status) |
| 4256 | status = decode_stateid(xdr, &res->stateid); |
| 4257 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | } |
| 4259 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4260 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4261 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4262 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4263 | } |
| 4264 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4265 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4266 | { |
| 4267 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4268 | } |
| 4269 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4270 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4271 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4272 | int status; |
| 4273 | |
| 4274 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4275 | if (!status) |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4276 | status = decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4277 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4278 | } |
| 4279 | |
| 4280 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4281 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4282 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | uint32_t bmlen; |
| 4284 | int status; |
| 4285 | |
| 4286 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4287 | if (status) |
| 4288 | return status; |
| 4289 | if ((status = decode_change_info(xdr, cinfo))) |
| 4290 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4291 | p = xdr_inline_decode(xdr, 4); |
| 4292 | if (unlikely(!p)) |
| 4293 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4294 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4295 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4296 | if (likely(p)) |
| 4297 | return 0; |
| 4298 | out_overflow: |
| 4299 | print_overflow_msg(__func__, xdr); |
| 4300 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4301 | } |
| 4302 | |
| 4303 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4304 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4305 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4306 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4307 | int status; |
| 4308 | |
| 4309 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4310 | goto xdr_error; |
| 4311 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4312 | goto xdr_error; |
| 4313 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4314 | goto xdr_error; |
| 4315 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4316 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4317 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4318 | &res->fh_expire_type)) != 0) |
| 4319 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4320 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4321 | goto xdr_error; |
| 4322 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4323 | goto xdr_error; |
| 4324 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4325 | goto xdr_error; |
| 4326 | status = verify_attr_len(xdr, savep, attrlen); |
| 4327 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4328 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | return status; |
| 4330 | } |
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 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4333 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4334 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4335 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4336 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4337 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4338 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4339 | goto xdr_error; |
| 4340 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4341 | goto xdr_error; |
| 4342 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4343 | goto xdr_error; |
| 4344 | |
| 4345 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4346 | goto xdr_error; |
| 4347 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4348 | goto xdr_error; |
| 4349 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4350 | goto xdr_error; |
| 4351 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4352 | goto xdr_error; |
| 4353 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4354 | goto xdr_error; |
| 4355 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4356 | goto xdr_error; |
| 4357 | |
| 4358 | status = verify_attr_len(xdr, savep, attrlen); |
| 4359 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4360 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4361 | return status; |
| 4362 | } |
| 4363 | |
| 4364 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4365 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4366 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4367 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4368 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4370 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4371 | goto xdr_error; |
| 4372 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4373 | goto xdr_error; |
| 4374 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4375 | goto xdr_error; |
| 4376 | |
| 4377 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4378 | goto xdr_error; |
| 4379 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4380 | goto xdr_error; |
| 4381 | |
| 4382 | status = verify_attr_len(xdr, savep, attrlen); |
| 4383 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4384 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4385 | return status; |
| 4386 | } |
| 4387 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4388 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4389 | uint32_t *bitmap, |
| 4390 | uint64_t *res, |
| 4391 | uint32_t hint_bit) |
| 4392 | { |
| 4393 | __be32 *p; |
| 4394 | |
| 4395 | *res = 0; |
| 4396 | if (likely(bitmap[0] & hint_bit)) { |
| 4397 | p = xdr_inline_decode(xdr, 8); |
| 4398 | if (unlikely(!p)) |
| 4399 | goto out_overflow; |
| 4400 | xdr_decode_hyper(p, res); |
| 4401 | } |
| 4402 | return 0; |
| 4403 | out_overflow: |
| 4404 | print_overflow_msg(__func__, xdr); |
| 4405 | return -EIO; |
| 4406 | } |
| 4407 | |
| 4408 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4409 | struct nfs4_threshold *res) |
| 4410 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4411 | __be32 *p; |
| 4412 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4413 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4414 | int status; |
| 4415 | |
| 4416 | /* layout type */ |
| 4417 | p = xdr_inline_decode(xdr, 4); |
| 4418 | if (unlikely(!p)) { |
| 4419 | print_overflow_msg(__func__, xdr); |
| 4420 | return -EIO; |
| 4421 | } |
| 4422 | res->l_type = be32_to_cpup(p); |
| 4423 | |
| 4424 | /* thi_hintset bitmap */ |
| 4425 | status = decode_attr_bitmap(xdr, bitmap); |
| 4426 | if (status < 0) |
| 4427 | goto xdr_error; |
| 4428 | |
| 4429 | /* thi_hintlist length */ |
| 4430 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4431 | if (status < 0) |
| 4432 | goto xdr_error; |
| 4433 | /* thi_hintlist */ |
| 4434 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4435 | if (status < 0) |
| 4436 | goto xdr_error; |
| 4437 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4438 | if (status < 0) |
| 4439 | goto xdr_error; |
| 4440 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4441 | THRESHOLD_RD_IO); |
| 4442 | if (status < 0) |
| 4443 | goto xdr_error; |
| 4444 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4445 | THRESHOLD_WR_IO); |
| 4446 | if (status < 0) |
| 4447 | goto xdr_error; |
| 4448 | |
| 4449 | status = verify_attr_len(xdr, savep, attrlen); |
| 4450 | res->bm = bitmap[0]; |
| 4451 | |
| 4452 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4453 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4454 | res->wr_io_sz); |
| 4455 | xdr_error: |
| 4456 | dprintk("%s ret=%d!\n", __func__, status); |
| 4457 | return status; |
| 4458 | } |
| 4459 | |
| 4460 | /* |
| 4461 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4462 | */ |
| 4463 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4464 | uint32_t *bitmap, |
| 4465 | struct nfs4_threshold *res) |
| 4466 | { |
| 4467 | __be32 *p; |
| 4468 | int status = 0; |
| 4469 | uint32_t num; |
| 4470 | |
| 4471 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4472 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4473 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4474 | /* Did the server return an unrequested attribute? */ |
| 4475 | if (unlikely(res == NULL)) |
| 4476 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4477 | p = xdr_inline_decode(xdr, 4); |
| 4478 | if (unlikely(!p)) |
| 4479 | goto out_overflow; |
| 4480 | num = be32_to_cpup(p); |
| 4481 | if (num == 0) |
| 4482 | return 0; |
| 4483 | if (num > 1) |
| 4484 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4485 | "drivers per filesystem not supported\n", |
| 4486 | __func__); |
| 4487 | |
| 4488 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4489 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4490 | } |
| 4491 | return status; |
| 4492 | out_overflow: |
| 4493 | print_overflow_msg(__func__, xdr); |
| 4494 | return -EIO; |
| 4495 | } |
| 4496 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4497 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4498 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4499 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4500 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4501 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4502 | int status; |
| 4503 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4504 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4505 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4506 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4507 | status = decode_attr_type(xdr, bitmap, &type); |
| 4508 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4509 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4510 | fattr->mode = 0; |
| 4511 | if (status != 0) { |
| 4512 | fattr->mode |= nfs_type2fmt[type]; |
| 4513 | fattr->valid |= status; |
| 4514 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4515 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4516 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4517 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4519 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4520 | |
| 4521 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4522 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4523 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4524 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4525 | |
| 4526 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4527 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4528 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4529 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4530 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4531 | err = 0; |
| 4532 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4533 | if (status < 0) |
| 4534 | goto xdr_error; |
| 4535 | |
| 4536 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4537 | if (status < 0) |
| 4538 | goto xdr_error; |
| 4539 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4540 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4541 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4542 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4543 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4544 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4545 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4546 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4547 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4548 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4549 | |
| 4550 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4551 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4552 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4553 | if (status != 0) { |
| 4554 | fattr->mode |= fmode; |
| 4555 | fattr->valid |= status; |
| 4556 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4557 | |
| 4558 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4559 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4560 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4561 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4562 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4563 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4564 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4565 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4566 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4567 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4568 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4569 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4570 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4571 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4572 | |
| 4573 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4574 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4575 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4576 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4577 | |
| 4578 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4579 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4580 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4581 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4582 | |
| 4583 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4584 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4585 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4586 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4587 | |
| 4588 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4589 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4590 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4591 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4592 | |
| 4593 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4594 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4595 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4596 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4597 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4598 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4599 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4600 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4601 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4602 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4603 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4604 | if (status < 0) |
| 4605 | goto xdr_error; |
| 4606 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4607 | if (label) { |
| 4608 | status = decode_attr_security_label(xdr, bitmap, label); |
| 4609 | if (status < 0) |
| 4610 | goto xdr_error; |
| 4611 | fattr->valid |= status; |
| 4612 | } |
| 4613 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4614 | xdr_error: |
| 4615 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4616 | return status; |
| 4617 | } |
| 4618 | |
| 4619 | 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] | 4620 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4621 | struct nfs4_label *label, const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4622 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4623 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4624 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4625 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4626 | int status; |
| 4627 | |
| 4628 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4629 | if (status < 0) |
| 4630 | goto xdr_error; |
| 4631 | |
| 4632 | status = decode_attr_bitmap(xdr, bitmap); |
| 4633 | if (status < 0) |
| 4634 | goto xdr_error; |
| 4635 | |
| 4636 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4637 | if (status < 0) |
| 4638 | goto xdr_error; |
| 4639 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4640 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
| 4641 | label, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4642 | if (status < 0) |
| 4643 | goto xdr_error; |
| 4644 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4645 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4646 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4647 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4648 | return status; |
| 4649 | } |
| 4650 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4651 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 4652 | struct nfs4_label *label, const struct nfs_server *server) |
| 4653 | { |
| 4654 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); |
| 4655 | } |
| 4656 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4657 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4658 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4659 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4660 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4661 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4662 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4663 | /* |
| 4664 | * Decode potentially multiple layout types. Currently we only support |
| 4665 | * one layout driver per file system. |
| 4666 | */ |
| 4667 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4668 | uint32_t *layouttype) |
| 4669 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4670 | __be32 *p; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4671 | int num; |
| 4672 | |
| 4673 | p = xdr_inline_decode(xdr, 4); |
| 4674 | if (unlikely(!p)) |
| 4675 | goto out_overflow; |
| 4676 | num = be32_to_cpup(p); |
| 4677 | |
| 4678 | /* pNFS is not supported by the underlying file system */ |
| 4679 | if (num == 0) { |
| 4680 | *layouttype = 0; |
| 4681 | return 0; |
| 4682 | } |
| 4683 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4684 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4685 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4686 | |
| 4687 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4688 | p = xdr_inline_decode(xdr, num * 4); |
| 4689 | if (unlikely(!p)) |
| 4690 | goto out_overflow; |
| 4691 | *layouttype = be32_to_cpup(p); |
| 4692 | return 0; |
| 4693 | out_overflow: |
| 4694 | print_overflow_msg(__func__, xdr); |
| 4695 | return -EIO; |
| 4696 | } |
| 4697 | |
| 4698 | /* |
| 4699 | * The type of file system exported. |
| 4700 | * Note we must ensure that layouttype is set in any non-error case. |
| 4701 | */ |
| 4702 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4703 | uint32_t *layouttype) |
| 4704 | { |
| 4705 | int status = 0; |
| 4706 | |
| 4707 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4708 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4709 | return -EIO; |
| 4710 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4711 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4712 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4713 | } else |
| 4714 | *layouttype = 0; |
| 4715 | return status; |
| 4716 | } |
| 4717 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4718 | /* |
| 4719 | * The prefered block size for layout directed io |
| 4720 | */ |
| 4721 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4722 | uint32_t *res) |
| 4723 | { |
| 4724 | __be32 *p; |
| 4725 | |
| 4726 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4727 | *res = 0; |
| 4728 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4729 | p = xdr_inline_decode(xdr, 4); |
| 4730 | if (unlikely(!p)) { |
| 4731 | print_overflow_msg(__func__, xdr); |
| 4732 | return -EIO; |
| 4733 | } |
| 4734 | *res = be32_to_cpup(p); |
| 4735 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4736 | } |
| 4737 | return 0; |
| 4738 | } |
| 4739 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4740 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4741 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4742 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4743 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4744 | int status; |
| 4745 | |
| 4746 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4747 | goto xdr_error; |
| 4748 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4749 | goto xdr_error; |
| 4750 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4751 | goto xdr_error; |
| 4752 | |
| 4753 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4754 | |
| 4755 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4756 | goto xdr_error; |
| 4757 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4758 | goto xdr_error; |
| 4759 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4760 | goto xdr_error; |
| 4761 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4762 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4763 | goto xdr_error; |
| 4764 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4765 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4766 | if (status != 0) |
| 4767 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4768 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4769 | if (status != 0) |
| 4770 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4771 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4772 | if (status) |
| 4773 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4774 | |
| 4775 | status = verify_attr_len(xdr, savep, attrlen); |
| 4776 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4777 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4778 | return status; |
| 4779 | } |
| 4780 | |
| 4781 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4782 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4783 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4784 | uint32_t len; |
| 4785 | int status; |
| 4786 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4787 | /* Zero handle first to allow comparisons */ |
| 4788 | memset(fh, 0, sizeof(*fh)); |
| 4789 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4790 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4791 | if (status) |
| 4792 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4793 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4794 | p = xdr_inline_decode(xdr, 4); |
| 4795 | if (unlikely(!p)) |
| 4796 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4797 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4798 | if (len > NFS4_FHSIZE) |
| 4799 | return -EIO; |
| 4800 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4801 | p = xdr_inline_decode(xdr, len); |
| 4802 | if (unlikely(!p)) |
| 4803 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4804 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4805 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4806 | out_overflow: |
| 4807 | print_overflow_msg(__func__, xdr); |
| 4808 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4809 | } |
| 4810 | |
| 4811 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4812 | { |
| 4813 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4814 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4815 | status = decode_op_hdr(xdr, OP_LINK); |
| 4816 | if (status) |
| 4817 | return status; |
| 4818 | return decode_change_info(xdr, cinfo); |
| 4819 | } |
| 4820 | |
| 4821 | /* |
| 4822 | * We create the owner, so we know a proper owner.id length is 4. |
| 4823 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4824 | 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] | 4825 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4826 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4827 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4828 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4829 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4830 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4831 | if (unlikely(!p)) |
| 4832 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4833 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4834 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4835 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4836 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4837 | fl->fl_start = (loff_t)offset; |
| 4838 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4839 | if (length == ~(uint64_t)0) |
| 4840 | fl->fl_end = OFFSET_MAX; |
| 4841 | fl->fl_type = F_WRLCK; |
| 4842 | if (type & 1) |
| 4843 | fl->fl_type = F_RDLCK; |
| 4844 | fl->fl_pid = 0; |
| 4845 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4846 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4847 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4848 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4849 | if (likely(p)) |
| 4850 | return -NFS4ERR_DENIED; |
| 4851 | out_overflow: |
| 4852 | print_overflow_msg(__func__, xdr); |
| 4853 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4854 | } |
| 4855 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4856 | 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] | 4857 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4858 | int status; |
| 4859 | |
| 4860 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4861 | if (status == -EIO) |
| 4862 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4863 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4864 | status = decode_stateid(xdr, &res->stateid); |
| 4865 | if (unlikely(status)) |
| 4866 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4867 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4868 | status = decode_lock_denied(xdr, NULL); |
| 4869 | if (res->open_seqid != NULL) |
| 4870 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4871 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4872 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4873 | return status; |
| 4874 | } |
| 4875 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4876 | 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] | 4877 | { |
| 4878 | int status; |
| 4879 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4880 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4881 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4882 | return status; |
| 4883 | } |
| 4884 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4885 | 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] | 4886 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4887 | int status; |
| 4888 | |
| 4889 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4890 | if (status != -EIO) |
| 4891 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4892 | if (status == 0) |
| 4893 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4894 | return status; |
| 4895 | } |
| 4896 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4897 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4898 | { |
| 4899 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4900 | } |
| 4901 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4902 | static int decode_lookup(struct xdr_stream *xdr) |
| 4903 | { |
| 4904 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4905 | } |
| 4906 | |
| 4907 | /* This is too sick! */ |
| 4908 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4909 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4910 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4911 | uint32_t limit_type, nblocks, blocksize; |
| 4912 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4913 | p = xdr_inline_decode(xdr, 12); |
| 4914 | if (unlikely(!p)) |
| 4915 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4916 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4917 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4918 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4919 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4920 | break; |
| 4921 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4922 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4923 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4924 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4925 | } |
| 4926 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4927 | out_overflow: |
| 4928 | print_overflow_msg(__func__, xdr); |
| 4929 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4930 | } |
| 4931 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 4932 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| 4933 | uint32_t delegation_type, |
| 4934 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4935 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4936 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4937 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4938 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4939 | status = decode_stateid(xdr, &res->delegation); |
| 4940 | if (unlikely(status)) |
| 4941 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4942 | p = xdr_inline_decode(xdr, 4); |
| 4943 | if (unlikely(!p)) |
| 4944 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4945 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4946 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4947 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4948 | case NFS4_OPEN_DELEGATE_READ: |
| 4949 | res->delegation_type = FMODE_READ; |
| 4950 | break; |
| 4951 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4952 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4953 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4954 | return -EIO; |
| 4955 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4956 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4957 | out_overflow: |
| 4958 | print_overflow_msg(__func__, xdr); |
| 4959 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4960 | } |
| 4961 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 4962 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4963 | { |
| 4964 | __be32 *p; |
| 4965 | uint32_t why_no_delegation; |
| 4966 | |
| 4967 | p = xdr_inline_decode(xdr, 4); |
| 4968 | if (unlikely(!p)) |
| 4969 | goto out_overflow; |
| 4970 | why_no_delegation = be32_to_cpup(p); |
| 4971 | switch (why_no_delegation) { |
| 4972 | case WND4_CONTENTION: |
| 4973 | case WND4_RESOURCE: |
| 4974 | xdr_inline_decode(xdr, 4); |
| 4975 | /* Ignore for now */ |
| 4976 | } |
| 4977 | return 0; |
| 4978 | out_overflow: |
| 4979 | print_overflow_msg(__func__, xdr); |
| 4980 | return -EIO; |
| 4981 | } |
| 4982 | |
| 4983 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4984 | { |
| 4985 | __be32 *p; |
| 4986 | uint32_t delegation_type; |
| 4987 | |
| 4988 | p = xdr_inline_decode(xdr, 4); |
| 4989 | if (unlikely(!p)) |
| 4990 | goto out_overflow; |
| 4991 | delegation_type = be32_to_cpup(p); |
| 4992 | res->delegation_type = 0; |
| 4993 | switch (delegation_type) { |
| 4994 | case NFS4_OPEN_DELEGATE_NONE: |
| 4995 | return 0; |
| 4996 | case NFS4_OPEN_DELEGATE_READ: |
| 4997 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4998 | return decode_rw_delegation(xdr, delegation_type, res); |
| 4999 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
| 5000 | return decode_no_delegation(xdr, res); |
| 5001 | } |
| 5002 | return -EIO; |
| 5003 | out_overflow: |
| 5004 | print_overflow_msg(__func__, xdr); |
| 5005 | return -EIO; |
| 5006 | } |
| 5007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5009 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5010 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5011 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5012 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5013 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5014 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 5015 | return status; |
| 5016 | nfs_increment_open_seqid(status, res->seqid); |
| 5017 | if (status) |
| 5018 | return status; |
| 5019 | status = decode_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5020 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5021 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5022 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5023 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5024 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5025 | p = xdr_inline_decode(xdr, 8); |
| 5026 | if (unlikely(!p)) |
| 5027 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5028 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5029 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5030 | if (bmlen > 10) |
| 5031 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5032 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5033 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5034 | if (unlikely(!p)) |
| 5035 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5036 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5037 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5038 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5039 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5040 | res->attrset[i] = 0; |
| 5041 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5042 | return decode_delegation(xdr, res); |
| 5043 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5044 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5045 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5046 | out_overflow: |
| 5047 | print_overflow_msg(__func__, xdr); |
| 5048 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5049 | } |
| 5050 | |
| 5051 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5052 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5053 | int status; |
| 5054 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5055 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5056 | if (status != -EIO) |
| 5057 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5058 | if (!status) |
| 5059 | status = decode_stateid(xdr, &res->stateid); |
| 5060 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5061 | } |
| 5062 | |
| 5063 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5064 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5065 | int status; |
| 5066 | |
| 5067 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5068 | if (status != -EIO) |
| 5069 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5070 | if (!status) |
| 5071 | status = decode_stateid(xdr, &res->stateid); |
| 5072 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | } |
| 5074 | |
| 5075 | static int decode_putfh(struct xdr_stream *xdr) |
| 5076 | { |
| 5077 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5078 | } |
| 5079 | |
| 5080 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5081 | { |
| 5082 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5083 | } |
| 5084 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5085 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5086 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5087 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5088 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5089 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5090 | int status; |
| 5091 | |
| 5092 | status = decode_op_hdr(xdr, OP_READ); |
| 5093 | if (status) |
| 5094 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5095 | p = xdr_inline_decode(xdr, 8); |
| 5096 | if (unlikely(!p)) |
| 5097 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5098 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5099 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5100 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5101 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5102 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5103 | "count %u > recvd %u\n", count, recvd); |
| 5104 | count = recvd; |
| 5105 | eof = 0; |
| 5106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5107 | res->eof = eof; |
| 5108 | res->count = count; |
| 5109 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5110 | out_overflow: |
| 5111 | print_overflow_msg(__func__, xdr); |
| 5112 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5113 | } |
| 5114 | |
| 5115 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5116 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5117 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5118 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5119 | |
| 5120 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5121 | if (!status) |
| 5122 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5123 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5124 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5125 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5126 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5127 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5128 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5129 | } |
| 5130 | |
| 5131 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5132 | { |
| 5133 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5134 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5135 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5136 | int status; |
| 5137 | |
| 5138 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5139 | if (status) |
| 5140 | return status; |
| 5141 | |
| 5142 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5143 | p = xdr_inline_decode(xdr, 4); |
| 5144 | if (unlikely(!p)) |
| 5145 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5146 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5147 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5148 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5149 | return -ENAMETOOLONG; |
| 5150 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5151 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5152 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5153 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5154 | "count %u > recvd %u\n", len, recvd); |
| 5155 | return -EIO; |
| 5156 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5157 | /* |
| 5158 | * The XDR encode routine has set things up so that |
| 5159 | * the link text will be copied directly into the |
| 5160 | * buffer. We just have to do overflow-checking, |
| 5161 | * and and null-terminate the text (the VFS expects |
| 5162 | * null-termination). |
| 5163 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5164 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5165 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5166 | out_overflow: |
| 5167 | print_overflow_msg(__func__, xdr); |
| 5168 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5169 | } |
| 5170 | |
| 5171 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5172 | { |
| 5173 | int status; |
| 5174 | |
| 5175 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5176 | if (status) |
| 5177 | goto out; |
| 5178 | status = decode_change_info(xdr, cinfo); |
| 5179 | out: |
| 5180 | return status; |
| 5181 | } |
| 5182 | |
| 5183 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5184 | struct nfs4_change_info *new_cinfo) |
| 5185 | { |
| 5186 | int status; |
| 5187 | |
| 5188 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5189 | if (status) |
| 5190 | goto out; |
| 5191 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5192 | goto out; |
| 5193 | status = decode_change_info(xdr, new_cinfo); |
| 5194 | out: |
| 5195 | return status; |
| 5196 | } |
| 5197 | |
| 5198 | static int decode_renew(struct xdr_stream *xdr) |
| 5199 | { |
| 5200 | return decode_op_hdr(xdr, OP_RENEW); |
| 5201 | } |
| 5202 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5203 | static int |
| 5204 | decode_restorefh(struct xdr_stream *xdr) |
| 5205 | { |
| 5206 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5207 | } |
| 5208 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5209 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5210 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5211 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5212 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5213 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5214 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5215 | int status; |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5216 | unsigned int pg_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5217 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5218 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5219 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5220 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5221 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5222 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5223 | |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5224 | /* Calculate the offset of the page data */ |
| 5225 | pg_offset = xdr->buf->head[0].iov_len; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5226 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5227 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5228 | goto out; |
| 5229 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5230 | goto out; |
| 5231 | |
| 5232 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5233 | return -EIO; |
| 5234 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5235 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5236 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5237 | * are stored with the acl data to handle the problem of |
| 5238 | * variable length bitmaps.*/ |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5239 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5240 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5241 | |
| 5242 | /* Check for receive buffer overflow */ |
| 5243 | if (res->acl_len > (xdr->nwords << 2) || |
| 5244 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5245 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5246 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5247 | attrlen, xdr->nwords << 2); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5248 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5249 | } else |
| 5250 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5251 | |
| 5252 | out: |
| 5253 | return status; |
| 5254 | } |
| 5255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5256 | static int |
| 5257 | decode_savefh(struct xdr_stream *xdr) |
| 5258 | { |
| 5259 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5260 | } |
| 5261 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5262 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5263 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5264 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5265 | uint32_t bmlen; |
| 5266 | int status; |
| 5267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5268 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5269 | if (status) |
| 5270 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5271 | p = xdr_inline_decode(xdr, 4); |
| 5272 | if (unlikely(!p)) |
| 5273 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5274 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5275 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5276 | if (likely(p)) |
| 5277 | return 0; |
| 5278 | out_overflow: |
| 5279 | print_overflow_msg(__func__, xdr); |
| 5280 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5281 | } |
| 5282 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5283 | 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] | 5284 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5285 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5286 | uint32_t opnum; |
| 5287 | int32_t nfserr; |
| 5288 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5289 | p = xdr_inline_decode(xdr, 8); |
| 5290 | if (unlikely(!p)) |
| 5291 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5292 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5293 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5294 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5295 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5296 | return -EIO; |
| 5297 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5298 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5299 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5300 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5301 | if (unlikely(!p)) |
| 5302 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5303 | p = xdr_decode_hyper(p, &res->clientid); |
| 5304 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5305 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5306 | uint32_t len; |
| 5307 | |
| 5308 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5309 | p = xdr_inline_decode(xdr, 4); |
| 5310 | if (unlikely(!p)) |
| 5311 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5312 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5313 | p = xdr_inline_decode(xdr, len); |
| 5314 | if (unlikely(!p)) |
| 5315 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5316 | |
| 5317 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5318 | p = xdr_inline_decode(xdr, 4); |
| 5319 | if (unlikely(!p)) |
| 5320 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5321 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5322 | p = xdr_inline_decode(xdr, len); |
| 5323 | if (unlikely(!p)) |
| 5324 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5325 | return -NFSERR_CLID_INUSE; |
| 5326 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5327 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5328 | |
| 5329 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5330 | out_overflow: |
| 5331 | print_overflow_msg(__func__, xdr); |
| 5332 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5333 | } |
| 5334 | |
| 5335 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5336 | { |
| 5337 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5338 | } |
| 5339 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5340 | 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] | 5341 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5342 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5343 | int status; |
| 5344 | |
| 5345 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5346 | if (status) |
| 5347 | return status; |
| 5348 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5349 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5350 | if (unlikely(!p)) |
| 5351 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5352 | res->count = be32_to_cpup(p++); |
| 5353 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5354 | return decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5355 | out_overflow: |
| 5356 | print_overflow_msg(__func__, xdr); |
| 5357 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | } |
| 5359 | |
| 5360 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5361 | { |
| 5362 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5363 | } |
| 5364 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5365 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5366 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5367 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5368 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5369 | __be32 *p; |
| 5370 | |
| 5371 | p = xdr_inline_decode(xdr, 4); |
| 5372 | if (unlikely(!p)) |
| 5373 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5374 | oid_len = be32_to_cpup(p); |
| 5375 | if (oid_len > GSS_OID_MAX_LEN) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5376 | goto out_err; |
| 5377 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5378 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5379 | if (unlikely(!p)) |
| 5380 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5381 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5382 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5383 | |
| 5384 | p = xdr_inline_decode(xdr, 8); |
| 5385 | if (unlikely(!p)) |
| 5386 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5387 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5388 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5389 | |
| 5390 | return 0; |
| 5391 | |
| 5392 | out_overflow: |
| 5393 | print_overflow_msg(__func__, xdr); |
| 5394 | return -EIO; |
| 5395 | out_err: |
| 5396 | return -EINVAL; |
| 5397 | } |
| 5398 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5399 | 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] | 5400 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5401 | struct nfs4_secinfo4 *sec_flavor; |
| 5402 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5403 | int status; |
| 5404 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5405 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5406 | p = xdr_inline_decode(xdr, 4); |
| 5407 | if (unlikely(!p)) |
| 5408 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5409 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5410 | res->flavors->num_flavors = 0; |
| 5411 | num_flavors = be32_to_cpup(p); |
| 5412 | |
| 5413 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5414 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5415 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5416 | break; |
| 5417 | |
| 5418 | p = xdr_inline_decode(xdr, 4); |
| 5419 | if (unlikely(!p)) |
| 5420 | goto out_overflow; |
| 5421 | sec_flavor->flavor = be32_to_cpup(p); |
| 5422 | |
| 5423 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5424 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5425 | if (status) |
| 5426 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5427 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5428 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5429 | } |
| 5430 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5431 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5432 | out: |
| 5433 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5434 | out_overflow: |
| 5435 | print_overflow_msg(__func__, xdr); |
| 5436 | return -EIO; |
| 5437 | } |
| 5438 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5439 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5440 | { |
| 5441 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5442 | if (status) |
| 5443 | return status; |
| 5444 | return decode_secinfo_common(xdr, res); |
| 5445 | } |
| 5446 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5447 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5448 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5449 | { |
| 5450 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5451 | if (status) |
| 5452 | return status; |
| 5453 | return decode_secinfo_common(xdr, res); |
| 5454 | } |
| 5455 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5456 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5457 | { |
| 5458 | __be32 *p; |
| 5459 | uint32_t bitmap_words; |
| 5460 | unsigned int i; |
| 5461 | |
| 5462 | p = xdr_inline_decode(xdr, 4); |
| 5463 | bitmap_words = be32_to_cpup(p++); |
| 5464 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) |
| 5465 | return -EIO; |
| 5466 | p = xdr_inline_decode(xdr, 4 * bitmap_words); |
| 5467 | for (i = 0; i < bitmap_words; i++) |
| 5468 | op_map->u.words[i] = be32_to_cpup(p++); |
| 5469 | |
| 5470 | return 0; |
| 5471 | } |
| 5472 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5473 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5474 | struct nfs41_exchange_id_res *res) |
| 5475 | { |
| 5476 | __be32 *p; |
| 5477 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5478 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5479 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5480 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5481 | |
| 5482 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5483 | if (status) |
| 5484 | return status; |
| 5485 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5486 | p = xdr_inline_decode(xdr, 8); |
| 5487 | if (unlikely(!p)) |
| 5488 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5489 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5490 | p = xdr_inline_decode(xdr, 12); |
| 5491 | if (unlikely(!p)) |
| 5492 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5493 | res->seqid = be32_to_cpup(p++); |
| 5494 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5495 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5496 | res->state_protect.how = be32_to_cpup(p); |
| 5497 | switch (res->state_protect.how) { |
| 5498 | case SP4_NONE: |
| 5499 | break; |
| 5500 | case SP4_MACH_CRED: |
| 5501 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5502 | if (status) |
| 5503 | return status; |
| 5504 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5505 | if (status) |
| 5506 | return status; |
| 5507 | break; |
| 5508 | default: |
| 5509 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5510 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5511 | } |
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_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5514 | p = xdr_inline_decode(xdr, 8); |
| 5515 | if (unlikely(!p)) |
| 5516 | goto out_overflow; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5517 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5518 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5519 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5520 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5521 | if (unlikely(status)) |
| 5522 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5523 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5524 | return -EIO; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5525 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5526 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5527 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5528 | /* server_scope4 */ |
| 5529 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5530 | if (unlikely(status)) |
| 5531 | return status; |
| 5532 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5533 | return -EIO; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5534 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5535 | res->server_scope->server_scope_sz = dummy; |
| 5536 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5537 | /* Implementation Id */ |
| 5538 | p = xdr_inline_decode(xdr, 4); |
| 5539 | if (unlikely(!p)) |
| 5540 | goto out_overflow; |
| 5541 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5542 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5543 | if (impl_id_count) { |
| 5544 | /* nii_domain */ |
| 5545 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5546 | if (unlikely(status)) |
| 5547 | return status; |
| 5548 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5549 | return -EIO; |
| 5550 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5551 | |
| 5552 | /* nii_name */ |
| 5553 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5554 | if (unlikely(status)) |
| 5555 | return status; |
| 5556 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5557 | return -EIO; |
| 5558 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5559 | |
| 5560 | /* nii_date */ |
| 5561 | p = xdr_inline_decode(xdr, 12); |
| 5562 | if (unlikely(!p)) |
| 5563 | goto out_overflow; |
| 5564 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5565 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5566 | |
| 5567 | /* if there's more than one entry, ignore the rest */ |
| 5568 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5569 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5570 | out_overflow: |
| 5571 | print_overflow_msg(__func__, xdr); |
| 5572 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5573 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5574 | |
| 5575 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5576 | struct nfs4_channel_attrs *attrs) |
| 5577 | { |
| 5578 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5579 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5580 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5581 | p = xdr_inline_decode(xdr, 28); |
| 5582 | if (unlikely(!p)) |
| 5583 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5584 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5585 | if (val) |
| 5586 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5587 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5588 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5589 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5590 | attrs->max_ops = be32_to_cpup(p++); |
| 5591 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5592 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5593 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5594 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5595 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5596 | return -EINVAL; |
| 5597 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5598 | if (nr_attrs == 1) { |
| 5599 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5600 | if (unlikely(!p)) |
| 5601 | goto out_overflow; |
| 5602 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5603 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5604 | out_overflow: |
| 5605 | print_overflow_msg(__func__, xdr); |
| 5606 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5607 | } |
| 5608 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5609 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5610 | { |
| 5611 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5612 | } |
| 5613 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5614 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5615 | struct nfs41_bind_conn_to_session_res *res) |
| 5616 | { |
| 5617 | __be32 *p; |
| 5618 | int status; |
| 5619 | |
| 5620 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5621 | if (!status) |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5622 | status = decode_sessionid(xdr, &res->sessionid); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5623 | if (unlikely(status)) |
| 5624 | return status; |
| 5625 | |
| 5626 | /* dir flags, rdma mode bool */ |
| 5627 | p = xdr_inline_decode(xdr, 8); |
| 5628 | if (unlikely(!p)) |
| 5629 | goto out_overflow; |
| 5630 | |
| 5631 | res->dir = be32_to_cpup(p++); |
| 5632 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5633 | return -EIO; |
| 5634 | if (be32_to_cpup(p) == 0) |
| 5635 | res->use_conn_in_rdma_mode = false; |
| 5636 | else |
| 5637 | res->use_conn_in_rdma_mode = true; |
| 5638 | |
| 5639 | return 0; |
| 5640 | out_overflow: |
| 5641 | print_overflow_msg(__func__, xdr); |
| 5642 | return -EIO; |
| 5643 | } |
| 5644 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5645 | static int decode_create_session(struct xdr_stream *xdr, |
| 5646 | struct nfs41_create_session_res *res) |
| 5647 | { |
| 5648 | __be32 *p; |
| 5649 | int status; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5650 | |
| 5651 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5652 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5653 | status = decode_sessionid(xdr, &res->sessionid); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5654 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5655 | return status; |
| 5656 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5657 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5658 | p = xdr_inline_decode(xdr, 8); |
| 5659 | if (unlikely(!p)) |
| 5660 | goto out_overflow; |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5661 | res->seqid = be32_to_cpup(p++); |
| 5662 | res->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5663 | |
| 5664 | /* Channel attributes */ |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5665 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5666 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5667 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5668 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5669 | out_overflow: |
| 5670 | print_overflow_msg(__func__, xdr); |
| 5671 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5672 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5673 | |
| 5674 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5675 | { |
| 5676 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5677 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5678 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5679 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5680 | { |
| 5681 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5682 | } |
| 5683 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5684 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5685 | { |
| 5686 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5687 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5688 | #endif /* CONFIG_NFS_V4_1 */ |
| 5689 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5690 | static int decode_sequence(struct xdr_stream *xdr, |
| 5691 | struct nfs4_sequence_res *res, |
| 5692 | struct rpc_rqst *rqstp) |
| 5693 | { |
| 5694 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5695 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5696 | struct nfs4_sessionid id; |
| 5697 | u32 dummy; |
| 5698 | int status; |
| 5699 | __be32 *p; |
| 5700 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5701 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5702 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5703 | if (!res->sr_slot->table->session) |
| 5704 | return 0; |
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 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5707 | if (!status) |
| 5708 | status = decode_sessionid(xdr, &id); |
| 5709 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5710 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5711 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5712 | /* |
| 5713 | * If the server returns different values for sessionID, slotID or |
| 5714 | * sequence number, the server is looney tunes. |
| 5715 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5716 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5717 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5718 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5719 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5720 | NFS4_MAX_SESSIONID_LEN)) { |
| 5721 | dprintk("%s Invalid session id\n", __func__); |
| 5722 | goto out_err; |
| 5723 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5724 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5725 | p = xdr_inline_decode(xdr, 20); |
| 5726 | if (unlikely(!p)) |
| 5727 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5728 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5729 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5730 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5731 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5732 | dprintk("%s Invalid sequence number\n", __func__); |
| 5733 | goto out_err; |
| 5734 | } |
| 5735 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5736 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5737 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5738 | dprintk("%s Invalid slot id\n", __func__); |
| 5739 | goto out_err; |
| 5740 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5741 | /* highest slot id */ |
| 5742 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5743 | /* target highest slot id */ |
| 5744 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5745 | /* result flags */ |
| 5746 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5747 | status = 0; |
| 5748 | out_err: |
| 5749 | res->sr_status = status; |
| 5750 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5751 | out_overflow: |
| 5752 | print_overflow_msg(__func__, xdr); |
| 5753 | status = -EIO; |
| 5754 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5755 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5756 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5757 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5758 | } |
| 5759 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5760 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5761 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5762 | struct nfs4_getdeviceinfo_res *res) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5763 | { |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5764 | struct pnfs_device *pdev = res->pdev; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5765 | __be32 *p; |
| 5766 | uint32_t len, type; |
| 5767 | int status; |
| 5768 | |
| 5769 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5770 | if (status) { |
| 5771 | if (status == -ETOOSMALL) { |
| 5772 | p = xdr_inline_decode(xdr, 4); |
| 5773 | if (unlikely(!p)) |
| 5774 | goto out_overflow; |
| 5775 | pdev->mincount = be32_to_cpup(p); |
| 5776 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5777 | __func__, pdev->mincount); |
| 5778 | } |
| 5779 | return status; |
| 5780 | } |
| 5781 | |
| 5782 | p = xdr_inline_decode(xdr, 8); |
| 5783 | if (unlikely(!p)) |
| 5784 | goto out_overflow; |
| 5785 | type = be32_to_cpup(p++); |
| 5786 | if (type != pdev->layout_type) { |
| 5787 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5788 | __func__, pdev->layout_type, type); |
| 5789 | return -EINVAL; |
| 5790 | } |
| 5791 | /* |
| 5792 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5793 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5794 | * and places the remaining xdr data in xdr_buf->tail |
| 5795 | */ |
| 5796 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5797 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 5798 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5799 | |
| 5800 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5801 | p = xdr_inline_decode(xdr, 4); |
| 5802 | if (unlikely(!p)) |
| 5803 | goto out_overflow; |
| 5804 | len = be32_to_cpup(p); |
| 5805 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5806 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5807 | |
| 5808 | p = xdr_inline_decode(xdr, 4 * len); |
| 5809 | if (unlikely(!p)) |
| 5810 | goto out_overflow; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5811 | |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5812 | res->notification = be32_to_cpup(p++); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5813 | for (i = 1; i < len; i++) { |
| 5814 | if (be32_to_cpup(p++)) { |
| 5815 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5816 | __func__); |
| 5817 | return -EIO; |
| 5818 | } |
| 5819 | } |
| 5820 | } |
| 5821 | return 0; |
| 5822 | out_overflow: |
| 5823 | print_overflow_msg(__func__, xdr); |
| 5824 | return -EIO; |
| 5825 | } |
| 5826 | |
| 5827 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5828 | struct nfs4_layoutget_res *res) |
| 5829 | { |
| 5830 | __be32 *p; |
| 5831 | int status; |
| 5832 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5833 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5834 | |
| 5835 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5836 | if (status) |
| 5837 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5838 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5839 | if (unlikely(!p)) |
| 5840 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5841 | res->return_on_close = be32_to_cpup(p); |
| 5842 | decode_stateid(xdr, &res->stateid); |
| 5843 | p = xdr_inline_decode(xdr, 4); |
| 5844 | if (unlikely(!p)) |
| 5845 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5846 | layout_count = be32_to_cpup(p); |
| 5847 | if (!layout_count) { |
| 5848 | dprintk("%s: server responded with empty layout array\n", |
| 5849 | __func__); |
| 5850 | return -EINVAL; |
| 5851 | } |
| 5852 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5853 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5854 | if (unlikely(!p)) |
| 5855 | goto out_overflow; |
| 5856 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5857 | p = xdr_decode_hyper(p, &res->range.length); |
| 5858 | res->range.iomode = be32_to_cpup(p++); |
| 5859 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5860 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5861 | |
| 5862 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5863 | __func__, |
| 5864 | (unsigned long)res->range.offset, |
| 5865 | (unsigned long)res->range.length, |
| 5866 | res->range.iomode, |
| 5867 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5868 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5869 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5870 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5871 | if (res->layoutp->len > recvd) { |
| 5872 | dprintk("NFS: server cheating in layoutget reply: " |
| 5873 | "layout len %u > recvd %u\n", |
| 5874 | res->layoutp->len, recvd); |
| 5875 | return -EINVAL; |
| 5876 | } |
| 5877 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5878 | if (layout_count > 1) { |
| 5879 | /* We only handle a length one array at the moment. Any |
| 5880 | * further entries are just ignored. Note that this means |
| 5881 | * the client may see a response that is less than the |
| 5882 | * minimum it requested. |
| 5883 | */ |
| 5884 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5885 | __func__, layout_count); |
| 5886 | } |
| 5887 | |
| 5888 | return 0; |
| 5889 | out_overflow: |
| 5890 | print_overflow_msg(__func__, xdr); |
| 5891 | return -EIO; |
| 5892 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5893 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5894 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5895 | struct nfs4_layoutreturn_res *res) |
| 5896 | { |
| 5897 | __be32 *p; |
| 5898 | int status; |
| 5899 | |
| 5900 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5901 | if (status) |
| 5902 | return status; |
| 5903 | p = xdr_inline_decode(xdr, 4); |
| 5904 | if (unlikely(!p)) |
| 5905 | goto out_overflow; |
| 5906 | res->lrs_present = be32_to_cpup(p); |
| 5907 | if (res->lrs_present) |
| 5908 | status = decode_stateid(xdr, &res->stateid); |
| 5909 | return status; |
| 5910 | out_overflow: |
| 5911 | print_overflow_msg(__func__, xdr); |
| 5912 | return -EIO; |
| 5913 | } |
| 5914 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5915 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5916 | struct rpc_rqst *req, |
| 5917 | struct nfs4_layoutcommit_res *res) |
| 5918 | { |
| 5919 | __be32 *p; |
| 5920 | __u32 sizechanged; |
| 5921 | int status; |
| 5922 | |
| 5923 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5924 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5925 | if (status) |
| 5926 | return status; |
| 5927 | |
| 5928 | p = xdr_inline_decode(xdr, 4); |
| 5929 | if (unlikely(!p)) |
| 5930 | goto out_overflow; |
| 5931 | sizechanged = be32_to_cpup(p); |
| 5932 | |
| 5933 | if (sizechanged) { |
| 5934 | /* throw away new size */ |
| 5935 | p = xdr_inline_decode(xdr, 8); |
| 5936 | if (unlikely(!p)) |
| 5937 | goto out_overflow; |
| 5938 | } |
| 5939 | return 0; |
| 5940 | out_overflow: |
| 5941 | print_overflow_msg(__func__, xdr); |
| 5942 | return -EIO; |
| 5943 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5944 | |
| 5945 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5946 | struct nfs41_test_stateid_res *res) |
| 5947 | { |
| 5948 | __be32 *p; |
| 5949 | int status; |
| 5950 | int num_res; |
| 5951 | |
| 5952 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5953 | if (status) |
| 5954 | return status; |
| 5955 | |
| 5956 | p = xdr_inline_decode(xdr, 4); |
| 5957 | if (unlikely(!p)) |
| 5958 | goto out_overflow; |
| 5959 | num_res = be32_to_cpup(p++); |
| 5960 | if (num_res != 1) |
| 5961 | goto out; |
| 5962 | |
| 5963 | p = xdr_inline_decode(xdr, 4); |
| 5964 | if (unlikely(!p)) |
| 5965 | goto out_overflow; |
| 5966 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5967 | |
| 5968 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5969 | out_overflow: |
| 5970 | print_overflow_msg(__func__, xdr); |
| 5971 | out: |
| 5972 | return -EIO; |
| 5973 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5974 | |
| 5975 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5976 | struct nfs41_free_stateid_res *res) |
| 5977 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 5978 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5979 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5980 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5981 | #endif /* CONFIG_NFS_V4_1 */ |
| 5982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5983 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5984 | * END OF "GENERIC" DECODE ROUTINES. |
| 5985 | */ |
| 5986 | |
| 5987 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5988 | * Decode OPEN_DOWNGRADE response |
| 5989 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5990 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5991 | struct xdr_stream *xdr, |
| 5992 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5993 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5994 | struct compound_hdr hdr; |
| 5995 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5996 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5997 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5998 | if (status) |
| 5999 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6000 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6001 | if (status) |
| 6002 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6003 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6004 | if (status) |
| 6005 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6006 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6007 | if (status != 0) |
| 6008 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6009 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6010 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6011 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6012 | } |
| 6013 | |
| 6014 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6015 | * Decode ACCESS response |
| 6016 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6017 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6018 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6019 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6020 | struct compound_hdr hdr; |
| 6021 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6022 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6023 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6024 | if (status) |
| 6025 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6026 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6027 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6028 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6029 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6030 | if (status != 0) |
| 6031 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6032 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6033 | if (status != 0) |
| 6034 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6035 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6036 | out: |
| 6037 | return status; |
| 6038 | } |
| 6039 | |
| 6040 | /* |
| 6041 | * Decode LOOKUP response |
| 6042 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6043 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6044 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6045 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6046 | struct compound_hdr hdr; |
| 6047 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6048 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6049 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6050 | if (status) |
| 6051 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6052 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6053 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6054 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6055 | status = decode_putfh(xdr); |
| 6056 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6057 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6058 | status = decode_lookup(xdr); |
| 6059 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6060 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6061 | status = decode_getfh(xdr, res->fh); |
| 6062 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6063 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6064 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6065 | out: |
| 6066 | return status; |
| 6067 | } |
| 6068 | |
| 6069 | /* |
| 6070 | * Decode LOOKUP_ROOT response |
| 6071 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6072 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6073 | struct xdr_stream *xdr, |
| 6074 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6075 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6076 | struct compound_hdr hdr; |
| 6077 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6078 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6079 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6080 | if (status) |
| 6081 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6082 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6083 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6084 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6085 | status = decode_putrootfh(xdr); |
| 6086 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6087 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6088 | status = decode_getfh(xdr, res->fh); |
| 6089 | if (status == 0) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6090 | status = decode_getfattr_label(xdr, res->fattr, |
| 6091 | res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6092 | out: |
| 6093 | return status; |
| 6094 | } |
| 6095 | |
| 6096 | /* |
| 6097 | * Decode REMOVE response |
| 6098 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6099 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6100 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6101 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6102 | struct compound_hdr hdr; |
| 6103 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6104 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6105 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6106 | if (status) |
| 6107 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6108 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6109 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6110 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6111 | status = decode_putfh(xdr); |
| 6112 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6113 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6114 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6115 | out: |
| 6116 | return status; |
| 6117 | } |
| 6118 | |
| 6119 | /* |
| 6120 | * Decode RENAME response |
| 6121 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6122 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6123 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6124 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6125 | struct compound_hdr hdr; |
| 6126 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6127 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6128 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6129 | if (status) |
| 6130 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6131 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6132 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6133 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6134 | status = decode_putfh(xdr); |
| 6135 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6136 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6137 | status = decode_savefh(xdr); |
| 6138 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6139 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6140 | status = decode_putfh(xdr); |
| 6141 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6143 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6144 | out: |
| 6145 | return status; |
| 6146 | } |
| 6147 | |
| 6148 | /* |
| 6149 | * Decode LINK response |
| 6150 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6151 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6152 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6153 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6154 | struct compound_hdr hdr; |
| 6155 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6156 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6157 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6158 | if (status) |
| 6159 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6160 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6161 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6162 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6163 | status = decode_putfh(xdr); |
| 6164 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6166 | status = decode_savefh(xdr); |
| 6167 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6168 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6169 | status = decode_putfh(xdr); |
| 6170 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6171 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6172 | status = decode_link(xdr, &res->cinfo); |
| 6173 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6174 | goto out; |
| 6175 | /* |
| 6176 | * Note order: OP_LINK leaves the directory as the current |
| 6177 | * filehandle. |
| 6178 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6179 | status = decode_restorefh(xdr); |
| 6180 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6181 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6182 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6183 | out: |
| 6184 | return status; |
| 6185 | } |
| 6186 | |
| 6187 | /* |
| 6188 | * Decode CREATE response |
| 6189 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6190 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6191 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6193 | struct compound_hdr hdr; |
| 6194 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6195 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6196 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6197 | if (status) |
| 6198 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6199 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6200 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6201 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6202 | status = decode_putfh(xdr); |
| 6203 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6204 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6205 | status = decode_create(xdr, &res->dir_cinfo); |
| 6206 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6207 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6208 | status = decode_getfh(xdr, res->fh); |
| 6209 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6210 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6211 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6212 | out: |
| 6213 | return status; |
| 6214 | } |
| 6215 | |
| 6216 | /* |
| 6217 | * Decode SYMLINK response |
| 6218 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6219 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6220 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6221 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6222 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6223 | } |
| 6224 | |
| 6225 | /* |
| 6226 | * Decode GETATTR response |
| 6227 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6228 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6229 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6230 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6231 | struct compound_hdr hdr; |
| 6232 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6233 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6234 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6235 | if (status) |
| 6236 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6237 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6238 | if (status) |
| 6239 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6240 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6241 | if (status) |
| 6242 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6243 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | out: |
| 6245 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6246 | } |
| 6247 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6248 | /* |
| 6249 | * Encode an SETACL request |
| 6250 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6251 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6252 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6253 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6254 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6255 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6256 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6257 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6258 | encode_compound_hdr(xdr, req, &hdr); |
| 6259 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6260 | encode_putfh(xdr, args->fh, &hdr); |
| 6261 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6262 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6263 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6264 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6265 | /* |
| 6266 | * Decode SETACL response |
| 6267 | */ |
| 6268 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6269 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6270 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6271 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6272 | struct compound_hdr hdr; |
| 6273 | int status; |
| 6274 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6275 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6276 | if (status) |
| 6277 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6278 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6279 | if (status) |
| 6280 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6281 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6282 | if (status) |
| 6283 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6284 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6285 | out: |
| 6286 | return status; |
| 6287 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6288 | |
| 6289 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6290 | * Decode GETACL response |
| 6291 | */ |
| 6292 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6294 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6295 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6296 | struct compound_hdr hdr; |
| 6297 | int status; |
| 6298 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6299 | if (res->acl_scratch != NULL) { |
| 6300 | void *p = page_address(res->acl_scratch); |
| 6301 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6302 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6303 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6304 | if (status) |
| 6305 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6306 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6307 | if (status) |
| 6308 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6309 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6310 | if (status) |
| 6311 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6312 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6313 | |
| 6314 | out: |
| 6315 | return status; |
| 6316 | } |
| 6317 | |
| 6318 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6319 | * Decode CLOSE response |
| 6320 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6321 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6322 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6323 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6324 | struct compound_hdr hdr; |
| 6325 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6327 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6328 | if (status) |
| 6329 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6330 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6331 | if (status) |
| 6332 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6333 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6334 | if (status) |
| 6335 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6336 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6337 | if (status != 0) |
| 6338 | goto out; |
| 6339 | /* |
| 6340 | * Note: Server may do delete on close for this file |
| 6341 | * in which case the getattr call will fail with |
| 6342 | * an ESTALE error. Shouldn't be a problem, |
| 6343 | * though, since fattr->valid will remain unset. |
| 6344 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6345 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6346 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6347 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6348 | } |
| 6349 | |
| 6350 | /* |
| 6351 | * Decode OPEN response |
| 6352 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6353 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6354 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6355 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6356 | struct compound_hdr hdr; |
| 6357 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6358 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6359 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6360 | if (status) |
| 6361 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6362 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6363 | if (status) |
| 6364 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6365 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6366 | if (status) |
| 6367 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6368 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6369 | if (status) |
| 6370 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6371 | status = decode_getfh(xdr, &res->fh); |
| 6372 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6373 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6374 | if (res->access_request) |
| 6375 | decode_access(xdr, &res->access_supported, &res->access_result); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6376 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6377 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6378 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6379 | } |
| 6380 | |
| 6381 | /* |
| 6382 | * Decode OPEN_CONFIRM response |
| 6383 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6384 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6385 | struct xdr_stream *xdr, |
| 6386 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6388 | struct compound_hdr hdr; |
| 6389 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6390 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6391 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6392 | if (status) |
| 6393 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6394 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6395 | if (status) |
| 6396 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6397 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6399 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6400 | } |
| 6401 | |
| 6402 | /* |
| 6403 | * Decode OPEN response |
| 6404 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6405 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6406 | struct xdr_stream *xdr, |
| 6407 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6408 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6409 | struct compound_hdr hdr; |
| 6410 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6411 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6412 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6413 | if (status) |
| 6414 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6415 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6416 | if (status) |
| 6417 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6418 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6419 | if (status) |
| 6420 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6421 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6422 | if (status) |
| 6423 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6424 | if (res->access_request) |
| 6425 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6426 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6427 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6428 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6429 | } |
| 6430 | |
| 6431 | /* |
| 6432 | * Decode SETATTR response |
| 6433 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6434 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6435 | struct xdr_stream *xdr, |
| 6436 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6437 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6438 | struct compound_hdr hdr; |
| 6439 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6440 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6441 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6442 | if (status) |
| 6443 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6444 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6445 | if (status) |
| 6446 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6447 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6448 | if (status) |
| 6449 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6450 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6451 | if (status) |
| 6452 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6453 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6454 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6455 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6456 | } |
| 6457 | |
| 6458 | /* |
| 6459 | * Decode LOCK response |
| 6460 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6461 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6462 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6464 | struct compound_hdr hdr; |
| 6465 | int status; |
| 6466 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6467 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6468 | if (status) |
| 6469 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6470 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6471 | if (status) |
| 6472 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6473 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6474 | if (status) |
| 6475 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6476 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6477 | out: |
| 6478 | return status; |
| 6479 | } |
| 6480 | |
| 6481 | /* |
| 6482 | * Decode LOCKT response |
| 6483 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6484 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6485 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6487 | struct compound_hdr hdr; |
| 6488 | int status; |
| 6489 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6490 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | if (status) |
| 6492 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6493 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6494 | if (status) |
| 6495 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6496 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | if (status) |
| 6498 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6499 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6500 | out: |
| 6501 | return status; |
| 6502 | } |
| 6503 | |
| 6504 | /* |
| 6505 | * Decode LOCKU response |
| 6506 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6507 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6508 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6509 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6510 | struct compound_hdr hdr; |
| 6511 | int status; |
| 6512 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6513 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6514 | if (status) |
| 6515 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6516 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6517 | if (status) |
| 6518 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6519 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6520 | if (status) |
| 6521 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6522 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6523 | out: |
| 6524 | return status; |
| 6525 | } |
| 6526 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6527 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6528 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6529 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6530 | struct compound_hdr hdr; |
| 6531 | int status; |
| 6532 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6533 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6534 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6535 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6536 | return status; |
| 6537 | } |
| 6538 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6539 | /* |
| 6540 | * Decode READLINK response |
| 6541 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6542 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6543 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6544 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6546 | struct compound_hdr hdr; |
| 6547 | int status; |
| 6548 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6549 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6550 | if (status) |
| 6551 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6552 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6553 | if (status) |
| 6554 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6555 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6556 | if (status) |
| 6557 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6558 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6559 | out: |
| 6560 | return status; |
| 6561 | } |
| 6562 | |
| 6563 | /* |
| 6564 | * Decode READDIR response |
| 6565 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6566 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6567 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6568 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6569 | struct compound_hdr hdr; |
| 6570 | int status; |
| 6571 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6572 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | if (status) |
| 6574 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6575 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6576 | if (status) |
| 6577 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6578 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6579 | if (status) |
| 6580 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6581 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | out: |
| 6583 | return status; |
| 6584 | } |
| 6585 | |
| 6586 | /* |
| 6587 | * Decode Read response |
| 6588 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6589 | 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] | 6590 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6591 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6592 | struct compound_hdr hdr; |
| 6593 | int status; |
| 6594 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6595 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6596 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6597 | if (status) |
| 6598 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6599 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6600 | if (status) |
| 6601 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6602 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6603 | if (status) |
| 6604 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6605 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6606 | if (!status) |
| 6607 | status = res->count; |
| 6608 | out: |
| 6609 | return status; |
| 6610 | } |
| 6611 | |
| 6612 | /* |
| 6613 | * Decode WRITE response |
| 6614 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6615 | 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] | 6616 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6617 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6618 | struct compound_hdr hdr; |
| 6619 | int status; |
| 6620 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6621 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6622 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6623 | if (status) |
| 6624 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6625 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6626 | if (status) |
| 6627 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6628 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6629 | if (status) |
| 6630 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6631 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6632 | if (status) |
| 6633 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6634 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6635 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6636 | if (!status) |
| 6637 | status = res->count; |
| 6638 | out: |
| 6639 | return status; |
| 6640 | } |
| 6641 | |
| 6642 | /* |
| 6643 | * Decode COMMIT response |
| 6644 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6645 | 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] | 6646 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6647 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6648 | struct compound_hdr hdr; |
| 6649 | int status; |
| 6650 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6651 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6652 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6653 | if (status) |
| 6654 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6655 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6656 | if (status) |
| 6657 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6658 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6659 | if (status) |
| 6660 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6661 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6662 | out: |
| 6663 | return status; |
| 6664 | } |
| 6665 | |
| 6666 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6667 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6668 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6669 | 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] | 6670 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6671 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6672 | struct compound_hdr hdr; |
| 6673 | int status; |
| 6674 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6675 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6676 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6677 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6678 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6679 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6680 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6681 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6682 | return status; |
| 6683 | } |
| 6684 | |
| 6685 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6686 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6687 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6688 | 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] | 6689 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6690 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6691 | struct compound_hdr hdr; |
| 6692 | int status; |
| 6693 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6695 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6696 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6697 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6698 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6699 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6700 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6701 | return status; |
| 6702 | } |
| 6703 | |
| 6704 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6705 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6706 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6707 | 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] | 6708 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6709 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6710 | struct compound_hdr hdr; |
| 6711 | int status; |
| 6712 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6713 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6714 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6715 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6716 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6717 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6718 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6719 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6720 | return status; |
| 6721 | } |
| 6722 | |
| 6723 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6724 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6725 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6726 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6727 | struct xdr_stream *xdr, |
| 6728 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6729 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6730 | struct compound_hdr hdr; |
| 6731 | int status; |
| 6732 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6733 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6734 | if (status) |
| 6735 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6736 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6737 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6738 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6739 | status = decode_putfh(xdr); |
| 6740 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6741 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6742 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6743 | out: |
| 6744 | return status; |
| 6745 | } |
| 6746 | |
| 6747 | /* |
| 6748 | * Decode RENEW response |
| 6749 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6750 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6751 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6752 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6753 | struct compound_hdr hdr; |
| 6754 | int status; |
| 6755 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6756 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6757 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6758 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6759 | return status; |
| 6760 | } |
| 6761 | |
| 6762 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6763 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6764 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6765 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6766 | struct xdr_stream *xdr, |
| 6767 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6768 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6769 | struct compound_hdr hdr; |
| 6770 | int status; |
| 6771 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6772 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6773 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6774 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6775 | return status; |
| 6776 | } |
| 6777 | |
| 6778 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6779 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6780 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6781 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 6782 | struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6783 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6784 | struct compound_hdr hdr; |
| 6785 | int status; |
| 6786 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6787 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6788 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6789 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6790 | return status; |
| 6791 | } |
| 6792 | |
| 6793 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6794 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6795 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6796 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6797 | struct xdr_stream *xdr, |
| 6798 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6799 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6800 | struct compound_hdr hdr; |
| 6801 | int status; |
| 6802 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6803 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6804 | if (status) |
| 6805 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6806 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6807 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6808 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6809 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6810 | if (status != 0) |
| 6811 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6812 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6813 | if (status != 0) |
| 6814 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6815 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6816 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6817 | return status; |
| 6818 | } |
| 6819 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6820 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6821 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6822 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6823 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6824 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6825 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6826 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6827 | struct compound_hdr hdr; |
| 6828 | int status; |
| 6829 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6830 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6831 | if (status) |
| 6832 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6833 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6834 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6835 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6836 | status = decode_putfh(xdr); |
| 6837 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6838 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6839 | if (res->migration) { |
| 6840 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6841 | status = decode_getfattr_generic(xdr, |
| 6842 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6843 | NULL, res->fs_locations, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6844 | NULL, res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6845 | if (status) |
| 6846 | goto out; |
| 6847 | if (res->renew) |
| 6848 | status = decode_renew(xdr); |
| 6849 | } else { |
| 6850 | status = decode_lookup(xdr); |
| 6851 | if (status) |
| 6852 | goto out; |
| 6853 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6854 | status = decode_getfattr_generic(xdr, |
| 6855 | &res->fs_locations->fattr, |
| 6856 | NULL, res->fs_locations, |
| 6857 | NULL, res->fs_locations->server); |
| 6858 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6859 | out: |
| 6860 | return status; |
| 6861 | } |
| 6862 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6863 | /* |
| 6864 | * Decode SECINFO response |
| 6865 | */ |
| 6866 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6867 | struct xdr_stream *xdr, |
| 6868 | struct nfs4_secinfo_res *res) |
| 6869 | { |
| 6870 | struct compound_hdr hdr; |
| 6871 | int status; |
| 6872 | |
| 6873 | status = decode_compound_hdr(xdr, &hdr); |
| 6874 | if (status) |
| 6875 | goto out; |
| 6876 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6877 | if (status) |
| 6878 | goto out; |
| 6879 | status = decode_putfh(xdr); |
| 6880 | if (status) |
| 6881 | goto out; |
| 6882 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6883 | out: |
| 6884 | return status; |
| 6885 | } |
| 6886 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 6887 | /* |
| 6888 | * Decode FSID_PRESENT response |
| 6889 | */ |
| 6890 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 6891 | struct xdr_stream *xdr, |
| 6892 | struct nfs4_fsid_present_res *res) |
| 6893 | { |
| 6894 | struct compound_hdr hdr; |
| 6895 | int status; |
| 6896 | |
| 6897 | status = decode_compound_hdr(xdr, &hdr); |
| 6898 | if (status) |
| 6899 | goto out; |
| 6900 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6901 | if (status) |
| 6902 | goto out; |
| 6903 | status = decode_putfh(xdr); |
| 6904 | if (status) |
| 6905 | goto out; |
| 6906 | status = decode_getfh(xdr, res->fh); |
| 6907 | if (status) |
| 6908 | goto out; |
| 6909 | if (res->renew) |
| 6910 | status = decode_renew(xdr); |
| 6911 | out: |
| 6912 | return status; |
| 6913 | } |
| 6914 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6915 | #if defined(CONFIG_NFS_V4_1) |
| 6916 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 6917 | * Decode BIND_CONN_TO_SESSION response |
| 6918 | */ |
| 6919 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 6920 | struct xdr_stream *xdr, |
| 6921 | void *res) |
| 6922 | { |
| 6923 | struct compound_hdr hdr; |
| 6924 | int status; |
| 6925 | |
| 6926 | status = decode_compound_hdr(xdr, &hdr); |
| 6927 | if (!status) |
| 6928 | status = decode_bind_conn_to_session(xdr, res); |
| 6929 | return status; |
| 6930 | } |
| 6931 | |
| 6932 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6933 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6934 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6935 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6936 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6937 | void *res) |
| 6938 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6939 | struct compound_hdr hdr; |
| 6940 | int status; |
| 6941 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6942 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6943 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6944 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6945 | return status; |
| 6946 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6947 | |
| 6948 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6949 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6950 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6951 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6952 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6953 | struct nfs41_create_session_res *res) |
| 6954 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6955 | struct compound_hdr hdr; |
| 6956 | int status; |
| 6957 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6958 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6959 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6960 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6961 | return status; |
| 6962 | } |
| 6963 | |
| 6964 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6965 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6966 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6967 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6968 | struct xdr_stream *xdr, |
| 6969 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6970 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6971 | struct compound_hdr hdr; |
| 6972 | int status; |
| 6973 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6974 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6975 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6976 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6977 | return status; |
| 6978 | } |
| 6979 | |
| 6980 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 6981 | * Decode DESTROY_CLIENTID response |
| 6982 | */ |
| 6983 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 6984 | struct xdr_stream *xdr, |
| 6985 | void *res) |
| 6986 | { |
| 6987 | struct compound_hdr hdr; |
| 6988 | int status; |
| 6989 | |
| 6990 | status = decode_compound_hdr(xdr, &hdr); |
| 6991 | if (!status) |
| 6992 | status = decode_destroy_clientid(xdr, res); |
| 6993 | return status; |
| 6994 | } |
| 6995 | |
| 6996 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6997 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6998 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6999 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 7000 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7001 | struct nfs4_sequence_res *res) |
| 7002 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7003 | struct compound_hdr hdr; |
| 7004 | int status; |
| 7005 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7006 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7007 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7008 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7009 | return status; |
| 7010 | } |
| 7011 | |
| 7012 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7013 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7014 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7015 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 7016 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7017 | struct nfs4_get_lease_time_res *res) |
| 7018 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7019 | struct compound_hdr hdr; |
| 7020 | int status; |
| 7021 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7022 | status = decode_compound_hdr(xdr, &hdr); |
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_sequence(xdr, &res->lr_seq_res, rqstp); |
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_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7027 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7028 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7029 | return status; |
| 7030 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7031 | |
| 7032 | /* |
| 7033 | * Decode RECLAIM_COMPLETE response |
| 7034 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7035 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7036 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7037 | struct nfs41_reclaim_complete_res *res) |
| 7038 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7039 | struct compound_hdr hdr; |
| 7040 | int status; |
| 7041 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7042 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7043 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7044 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7045 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7046 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7047 | return status; |
| 7048 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7049 | |
| 7050 | /* |
| 7051 | * Decode GETDEVINFO response |
| 7052 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7053 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7054 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7055 | struct nfs4_getdeviceinfo_res *res) |
| 7056 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7057 | struct compound_hdr hdr; |
| 7058 | int status; |
| 7059 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7060 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7061 | if (status != 0) |
| 7062 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7063 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7064 | if (status != 0) |
| 7065 | goto out; |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 7066 | status = decode_getdeviceinfo(xdr, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7067 | out: |
| 7068 | return status; |
| 7069 | } |
| 7070 | |
| 7071 | /* |
| 7072 | * Decode LAYOUTGET response |
| 7073 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7074 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7075 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7076 | struct nfs4_layoutget_res *res) |
| 7077 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7078 | struct compound_hdr hdr; |
| 7079 | int status; |
| 7080 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7081 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7082 | if (status) |
| 7083 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7084 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7085 | if (status) |
| 7086 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7087 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7088 | if (status) |
| 7089 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7090 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7091 | out: |
| 7092 | return status; |
| 7093 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7094 | |
| 7095 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7096 | * Decode LAYOUTRETURN response |
| 7097 | */ |
| 7098 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7099 | struct xdr_stream *xdr, |
| 7100 | struct nfs4_layoutreturn_res *res) |
| 7101 | { |
| 7102 | struct compound_hdr hdr; |
| 7103 | int status; |
| 7104 | |
| 7105 | status = decode_compound_hdr(xdr, &hdr); |
| 7106 | if (status) |
| 7107 | goto out; |
| 7108 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7109 | if (status) |
| 7110 | goto out; |
| 7111 | status = decode_putfh(xdr); |
| 7112 | if (status) |
| 7113 | goto out; |
| 7114 | status = decode_layoutreturn(xdr, res); |
| 7115 | out: |
| 7116 | return status; |
| 7117 | } |
| 7118 | |
| 7119 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7120 | * Decode LAYOUTCOMMIT response |
| 7121 | */ |
| 7122 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7123 | struct xdr_stream *xdr, |
| 7124 | struct nfs4_layoutcommit_res *res) |
| 7125 | { |
| 7126 | struct compound_hdr hdr; |
| 7127 | int status; |
| 7128 | |
| 7129 | status = decode_compound_hdr(xdr, &hdr); |
| 7130 | if (status) |
| 7131 | goto out; |
| 7132 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7133 | if (status) |
| 7134 | goto out; |
| 7135 | status = decode_putfh(xdr); |
| 7136 | if (status) |
| 7137 | goto out; |
| 7138 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7139 | if (status) |
| 7140 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7141 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7142 | out: |
| 7143 | return status; |
| 7144 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7145 | |
| 7146 | /* |
| 7147 | * Decode SECINFO_NO_NAME response |
| 7148 | */ |
| 7149 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7150 | struct xdr_stream *xdr, |
| 7151 | struct nfs4_secinfo_res *res) |
| 7152 | { |
| 7153 | struct compound_hdr hdr; |
| 7154 | int status; |
| 7155 | |
| 7156 | status = decode_compound_hdr(xdr, &hdr); |
| 7157 | if (status) |
| 7158 | goto out; |
| 7159 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7160 | if (status) |
| 7161 | goto out; |
| 7162 | status = decode_putrootfh(xdr); |
| 7163 | if (status) |
| 7164 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7165 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7166 | out: |
| 7167 | return status; |
| 7168 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7169 | |
| 7170 | /* |
| 7171 | * Decode TEST_STATEID response |
| 7172 | */ |
| 7173 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7174 | struct xdr_stream *xdr, |
| 7175 | struct nfs41_test_stateid_res *res) |
| 7176 | { |
| 7177 | struct compound_hdr hdr; |
| 7178 | int status; |
| 7179 | |
| 7180 | status = decode_compound_hdr(xdr, &hdr); |
| 7181 | if (status) |
| 7182 | goto out; |
| 7183 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7184 | if (status) |
| 7185 | goto out; |
| 7186 | status = decode_test_stateid(xdr, res); |
| 7187 | out: |
| 7188 | return status; |
| 7189 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7190 | |
| 7191 | /* |
| 7192 | * Decode FREE_STATEID response |
| 7193 | */ |
| 7194 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7195 | struct xdr_stream *xdr, |
| 7196 | struct nfs41_free_stateid_res *res) |
| 7197 | { |
| 7198 | struct compound_hdr hdr; |
| 7199 | int status; |
| 7200 | |
| 7201 | status = decode_compound_hdr(xdr, &hdr); |
| 7202 | if (status) |
| 7203 | goto out; |
| 7204 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7205 | if (status) |
| 7206 | goto out; |
| 7207 | status = decode_free_stateid(xdr, res); |
| 7208 | out: |
| 7209 | return status; |
| 7210 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7211 | #endif /* CONFIG_NFS_V4_1 */ |
| 7212 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7213 | /** |
| 7214 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7215 | * the local page cache. |
| 7216 | * @xdr: XDR stream where entry resides |
| 7217 | * @entry: buffer to fill in with entry data |
| 7218 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7219 | * |
| 7220 | * Returns zero if successful, otherwise a negative errno value is |
| 7221 | * returned. |
| 7222 | * |
| 7223 | * This function is not invoked during READDIR reply decoding, but |
| 7224 | * rather whenever an application invokes the getdents(2) system call |
| 7225 | * on a directory already in our cache. |
| 7226 | */ |
| 7227 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 7228 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7229 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7230 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7231 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7232 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7233 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7234 | if (unlikely(!p)) |
| 7235 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7236 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7237 | p = xdr_inline_decode(xdr, 4); |
| 7238 | if (unlikely(!p)) |
| 7239 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7240 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7241 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7242 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7243 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7244 | } |
| 7245 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7246 | p = xdr_inline_decode(xdr, 12); |
| 7247 | if (unlikely(!p)) |
| 7248 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7249 | entry->prev_cookie = entry->cookie; |
| 7250 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7251 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7252 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7253 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7254 | if (unlikely(!p)) |
| 7255 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7256 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7257 | |
| 7258 | /* |
| 7259 | * In case the server doesn't return an inode number, |
| 7260 | * we fake one here. (We don't use inode number 0, |
| 7261 | * since glibc seems to choke on it...) |
| 7262 | */ |
| 7263 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7264 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7265 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7266 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7267 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7268 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7269 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7270 | goto out_overflow; |
| 7271 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7272 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7273 | NULL, entry->label, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7274 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7275 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7276 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7277 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7278 | entry->ino = entry->fattr->fileid; |
| 7279 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7280 | entry->d_type = DT_UNKNOWN; |
| 7281 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7282 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7283 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7284 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7285 | |
| 7286 | out_overflow: |
| 7287 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7288 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7289 | } |
| 7290 | |
| 7291 | /* |
| 7292 | * We need to translate between nfs status return values and |
| 7293 | * the local errno values which may not be the same. |
| 7294 | */ |
| 7295 | static struct { |
| 7296 | int stat; |
| 7297 | int errno; |
| 7298 | } nfs_errtbl[] = { |
| 7299 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7300 | { NFS4ERR_PERM, -EPERM }, |
| 7301 | { NFS4ERR_NOENT, -ENOENT }, |
| 7302 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7303 | { NFS4ERR_NXIO, -ENXIO }, |
| 7304 | { NFS4ERR_ACCESS, -EACCES }, |
| 7305 | { NFS4ERR_EXIST, -EEXIST }, |
| 7306 | { NFS4ERR_XDEV, -EXDEV }, |
| 7307 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7308 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7309 | { NFS4ERR_INVAL, -EINVAL }, |
| 7310 | { NFS4ERR_FBIG, -EFBIG }, |
| 7311 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7312 | { NFS4ERR_ROFS, -EROFS }, |
| 7313 | { NFS4ERR_MLINK, -EMLINK }, |
| 7314 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7315 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7316 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7317 | { NFS4ERR_STALE, -ESTALE }, |
| 7318 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7319 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7320 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7321 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7322 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7323 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7324 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7325 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7326 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7327 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7328 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7329 | }; |
| 7330 | |
| 7331 | /* |
| 7332 | * Convert an NFS error code to a local one. |
| 7333 | * This one is used jointly by NFSv2 and NFSv3. |
| 7334 | */ |
| 7335 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7336 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7337 | { |
| 7338 | int i; |
| 7339 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7340 | if (nfs_errtbl[i].stat == stat) |
| 7341 | return nfs_errtbl[i].errno; |
| 7342 | } |
| 7343 | if (stat <= 10000 || stat > 10100) { |
| 7344 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7345 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7346 | } |
| 7347 | /* If we cannot translate the error, the recovery routines should |
| 7348 | * handle it. |
| 7349 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7350 | * not conflict with native Linux error codes. |
| 7351 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7352 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7353 | } |
| 7354 | |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7355 | #ifdef CONFIG_NFS_V4_2 |
| 7356 | #include "nfs42xdr.c" |
| 7357 | #endif /* CONFIG_NFS_V4_2 */ |
| 7358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7359 | #define PROC(proc, argtype, restype) \ |
| 7360 | [NFSPROC4_CLNT_##proc] = { \ |
| 7361 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7362 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7363 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7364 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7365 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7366 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7367 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7369 | |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7370 | #define STUB(proc) \ |
| 7371 | [NFSPROC4_CLNT_##proc] = { \ |
| 7372 | .p_name = #proc, \ |
| 7373 | } |
| 7374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7375 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7376 | PROC(READ, enc_read, dec_read), |
| 7377 | PROC(WRITE, enc_write, dec_write), |
| 7378 | PROC(COMMIT, enc_commit, dec_commit), |
| 7379 | PROC(OPEN, enc_open, dec_open), |
| 7380 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7381 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7382 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7383 | PROC(CLOSE, enc_close, dec_close), |
| 7384 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7385 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7386 | PROC(RENEW, enc_renew, dec_renew), |
| 7387 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7388 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7389 | PROC(LOCK, enc_lock, dec_lock), |
| 7390 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7391 | PROC(LOCKU, enc_locku, dec_locku), |
| 7392 | PROC(ACCESS, enc_access, dec_access), |
| 7393 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7394 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7395 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7396 | PROC(REMOVE, enc_remove, dec_remove), |
| 7397 | PROC(RENAME, enc_rename, dec_rename), |
| 7398 | PROC(LINK, enc_link, dec_link), |
| 7399 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7400 | PROC(CREATE, enc_create, dec_create), |
| 7401 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7402 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7403 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7404 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7405 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7406 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7407 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7408 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7409 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7410 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7411 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7412 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7413 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7414 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7415 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7416 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7417 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7418 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7419 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7420 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7421 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7422 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7423 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7424 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7425 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7426 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7427 | STUB(GETDEVICELIST), |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7428 | PROC(BIND_CONN_TO_SESSION, |
| 7429 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7430 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7431 | #endif /* CONFIG_NFS_V4_1 */ |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7432 | #ifdef CONFIG_NFS_V4_2 |
| 7433 | PROC(SEEK, enc_seek, dec_seek), |
Anna Schumaker | f4ac167 | 2014-11-25 13:18:15 -0500 | [diff] [blame] | 7434 | PROC(ALLOCATE, enc_allocate, dec_allocate), |
Anna Schumaker | 624bd5b | 2014-11-25 13:18:16 -0500 | [diff] [blame] | 7435 | PROC(DEALLOCATE, enc_deallocate, dec_deallocate), |
Trond Myklebust | be3a5d2 | 2015-06-23 19:51:55 +0800 | [diff] [blame] | 7436 | PROC(LAYOUTSTATS, enc_layoutstats, dec_layoutstats), |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7437 | #endif /* CONFIG_NFS_V4_2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7438 | }; |
| 7439 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7440 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7441 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7442 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7443 | .procs = nfs4_procedures |
| 7444 | }; |
| 7445 | |
| 7446 | /* |
| 7447 | * Local variables: |
| 7448 | * c-basic-offset: 8 |
| 7449 | * End: |
| 7450 | */ |