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 + \ |
Trond Myklebust | 6669cb8 | 2015-08-27 20:43:20 -0400 | [diff] [blame] | 403 | 1 + \ |
| 404 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 405 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 406 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 407 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 408 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 409 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 410 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 411 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 412 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 413 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 414 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 415 | #else /* CONFIG_NFS_V4_1 */ |
| 416 | #define encode_sequence_maxsz 0 |
| 417 | #define decode_sequence_maxsz 0 |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 418 | #define encode_layoutreturn_maxsz 0 |
| 419 | #define decode_layoutreturn_maxsz 0 |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 420 | #endif /* CONFIG_NFS_V4_1 */ |
| 421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 423 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 424 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 425 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 427 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 429 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 431 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 433 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 435 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 437 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 439 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 441 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 443 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 445 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 447 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 449 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 451 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 452 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 454 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 456 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 457 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 459 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 461 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 465 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 467 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 468 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 469 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 470 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 471 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 472 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 474 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 475 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 476 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 477 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 478 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 479 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 480 | #define NFS4_enc_open_confirm_sz \ |
| 481 | (compound_encode_hdr_maxsz + \ |
| 482 | encode_putfh_maxsz + \ |
| 483 | encode_open_confirm_maxsz) |
| 484 | #define NFS4_dec_open_confirm_sz \ |
| 485 | (compound_decode_hdr_maxsz + \ |
| 486 | decode_putfh_maxsz + \ |
| 487 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 489 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 491 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 492 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 493 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 495 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 497 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 498 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 499 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | #define NFS4_enc_open_downgrade_sz \ |
| 501 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 502 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 503 | encode_putfh_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 504 | encode_open_downgrade_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | #define NFS4_dec_open_downgrade_sz \ |
| 506 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 507 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 508 | decode_putfh_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 509 | decode_open_downgrade_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 510 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 511 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 512 | encode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 513 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 514 | encode_close_maxsz + \ |
| 515 | encode_getattr_maxsz) |
| 516 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 517 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 518 | decode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 519 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 520 | decode_close_maxsz + \ |
| 521 | decode_getattr_maxsz) |
| 522 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 523 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 524 | encode_putfh_maxsz + \ |
| 525 | encode_setattr_maxsz + \ |
| 526 | encode_getattr_maxsz) |
| 527 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 528 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 529 | decode_putfh_maxsz + \ |
| 530 | decode_setattr_maxsz + \ |
| 531 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 533 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | encode_putfh_maxsz + \ |
| 535 | encode_fsinfo_maxsz) |
| 536 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 537 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | decode_putfh_maxsz + \ |
| 539 | decode_fsinfo_maxsz) |
| 540 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 541 | encode_renew_maxsz) |
| 542 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 543 | decode_renew_maxsz) |
| 544 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 545 | encode_setclientid_maxsz) |
| 546 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 547 | decode_setclientid_maxsz) |
| 548 | #define NFS4_enc_setclientid_confirm_sz \ |
| 549 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 550 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | #define NFS4_dec_setclientid_confirm_sz \ |
| 552 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 553 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 555 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 557 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 559 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 561 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 563 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 565 | encode_lockt_maxsz) |
| 566 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 567 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 568 | decode_putfh_maxsz + \ |
| 569 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 571 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 573 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 575 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 577 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 578 | #define NFS4_enc_release_lockowner_sz \ |
| 579 | (compound_encode_hdr_maxsz + \ |
| 580 | encode_lockowner_maxsz) |
| 581 | #define NFS4_dec_release_lockowner_sz \ |
| 582 | (compound_decode_hdr_maxsz + \ |
| 583 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 585 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 587 | encode_access_maxsz + \ |
| 588 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 590 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 592 | decode_access_maxsz + \ |
| 593 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 595 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 597 | encode_getattr_maxsz + \ |
| 598 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 600 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | decode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 602 | decode_getattr_maxsz + \ |
| 603 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 605 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | encode_putfh_maxsz + \ |
| 607 | encode_lookup_maxsz + \ |
| 608 | encode_getattr_maxsz + \ |
| 609 | encode_getfh_maxsz) |
| 610 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 611 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 613 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | decode_getattr_maxsz + \ |
| 615 | decode_getfh_maxsz) |
| 616 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 617 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | encode_putrootfh_maxsz + \ |
| 619 | encode_getattr_maxsz + \ |
| 620 | encode_getfh_maxsz) |
| 621 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 622 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | decode_putrootfh_maxsz + \ |
| 624 | decode_getattr_maxsz + \ |
| 625 | decode_getfh_maxsz) |
| 626 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 627 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 629 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 631 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 633 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 635 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | encode_putfh_maxsz + \ |
| 637 | encode_savefh_maxsz + \ |
| 638 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 639 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 641 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | decode_putfh_maxsz + \ |
| 643 | decode_savefh_maxsz + \ |
| 644 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 645 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 647 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | encode_putfh_maxsz + \ |
| 649 | encode_savefh_maxsz + \ |
| 650 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 651 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 652 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 653 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 655 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | decode_putfh_maxsz + \ |
| 657 | decode_savefh_maxsz + \ |
| 658 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 659 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 660 | decode_restorefh_maxsz + \ |
| 661 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 663 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | encode_putfh_maxsz + \ |
| 665 | encode_symlink_maxsz + \ |
| 666 | encode_getattr_maxsz + \ |
| 667 | encode_getfh_maxsz) |
| 668 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 669 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | decode_putfh_maxsz + \ |
| 671 | decode_symlink_maxsz + \ |
| 672 | decode_getattr_maxsz + \ |
| 673 | decode_getfh_maxsz) |
| 674 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 675 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | encode_putfh_maxsz + \ |
| 677 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 678 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 679 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 681 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | decode_putfh_maxsz + \ |
| 683 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 684 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 685 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 687 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | encode_putfh_maxsz + \ |
| 689 | encode_getattr_maxsz) |
| 690 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 691 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | decode_putfh_maxsz + \ |
| 693 | decode_getattr_maxsz) |
| 694 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 695 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 697 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 699 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 701 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 703 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 704 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | encode_getattr_maxsz) |
| 706 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 707 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 708 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | decode_getattr_maxsz) |
| 710 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 711 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 713 | encode_delegreturn_maxsz + \ |
| 714 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 716 | decode_sequence_maxsz + \ |
Trond Myklebust | d8434d4c | 2016-11-16 13:54:00 -0500 | [diff] [blame] | 717 | decode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 718 | decode_delegreturn_maxsz + \ |
| 719 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 720 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 721 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 722 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 723 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 724 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 725 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 726 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 727 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 728 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 729 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 730 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 731 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 732 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 733 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 734 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 735 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 736 | #define NFS4_enc_fs_locations_sz \ |
| 737 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 738 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 739 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 740 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 741 | encode_fs_locations_maxsz + \ |
| 742 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 743 | #define NFS4_dec_fs_locations_sz \ |
| 744 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 745 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 746 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 747 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 748 | decode_fs_locations_maxsz + \ |
| 749 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 750 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 751 | encode_sequence_maxsz + \ |
| 752 | encode_putfh_maxsz + \ |
| 753 | encode_secinfo_maxsz) |
| 754 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 755 | decode_sequence_maxsz + \ |
| 756 | decode_putfh_maxsz + \ |
| 757 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 758 | #define NFS4_enc_fsid_present_sz \ |
| 759 | (compound_encode_hdr_maxsz + \ |
| 760 | encode_sequence_maxsz + \ |
| 761 | encode_putfh_maxsz + \ |
| 762 | encode_getfh_maxsz + \ |
| 763 | encode_renew_maxsz) |
| 764 | #define NFS4_dec_fsid_present_sz \ |
| 765 | (compound_decode_hdr_maxsz + \ |
| 766 | decode_sequence_maxsz + \ |
| 767 | decode_putfh_maxsz + \ |
| 768 | decode_getfh_maxsz + \ |
| 769 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 770 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 771 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 772 | (compound_encode_hdr_maxsz + \ |
| 773 | encode_bind_conn_to_session_maxsz) |
| 774 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 775 | (compound_decode_hdr_maxsz + \ |
| 776 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 777 | #define NFS4_enc_exchange_id_sz \ |
| 778 | (compound_encode_hdr_maxsz + \ |
| 779 | encode_exchange_id_maxsz) |
| 780 | #define NFS4_dec_exchange_id_sz \ |
| 781 | (compound_decode_hdr_maxsz + \ |
| 782 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 783 | #define NFS4_enc_create_session_sz \ |
| 784 | (compound_encode_hdr_maxsz + \ |
| 785 | encode_create_session_maxsz) |
| 786 | #define NFS4_dec_create_session_sz \ |
| 787 | (compound_decode_hdr_maxsz + \ |
| 788 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 789 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 790 | encode_destroy_session_maxsz) |
| 791 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 792 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 793 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 794 | encode_destroy_clientid_maxsz) |
| 795 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 796 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 797 | #define NFS4_enc_sequence_sz \ |
| 798 | (compound_decode_hdr_maxsz + \ |
| 799 | encode_sequence_maxsz) |
| 800 | #define NFS4_dec_sequence_sz \ |
| 801 | (compound_decode_hdr_maxsz + \ |
| 802 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 803 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 804 | encode_sequence_maxsz + \ |
| 805 | encode_putrootfh_maxsz + \ |
| 806 | encode_fsinfo_maxsz) |
| 807 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 808 | decode_sequence_maxsz + \ |
| 809 | decode_putrootfh_maxsz + \ |
| 810 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 811 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 812 | encode_sequence_maxsz + \ |
| 813 | encode_reclaim_complete_maxsz) |
| 814 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 815 | decode_sequence_maxsz + \ |
| 816 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 817 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 818 | encode_sequence_maxsz +\ |
| 819 | encode_getdeviceinfo_maxsz) |
| 820 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 821 | decode_sequence_maxsz + \ |
| 822 | decode_getdeviceinfo_maxsz) |
| 823 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 824 | encode_sequence_maxsz + \ |
| 825 | encode_putfh_maxsz + \ |
| 826 | encode_layoutget_maxsz) |
| 827 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 828 | decode_sequence_maxsz + \ |
| 829 | decode_putfh_maxsz + \ |
| 830 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 831 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 832 | encode_sequence_maxsz +\ |
| 833 | encode_putfh_maxsz + \ |
| 834 | encode_layoutcommit_maxsz + \ |
| 835 | encode_getattr_maxsz) |
| 836 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 837 | decode_sequence_maxsz + \ |
| 838 | decode_putfh_maxsz + \ |
| 839 | decode_layoutcommit_maxsz + \ |
| 840 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 841 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 842 | encode_sequence_maxsz + \ |
| 843 | encode_putfh_maxsz + \ |
| 844 | encode_layoutreturn_maxsz) |
| 845 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 846 | decode_sequence_maxsz + \ |
| 847 | decode_putfh_maxsz + \ |
| 848 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 849 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 850 | encode_sequence_maxsz + \ |
| 851 | encode_putrootfh_maxsz +\ |
| 852 | encode_secinfo_no_name_maxsz) |
| 853 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 854 | decode_sequence_maxsz + \ |
| 855 | decode_putrootfh_maxsz + \ |
| 856 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 857 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 858 | encode_sequence_maxsz + \ |
| 859 | encode_test_stateid_maxsz) |
| 860 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 861 | decode_sequence_maxsz + \ |
| 862 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 863 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 864 | encode_sequence_maxsz + \ |
| 865 | encode_free_stateid_maxsz) |
| 866 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 867 | decode_sequence_maxsz + \ |
| 868 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 869 | |
| 870 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 871 | compound_encode_hdr_maxsz + |
| 872 | encode_sequence_maxsz + |
| 873 | encode_putfh_maxsz + |
| 874 | encode_getattr_maxsz) * |
| 875 | XDR_UNIT); |
| 876 | |
| 877 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 878 | compound_decode_hdr_maxsz + |
| 879 | decode_sequence_maxsz + |
| 880 | decode_putfh_maxsz) * |
| 881 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 882 | |
| 883 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 884 | compound_decode_hdr_maxsz + |
| 885 | decode_sequence_maxsz) * |
| 886 | XDR_UNIT); |
| 887 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 888 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 890 | static const umode_t nfs_type2fmt[] = { |
| 891 | [NF4BAD] = 0, |
| 892 | [NF4REG] = S_IFREG, |
| 893 | [NF4DIR] = S_IFDIR, |
| 894 | [NF4BLK] = S_IFBLK, |
| 895 | [NF4CHR] = S_IFCHR, |
| 896 | [NF4LNK] = S_IFLNK, |
| 897 | [NF4SOCK] = S_IFSOCK, |
| 898 | [NF4FIFO] = S_IFIFO, |
| 899 | [NF4ATTRDIR] = 0, |
| 900 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | }; |
| 902 | |
| 903 | struct compound_hdr { |
| 904 | int32_t status; |
| 905 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 906 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | uint32_t taglen; |
| 908 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 909 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 910 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | }; |
| 912 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 913 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 914 | { |
| 915 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 916 | BUG_ON(!p); |
| 917 | return p; |
| 918 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 920 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 921 | { |
| 922 | __be32 *p; |
| 923 | |
| 924 | p = xdr_reserve_space(xdr, len); |
| 925 | xdr_encode_opaque_fixed(p, buf, len); |
| 926 | } |
| 927 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 929 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 930 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 932 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | xdr_encode_opaque(p, str, len); |
| 934 | } |
| 935 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 936 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 937 | { |
| 938 | __be32 *p; |
| 939 | |
| 940 | p = reserve_space(xdr, 4); |
| 941 | *p = cpu_to_be32(n); |
| 942 | } |
| 943 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 944 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 945 | { |
| 946 | __be32 *p; |
| 947 | |
| 948 | p = reserve_space(xdr, 8); |
| 949 | xdr_encode_hyper(p, n); |
| 950 | } |
| 951 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 952 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 953 | const struct nfs_seqid *seqid) |
| 954 | { |
Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 955 | if (seqid != NULL) |
| 956 | encode_uint32(xdr, seqid->sequence->counter); |
| 957 | else |
| 958 | encode_uint32(xdr, 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 959 | } |
| 960 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 961 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 962 | struct rpc_rqst *req, |
| 963 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 965 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 966 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 967 | |
| 968 | /* initialize running count of expected bytes in reply. |
| 969 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 970 | * but this is not required as a MUST for the server to do so. */ |
| 971 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 973 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 974 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 975 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 976 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 977 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 978 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 979 | } |
| 980 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 981 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 982 | uint32_t replen, |
| 983 | struct compound_hdr *hdr) |
| 984 | { |
| 985 | encode_uint32(xdr, op); |
| 986 | hdr->nops++; |
| 987 | hdr->replen += replen; |
| 988 | } |
| 989 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 990 | static void encode_nops(struct compound_hdr *hdr) |
| 991 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 992 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 993 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | } |
| 995 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 996 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 997 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 998 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 999 | } |
| 1000 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 1002 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1003 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1006 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 1007 | const struct nfs4_label *label, |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1008 | const struct nfs_server *server, |
| 1009 | bool excl_check) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | { |
| 1011 | char owner_name[IDMAP_NAMESZ]; |
| 1012 | char owner_group[IDMAP_NAMESZ]; |
| 1013 | int owner_namelen = 0; |
| 1014 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1015 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1016 | unsigned i; |
| 1017 | uint32_t len = 0; |
| 1018 | uint32_t bmval_len; |
| 1019 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | |
| 1021 | /* |
| 1022 | * We reserve enough space to write the entire attribute buffer at once. |
| 1023 | * In the worst-case, this would be |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1024 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 1025 | * = 40 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1026 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | */ |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1028 | if (iap->ia_valid & ATTR_SIZE) { |
| 1029 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1031 | } |
| 1032 | if (iap->ia_valid & ATTR_MODE) { |
| 1033 | bmval[1] |= FATTR4_WORD1_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | len += 4; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1035 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1037 | 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] | 1038 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1039 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1040 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | /* XXX */ |
| 1042 | strcpy(owner_name, "nobody"); |
| 1043 | owner_namelen = sizeof("nobody") - 1; |
| 1044 | /* goto out; */ |
| 1045 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1046 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1048 | } |
| 1049 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1050 | 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] | 1051 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1052 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1053 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | strcpy(owner_group, "nobody"); |
| 1055 | owner_grouplen = sizeof("nobody") - 1; |
| 1056 | /* goto out; */ |
| 1057 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1058 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1060 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | if (iap->ia_valid & ATTR_ATIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1062 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1063 | len += 16; |
| 1064 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1065 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1066 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | } |
| 1068 | if (iap->ia_valid & ATTR_MTIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1069 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1070 | len += 16; |
| 1071 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1072 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1073 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | } |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1075 | |
| 1076 | if (excl_check) { |
| 1077 | const u32 *excl_bmval = server->exclcreat_bitmask; |
| 1078 | bmval[0] &= excl_bmval[0]; |
| 1079 | bmval[1] &= excl_bmval[1]; |
| 1080 | bmval[2] &= excl_bmval[2]; |
| 1081 | |
| 1082 | if (!(excl_bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) |
| 1083 | label = NULL; |
| 1084 | } |
| 1085 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1086 | if (label) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1087 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1088 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1089 | } |
| 1090 | |
| 1091 | if (bmval[2] != 0) |
| 1092 | bmval_len = 3; |
| 1093 | else if (bmval[1] != 0) |
| 1094 | bmval_len = 2; |
| 1095 | else |
| 1096 | bmval_len = 1; |
| 1097 | |
| 1098 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); |
| 1099 | |
| 1100 | *p++ = cpu_to_be32(bmval_len); |
| 1101 | for (i = 0; i < bmval_len; i++) |
| 1102 | *p++ = cpu_to_be32(bmval[i]); |
| 1103 | *p++ = cpu_to_be32(len); |
| 1104 | |
| 1105 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1106 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1107 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1108 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1109 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1110 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1111 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1112 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1113 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1114 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1115 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1116 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); |
| 1117 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
| 1118 | } else |
| 1119 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1120 | } |
| 1121 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1122 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1123 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1124 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); |
| 1125 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
| 1126 | } else |
| 1127 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1128 | } |
| 1129 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1130 | *p++ = cpu_to_be32(label->lfs); |
| 1131 | *p++ = cpu_to_be32(label->pi); |
| 1132 | *p++ = cpu_to_be32(label->len); |
| 1133 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1134 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } |
| 1138 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1139 | 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] | 1140 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1141 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1142 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1145 | 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] | 1146 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1147 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1148 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1149 | encode_nfs4_stateid(xdr, &arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | } |
| 1151 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1152 | 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] | 1153 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1154 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1155 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1156 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1157 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1158 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1159 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1162 | 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] | 1163 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1164 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1165 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1166 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1167 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
| 1169 | switch (create->ftype) { |
| 1170 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1171 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1172 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 2fcc213 | 2015-08-03 13:04:26 -0400 | [diff] [blame] | 1173 | xdr_write_pages(xdr, create->u.symlink.pages, 0, |
| 1174 | create->u.symlink.len); |
| 1175 | xdr->buf->flags |= XDRBUF_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | break; |
| 1177 | |
| 1178 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1179 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1180 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1181 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | break; |
| 1183 | |
| 1184 | default: |
| 1185 | break; |
| 1186 | } |
| 1187 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1188 | encode_string(xdr, create->name->len, create->name->name); |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1189 | encode_attrs(xdr, create->attrs, create->label, create->server, false); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1192 | 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] | 1193 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1194 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1196 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1197 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1198 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1199 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1202 | 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] | 1203 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1204 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1206 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1207 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1208 | *p++ = cpu_to_be32(2); |
| 1209 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1210 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1213 | static void |
| 1214 | encode_getattr_three(struct xdr_stream *xdr, |
| 1215 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1216 | struct compound_hdr *hdr) |
| 1217 | { |
| 1218 | __be32 *p; |
| 1219 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1220 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1221 | if (bm2) { |
| 1222 | p = reserve_space(xdr, 16); |
| 1223 | *p++ = cpu_to_be32(3); |
| 1224 | *p++ = cpu_to_be32(bm0); |
| 1225 | *p++ = cpu_to_be32(bm1); |
| 1226 | *p = cpu_to_be32(bm2); |
| 1227 | } else if (bm1) { |
| 1228 | p = reserve_space(xdr, 12); |
| 1229 | *p++ = cpu_to_be32(2); |
| 1230 | *p++ = cpu_to_be32(bm0); |
| 1231 | *p = cpu_to_be32(bm1); |
| 1232 | } else { |
| 1233 | p = reserve_space(xdr, 8); |
| 1234 | *p++ = cpu_to_be32(1); |
| 1235 | *p = cpu_to_be32(bm0); |
| 1236 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1237 | } |
| 1238 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1239 | 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] | 1240 | { |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1241 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1242 | bitmask[1] & nfs4_fattr_bitmap[1], |
| 1243 | bitmask[2] & nfs4_fattr_bitmap[2], |
| 1244 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1247 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1248 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1249 | struct compound_hdr *hdr) |
| 1250 | { |
| 1251 | encode_getattr_three(xdr, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1252 | bitmask[0] & open_bitmap[0], |
| 1253 | bitmask[1] & open_bitmap[1], |
| 1254 | bitmask[2] & open_bitmap[2], |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1255 | hdr); |
| 1256 | } |
| 1257 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1258 | 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] | 1259 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1260 | encode_getattr_three(xdr, |
| 1261 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1262 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1263 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1264 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | } |
| 1266 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1267 | 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] | 1268 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1269 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1270 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1271 | } |
| 1272 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1273 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1275 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | } |
| 1277 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1278 | 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] | 1279 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1280 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1281 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1284 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1285 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1286 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1287 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1288 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1289 | } |
| 1290 | |
| 1291 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1292 | { |
| 1293 | if (fl->fl_end == OFFSET_MAX) |
| 1294 | return ~(uint64_t)0; |
| 1295 | return fl->fl_end - fl->fl_start + 1; |
| 1296 | } |
| 1297 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1298 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1299 | { |
| 1300 | __be32 *p; |
| 1301 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1302 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1303 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1304 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1305 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1306 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1307 | xdr_encode_hyper(p, lowner->id); |
| 1308 | } |
| 1309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | /* |
| 1311 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1312 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1313 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1314 | 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] | 1315 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1316 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1318 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1319 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1320 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1321 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1322 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1323 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1324 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1325 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1326 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1327 | encode_nfs4_stateid(xdr, &args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1328 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1329 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | } |
| 1331 | else { |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1332 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1333 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | } |
| 1336 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1337 | 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] | 1338 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1339 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1341 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1342 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1343 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1344 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1345 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1346 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1349 | 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] | 1350 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1351 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1353 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1354 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1355 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1356 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1357 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1358 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1359 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | } |
| 1361 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1362 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1363 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1364 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1365 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1366 | } |
| 1367 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1368 | 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] | 1369 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1370 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1371 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | } |
| 1373 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1374 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1376 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1378 | p = reserve_space(xdr, 8); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1379 | *p++ = cpu_to_be32(share_access); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1380 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1384 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1385 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | /* |
| 1387 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1388 | * owner 4 = 32 |
| 1389 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1390 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1391 | encode_share_access(xdr, arg->share_access); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1392 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1393 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1394 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1395 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1396 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1397 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1398 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1402 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1403 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1405 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1406 | switch(arg->createmode) { |
| 1407 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1408 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1409 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, false); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1410 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1411 | case NFS4_CREATE_GUARDED: |
| 1412 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1413 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, false); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1414 | break; |
| 1415 | case NFS4_CREATE_EXCLUSIVE: |
| 1416 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1417 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1418 | break; |
| 1419 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1420 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1421 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1422 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1427 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1428 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1430 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1432 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1433 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1434 | break; |
| 1435 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1436 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1437 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | } |
| 1439 | } |
| 1440 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1441 | 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] | 1442 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1443 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1445 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1447 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1448 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1449 | break; |
| 1450 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1451 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1452 | break; |
| 1453 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1454 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1455 | break; |
| 1456 | default: |
| 1457 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1462 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1463 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1465 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1466 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | encode_string(xdr, name->len, name->name); |
| 1468 | } |
| 1469 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1470 | 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] | 1471 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1472 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1474 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1475 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | encode_delegation_type(xdr, type); |
| 1477 | } |
| 1478 | |
| 1479 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1480 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1481 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1483 | p = reserve_space(xdr, 4); |
| 1484 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1485 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | encode_string(xdr, name->len, name->name); |
| 1487 | } |
| 1488 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1489 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1490 | { |
| 1491 | __be32 *p; |
| 1492 | |
| 1493 | p = reserve_space(xdr, 4); |
| 1494 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1495 | } |
| 1496 | |
| 1497 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1498 | { |
| 1499 | __be32 *p; |
| 1500 | |
| 1501 | p = reserve_space(xdr, 4); |
| 1502 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1503 | encode_nfs4_stateid(xdr, stateid); |
| 1504 | } |
| 1505 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1506 | 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] | 1507 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1508 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | encode_openhdr(xdr, arg); |
| 1510 | encode_opentype(xdr, arg); |
| 1511 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1512 | case NFS4_OPEN_CLAIM_NULL: |
| 1513 | encode_claim_null(xdr, arg->name); |
| 1514 | break; |
| 1515 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1516 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1517 | break; |
| 1518 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1519 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1520 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1521 | case NFS4_OPEN_CLAIM_FH: |
| 1522 | encode_claim_fh(xdr); |
| 1523 | break; |
| 1524 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1525 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1526 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1527 | default: |
| 1528 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | } |
| 1531 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1532 | 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] | 1533 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1534 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1535 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1536 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | } |
| 1538 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1539 | 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] | 1540 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1541 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1542 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1543 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1544 | encode_share_access(xdr, arg->share_access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1547 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1548 | 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] | 1549 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1550 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1551 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | } |
| 1553 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1554 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1556 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | } |
| 1558 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1559 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1560 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1562 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1564 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1565 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1567 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1568 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1569 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1570 | } |
| 1571 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1572 | 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] | 1573 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1574 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1575 | FATTR4_WORD0_RDATTR_ERROR, |
| 1576 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1577 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1578 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1579 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1580 | uint32_t attrlen = 0; |
| 1581 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1583 | if (readdir->plus) { |
| 1584 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1585 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1586 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1587 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1588 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1589 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1590 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1591 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1592 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1593 | /* Use mounted_on_fileid only if the server supports it */ |
| 1594 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1595 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1596 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1597 | attrs[i] &= readdir->bitmask[i]; |
| 1598 | if (attrs[i] != 0) |
| 1599 | attrlen = i+1; |
| 1600 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1601 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1602 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1603 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1604 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1605 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1606 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1607 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1608 | *p++ = cpu_to_be32(attrlen); |
| 1609 | for (i = 0; i < attrlen; i++) |
| 1610 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1611 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1612 | |
| 1613 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1614 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1615 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1616 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1617 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1618 | attrs[1] & readdir->bitmask[1], |
| 1619 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1622 | 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] | 1623 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1624 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | } |
| 1626 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1627 | 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] | 1628 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1629 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1630 | encode_string(xdr, name->len, name->name); |
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 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] | 1634 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1635 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1636 | encode_string(xdr, oldname->len, oldname->name); |
| 1637 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | } |
| 1639 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1640 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1641 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1643 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1644 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | } |
| 1646 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1647 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1648 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1649 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1650 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1651 | } |
| 1652 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1653 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1654 | 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] | 1655 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1656 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1657 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1658 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1659 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1660 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1661 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1662 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1663 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1664 | *p = cpu_to_be32(arg->acl_len); |
Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 1665 | xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1666 | } |
| 1667 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1668 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1669 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1671 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | } |
| 1673 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1674 | static void encode_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] | 1675 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1676 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1677 | encode_nfs4_stateid(xdr, &arg->stateid); |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1678 | encode_attrs(xdr, arg->iap, arg->label, server, false); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | } |
| 1680 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1681 | 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] | 1682 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1683 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1684 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1685 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1686 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1688 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), |
| 1689 | setclientid->sc_clnt->cl_owner_id); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1690 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1691 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1692 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1693 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1694 | p = reserve_space(xdr, 4); |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1695 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | } |
| 1697 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1698 | 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] | 1699 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1700 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1701 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1702 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1703 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | } |
| 1705 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1706 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1707 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1709 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1711 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1712 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1714 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1715 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1716 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1717 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | |
| 1719 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | } |
| 1721 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1722 | 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] | 1723 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1724 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1725 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1727 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1728 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1729 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1730 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1731 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1732 | } |
| 1733 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1734 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1735 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1736 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1737 | struct nfs41_bind_conn_to_session_args *args, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1738 | struct compound_hdr *hdr) |
| 1739 | { |
| 1740 | __be32 *p; |
| 1741 | |
| 1742 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1743 | decode_bind_conn_to_session_maxsz, hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1744 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1745 | p = xdr_reserve_space(xdr, 8); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1746 | *p++ = cpu_to_be32(args->dir); |
| 1747 | *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] | 1748 | } |
| 1749 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1750 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 1751 | { |
| 1752 | unsigned int i; |
| 1753 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1754 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1755 | encode_uint32(xdr, op_map->u.words[i]); |
| 1756 | } |
| 1757 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1758 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1759 | struct nfs41_exchange_id_args *args, |
| 1760 | struct compound_hdr *hdr) |
| 1761 | { |
| 1762 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1763 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1764 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1765 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1766 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1767 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1768 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1769 | encode_string(xdr, strlen(args->client->cl_owner_id), |
| 1770 | args->client->cl_owner_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1771 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1772 | encode_uint32(xdr, args->flags); |
| 1773 | encode_uint32(xdr, args->state_protect.how); |
| 1774 | |
| 1775 | switch (args->state_protect.how) { |
| 1776 | case SP4_NONE: |
| 1777 | break; |
| 1778 | case SP4_MACH_CRED: |
| 1779 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1780 | encode_op_map(xdr, &args->state_protect.allow); |
| 1781 | break; |
| 1782 | default: |
| 1783 | WARN_ON_ONCE(1); |
| 1784 | break; |
| 1785 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1786 | |
| 1787 | if (send_implementation_id && |
| 1788 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1789 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1790 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1791 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1792 | utsname()->sysname, utsname()->release, |
| 1793 | utsname()->version, utsname()->machine); |
| 1794 | |
| 1795 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1796 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1797 | |
| 1798 | encode_string(xdr, |
| 1799 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1800 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1801 | encode_string(xdr, len, impl_name); |
| 1802 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1803 | p = reserve_space(xdr, 12); |
| 1804 | p = xdr_encode_hyper(p, 0); |
| 1805 | *p = cpu_to_be32(0); |
| 1806 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1807 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1808 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1809 | |
| 1810 | static void encode_create_session(struct xdr_stream *xdr, |
| 1811 | struct nfs41_create_session_args *args, |
| 1812 | struct compound_hdr *hdr) |
| 1813 | { |
| 1814 | __be32 *p; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1815 | struct nfs_client *clp = args->client; |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1816 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1817 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1818 | u32 max_resp_sz_cached; |
| 1819 | |
| 1820 | /* |
| 1821 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1822 | * 2 is the verifier. |
| 1823 | */ |
| 1824 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1825 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1826 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1827 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1828 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1829 | p = xdr_encode_hyper(p, args->clientid); |
| 1830 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1831 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1832 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1833 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1834 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1835 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1836 | *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] | 1837 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1838 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1839 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1840 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1841 | |
| 1842 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1843 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1844 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1845 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1846 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1847 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1848 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1849 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1850 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1851 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1852 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1853 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1854 | |
| 1855 | /* authsys_parms rfc1831 */ |
Deepa Dinamani | 2f86e09 | 2016-10-01 16:46:26 -0700 | [diff] [blame] | 1856 | *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */ |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1857 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1858 | *p++ = cpu_to_be32(0); /* UID */ |
| 1859 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1860 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1861 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1862 | |
| 1863 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1864 | struct nfs4_session *session, |
| 1865 | struct compound_hdr *hdr) |
| 1866 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1867 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1868 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1869 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1870 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1871 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1872 | uint64_t clientid, |
| 1873 | struct compound_hdr *hdr) |
| 1874 | { |
| 1875 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1876 | encode_uint64(xdr, clientid); |
| 1877 | } |
| 1878 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1879 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1880 | struct nfs41_reclaim_complete_args *args, |
| 1881 | struct compound_hdr *hdr) |
| 1882 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1883 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1884 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1885 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1886 | #endif /* CONFIG_NFS_V4_1 */ |
| 1887 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1888 | static void encode_sequence(struct xdr_stream *xdr, |
| 1889 | const struct nfs4_sequence_args *args, |
| 1890 | struct compound_hdr *hdr) |
| 1891 | { |
| 1892 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1893 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1894 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1895 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1896 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1897 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1898 | tp = slot->table; |
| 1899 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1900 | if (!session) |
| 1901 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1902 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1903 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1904 | |
| 1905 | /* |
| 1906 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1907 | */ |
| 1908 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1909 | "max_slotid=%d cache_this=%d\n", |
| 1910 | __func__, |
| 1911 | ((u32 *)session->sess_id.data)[0], |
| 1912 | ((u32 *)session->sess_id.data)[1], |
| 1913 | ((u32 *)session->sess_id.data)[2], |
| 1914 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1915 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1916 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1917 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1918 | 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] | 1919 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1920 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1921 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1922 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1923 | #endif /* CONFIG_NFS_V4_1 */ |
| 1924 | } |
| 1925 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1926 | #ifdef CONFIG_NFS_V4_1 |
| 1927 | static void |
| 1928 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1929 | const struct nfs4_getdeviceinfo_args *args, |
| 1930 | struct compound_hdr *hdr) |
| 1931 | { |
| 1932 | __be32 *p; |
| 1933 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1934 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1935 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1936 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1937 | NFS4_DEVICEID4_SIZE); |
| 1938 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1939 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1940 | |
| 1941 | p = reserve_space(xdr, 4 + 4); |
| 1942 | *p++ = cpu_to_be32(1); /* bitmap length */ |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 1943 | *p++ = cpu_to_be32(args->notify_types); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1944 | } |
| 1945 | |
| 1946 | static void |
| 1947 | encode_layoutget(struct xdr_stream *xdr, |
| 1948 | const struct nfs4_layoutget_args *args, |
| 1949 | struct compound_hdr *hdr) |
| 1950 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1951 | __be32 *p; |
| 1952 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1953 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1954 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1955 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1956 | *p++ = cpu_to_be32(args->type); |
| 1957 | *p++ = cpu_to_be32(args->range.iomode); |
| 1958 | p = xdr_encode_hyper(p, args->range.offset); |
| 1959 | p = xdr_encode_hyper(p, args->range.length); |
| 1960 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1961 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1962 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1963 | |
| 1964 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1965 | __func__, |
| 1966 | args->type, |
| 1967 | args->range.iomode, |
| 1968 | (unsigned long)args->range.offset, |
| 1969 | (unsigned long)args->range.length, |
| 1970 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1971 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1972 | |
| 1973 | static int |
| 1974 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1975 | struct inode *inode, |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1976 | struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1977 | struct compound_hdr *hdr) |
| 1978 | { |
| 1979 | __be32 *p; |
| 1980 | |
| 1981 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1982 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1983 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1984 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1985 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1986 | /* Only whole file layouts */ |
| 1987 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1988 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1989 | *p = cpu_to_be32(0); /* reclaim */ |
| 1990 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 2e18d4d | 2016-06-26 18:54:58 -0400 | [diff] [blame] | 1991 | if (args->lastbytewritten != U64_MAX) { |
| 1992 | p = reserve_space(xdr, 20); |
| 1993 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1994 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1995 | } else { |
| 1996 | p = reserve_space(xdr, 12); |
| 1997 | *p++ = cpu_to_be32(0); /* newoffset = FALSE */ |
| 1998 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1999 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 2000 | *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] | 2001 | |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 2002 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2003 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 2004 | NFS_I(inode)->layout, xdr, args); |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 2005 | } else { |
| 2006 | encode_uint32(xdr, args->layoutupdate_len); |
| 2007 | if (args->layoutupdate_pages) { |
| 2008 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 2009 | args->layoutupdate_len); |
| 2010 | } |
| 2011 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2012 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2013 | return 0; |
| 2014 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2015 | |
| 2016 | static void |
| 2017 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2018 | const struct nfs4_layoutreturn_args *args, |
| 2019 | struct compound_hdr *hdr) |
| 2020 | { |
Trond Myklebust | 94e5c57 | 2016-09-15 18:49:52 -0400 | [diff] [blame] | 2021 | const struct pnfs_layoutdriver_type *lr_ops = NFS_SERVER(args->inode)->pnfs_curr_ld; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2022 | __be32 *p; |
| 2023 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2024 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 2025 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2026 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2027 | *p++ = cpu_to_be32(args->layout_type); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2028 | *p++ = cpu_to_be32(args->range.iomode); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2029 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2030 | p = reserve_space(xdr, 16); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2031 | p = xdr_encode_hyper(p, args->range.offset); |
| 2032 | p = xdr_encode_hyper(p, args->range.length); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2033 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2034 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2035 | spin_unlock(&args->inode->i_lock); |
Trond Myklebust | 94e5c57 | 2016-09-15 18:49:52 -0400 | [diff] [blame] | 2036 | if (lr_ops->encode_layoutreturn) |
| 2037 | lr_ops->encode_layoutreturn(xdr, args); |
| 2038 | else |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2039 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2040 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2041 | |
| 2042 | static int |
| 2043 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2044 | const struct nfs41_secinfo_no_name_args *args, |
| 2045 | struct compound_hdr *hdr) |
| 2046 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2047 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2048 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2049 | return 0; |
| 2050 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2051 | |
| 2052 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2053 | struct nfs41_test_stateid_args *args, |
| 2054 | struct compound_hdr *hdr) |
| 2055 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2056 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2057 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2058 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2059 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2060 | |
| 2061 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2062 | struct nfs41_free_stateid_args *args, |
| 2063 | struct compound_hdr *hdr) |
| 2064 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2065 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2066 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2067 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 2068 | #else |
| 2069 | static inline void |
| 2070 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2071 | const struct nfs4_layoutreturn_args *args, |
| 2072 | struct compound_hdr *hdr) |
| 2073 | { |
| 2074 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2075 | #endif /* CONFIG_NFS_V4_1 */ |
| 2076 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | /* |
| 2078 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2079 | */ |
| 2080 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2081 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2082 | { |
| 2083 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2084 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2085 | if (session) |
| 2086 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2087 | #endif /* CONFIG_NFS_V4_1 */ |
| 2088 | return 0; |
| 2089 | } |
| 2090 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | /* |
| 2092 | * Encode an ACCESS request |
| 2093 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2094 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2095 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2098 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2099 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2101 | encode_compound_hdr(xdr, req, &hdr); |
| 2102 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2103 | encode_putfh(xdr, args->fh, &hdr); |
| 2104 | encode_access(xdr, args->access, &hdr); |
| 2105 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2106 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | } |
| 2108 | |
| 2109 | /* |
| 2110 | * Encode LOOKUP request |
| 2111 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2112 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2113 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2116 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2119 | encode_compound_hdr(xdr, req, &hdr); |
| 2120 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2121 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2122 | encode_lookup(xdr, args->name, &hdr); |
| 2123 | encode_getfh(xdr, &hdr); |
| 2124 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2125 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | } |
| 2127 | |
| 2128 | /* |
| 2129 | * Encode LOOKUP_ROOT request |
| 2130 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2131 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2132 | struct xdr_stream *xdr, |
| 2133 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2135 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2136 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2139 | encode_compound_hdr(xdr, req, &hdr); |
| 2140 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2141 | encode_putrootfh(xdr, &hdr); |
| 2142 | encode_getfh(xdr, &hdr); |
| 2143 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2144 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | } |
| 2146 | |
| 2147 | /* |
| 2148 | * Encode REMOVE request |
| 2149 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2150 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2151 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2154 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2157 | encode_compound_hdr(xdr, req, &hdr); |
| 2158 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2159 | encode_putfh(xdr, args->fh, &hdr); |
| 2160 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2161 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | } |
| 2163 | |
| 2164 | /* |
| 2165 | * Encode RENAME request |
| 2166 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2167 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2168 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2171 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2174 | encode_compound_hdr(xdr, req, &hdr); |
| 2175 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2176 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2177 | encode_savefh(xdr, &hdr); |
| 2178 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2179 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2180 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | } |
| 2182 | |
| 2183 | /* |
| 2184 | * Encode LINK request |
| 2185 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2186 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2187 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2188 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2190 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2193 | encode_compound_hdr(xdr, req, &hdr); |
| 2194 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2195 | encode_putfh(xdr, args->fh, &hdr); |
| 2196 | encode_savefh(xdr, &hdr); |
| 2197 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2198 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2199 | encode_restorefh(xdr, &hdr); |
| 2200 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2201 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | /* |
| 2205 | * Encode CREATE request |
| 2206 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2207 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2208 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2210 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2211 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2214 | encode_compound_hdr(xdr, req, &hdr); |
| 2215 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2216 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2217 | encode_create(xdr, args, &hdr); |
| 2218 | encode_getfh(xdr, &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 SYMLINK request |
| 2225 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2226 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2227 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2229 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | } |
| 2231 | |
| 2232 | /* |
| 2233 | * Encode GETATTR request |
| 2234 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2235 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2236 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2239 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2242 | encode_compound_hdr(xdr, req, &hdr); |
| 2243 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2244 | encode_putfh(xdr, args->fh, &hdr); |
| 2245 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2246 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | /* |
| 2250 | * Encode a CLOSE request |
| 2251 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2252 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2253 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2255 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2256 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2257 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2259 | encode_compound_hdr(xdr, req, &hdr); |
| 2260 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2261 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 2262 | if (args->lr_args) |
| 2263 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2264 | encode_close(xdr, args, &hdr); |
Trond Myklebust | 3ecefc9 | 2016-10-27 18:25:04 -0400 | [diff] [blame] | 2265 | if (args->bitmask != NULL) |
| 2266 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2267 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | } |
| 2269 | |
| 2270 | /* |
| 2271 | * Encode an OPEN request |
| 2272 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2273 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2274 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2277 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2280 | encode_compound_hdr(xdr, req, &hdr); |
| 2281 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2282 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2283 | encode_open(xdr, args, &hdr); |
| 2284 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2285 | if (args->access) |
| 2286 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2287 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2288 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2289 | } |
| 2290 | |
| 2291 | /* |
| 2292 | * Encode an OPEN_CONFIRM request |
| 2293 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2294 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2295 | struct xdr_stream *xdr, |
| 2296 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2297 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2299 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2300 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2302 | encode_compound_hdr(xdr, req, &hdr); |
| 2303 | encode_putfh(xdr, args->fh, &hdr); |
| 2304 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2305 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | } |
| 2307 | |
| 2308 | /* |
| 2309 | * Encode an OPEN request with no attributes. |
| 2310 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2311 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2312 | struct xdr_stream *xdr, |
| 2313 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2314 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2316 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2319 | encode_compound_hdr(xdr, req, &hdr); |
| 2320 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2321 | encode_putfh(xdr, args->fh, &hdr); |
| 2322 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2323 | if (args->access) |
| 2324 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2325 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2326 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2327 | } |
| 2328 | |
| 2329 | /* |
| 2330 | * Encode an OPEN_DOWNGRADE request |
| 2331 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2332 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2333 | struct xdr_stream *xdr, |
| 2334 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2337 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2340 | encode_compound_hdr(xdr, req, &hdr); |
| 2341 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2342 | encode_putfh(xdr, args->fh, &hdr); |
| 2343 | encode_open_downgrade(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2344 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | /* |
| 2348 | * Encode a LOCK request |
| 2349 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2350 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2351 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2354 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2357 | encode_compound_hdr(xdr, req, &hdr); |
| 2358 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2359 | encode_putfh(xdr, args->fh, &hdr); |
| 2360 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2361 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | /* |
| 2365 | * Encode a LOCKT request |
| 2366 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2367 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2368 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2371 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2374 | encode_compound_hdr(xdr, req, &hdr); |
| 2375 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2376 | encode_putfh(xdr, args->fh, &hdr); |
| 2377 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2378 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2379 | } |
| 2380 | |
| 2381 | /* |
| 2382 | * Encode a LOCKU request |
| 2383 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2384 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2385 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2386 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2388 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2389 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2390 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2391 | encode_compound_hdr(xdr, req, &hdr); |
| 2392 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2393 | encode_putfh(xdr, args->fh, &hdr); |
| 2394 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2395 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | } |
| 2397 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2398 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2399 | struct xdr_stream *xdr, |
| 2400 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2401 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2402 | struct compound_hdr hdr = { |
| 2403 | .minorversion = 0, |
| 2404 | }; |
| 2405 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2406 | encode_compound_hdr(xdr, req, &hdr); |
| 2407 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2408 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2409 | } |
| 2410 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | /* |
| 2412 | * Encode a READLINK request |
| 2413 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2414 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2415 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2416 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2418 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2420 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2421 | encode_compound_hdr(xdr, req, &hdr); |
| 2422 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2423 | encode_putfh(xdr, args->fh, &hdr); |
| 2424 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2425 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2426 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2427 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2428 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
| 2431 | /* |
| 2432 | * Encode a READDIR request |
| 2433 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2434 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2435 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2438 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2441 | encode_compound_hdr(xdr, req, &hdr); |
| 2442 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2443 | encode_putfh(xdr, args->fh, &hdr); |
| 2444 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2445 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2446 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2447 | args->pgbase, args->count); |
| 2448 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2449 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2450 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2451 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | } |
| 2453 | |
| 2454 | /* |
| 2455 | * Encode a READ request |
| 2456 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2457 | 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] | 2458 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2459 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2460 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2461 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2462 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2464 | encode_compound_hdr(xdr, req, &hdr); |
| 2465 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2466 | encode_putfh(xdr, args->fh, &hdr); |
| 2467 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2468 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2469 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2471 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2472 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | } |
| 2474 | |
| 2475 | /* |
| 2476 | * Encode an SETATTR request |
| 2477 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2478 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2479 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2481 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2482 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2483 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2484 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2485 | encode_compound_hdr(xdr, req, &hdr); |
| 2486 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2487 | encode_putfh(xdr, args->fh, &hdr); |
| 2488 | encode_setattr(xdr, args, args->server, &hdr); |
| 2489 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2490 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2491 | } |
| 2492 | |
| 2493 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2494 | * Encode a GETACL request |
| 2495 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2496 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2497 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2498 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2499 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2500 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2501 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2502 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2503 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2504 | encode_compound_hdr(xdr, req, &hdr); |
| 2505 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2506 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2507 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2508 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2509 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2510 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 2511 | args->acl_pages, 0, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2512 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2513 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2514 | } |
| 2515 | |
| 2516 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | * Encode a WRITE request |
| 2518 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2519 | 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] | 2520 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2523 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2524 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2526 | encode_compound_hdr(xdr, req, &hdr); |
| 2527 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2528 | encode_putfh(xdr, args->fh, &hdr); |
| 2529 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2530 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2531 | if (args->bitmask) |
| 2532 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2533 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | } |
| 2535 | |
| 2536 | /* |
| 2537 | * a COMMIT request |
| 2538 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2539 | 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] | 2540 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2542 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2543 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2546 | encode_compound_hdr(xdr, req, &hdr); |
| 2547 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2548 | encode_putfh(xdr, args->fh, &hdr); |
| 2549 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2550 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | /* |
| 2554 | * FSINFO request |
| 2555 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2556 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2557 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2560 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2562 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2563 | encode_compound_hdr(xdr, req, &hdr); |
| 2564 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2565 | encode_putfh(xdr, args->fh, &hdr); |
| 2566 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2567 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | /* |
| 2571 | * a PATHCONF request |
| 2572 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2573 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2574 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2575 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2577 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2580 | encode_compound_hdr(xdr, req, &hdr); |
| 2581 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2582 | encode_putfh(xdr, args->fh, &hdr); |
| 2583 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2584 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2585 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | } |
| 2587 | |
| 2588 | /* |
| 2589 | * a STATFS request |
| 2590 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2591 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2592 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2594 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2595 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2597 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2598 | encode_compound_hdr(xdr, req, &hdr); |
| 2599 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2600 | encode_putfh(xdr, args->fh, &hdr); |
| 2601 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2602 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2603 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | /* |
| 2607 | * GETATTR_BITMAP request |
| 2608 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2609 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2610 | struct xdr_stream *xdr, |
| 2611 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | { |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2613 | const u32 *bitmask = args->bitmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2614 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2615 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2617 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2618 | encode_compound_hdr(xdr, req, &hdr); |
| 2619 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2620 | encode_putfh(xdr, args->fhandle, &hdr); |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2621 | encode_getattr_three(xdr, bitmask[0], bitmask[1], bitmask[2], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2622 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | } |
| 2624 | |
| 2625 | /* |
| 2626 | * a RENEW request |
| 2627 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2628 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2629 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2630 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2632 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | }; |
| 2634 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2635 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2636 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2637 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | /* |
| 2641 | * a SETCLIENTID request |
| 2642 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2643 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2644 | struct xdr_stream *xdr, |
| 2645 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2648 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2649 | }; |
| 2650 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2651 | encode_compound_hdr(xdr, req, &hdr); |
| 2652 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2653 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2654 | } |
| 2655 | |
| 2656 | /* |
| 2657 | * a SETCLIENTID_CONFIRM request |
| 2658 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2659 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2660 | struct xdr_stream *xdr, |
| 2661 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2664 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2667 | encode_compound_hdr(xdr, req, &hdr); |
| 2668 | encode_setclientid_confirm(xdr, arg, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2669 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | } |
| 2671 | |
| 2672 | /* |
| 2673 | * DELEGRETURN request |
| 2674 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2675 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2676 | struct xdr_stream *xdr, |
| 2677 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2678 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2679 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2680 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2682 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2683 | encode_compound_hdr(xdr, req, &hdr); |
| 2684 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2685 | encode_putfh(xdr, args->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2686 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2687 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2688 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2689 | } |
| 2690 | |
| 2691 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2692 | * Encode FS_LOCATIONS request |
| 2693 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2694 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2695 | struct xdr_stream *xdr, |
| 2696 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2697 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2698 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2699 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2700 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2701 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2702 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2703 | encode_compound_hdr(xdr, req, &hdr); |
| 2704 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2705 | if (args->migration) { |
| 2706 | encode_putfh(xdr, args->fh, &hdr); |
| 2707 | replen = hdr.replen; |
| 2708 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2709 | if (args->renew) |
| 2710 | encode_renew(xdr, args->clientid, &hdr); |
| 2711 | } else { |
| 2712 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2713 | encode_lookup(xdr, args->name, &hdr); |
| 2714 | replen = hdr.replen; |
| 2715 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2716 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2717 | |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2718 | /* Set up reply kvec to capture returned fs_locations array. */ |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2719 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2720 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2721 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2722 | } |
| 2723 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2724 | /* |
| 2725 | * Encode SECINFO request |
| 2726 | */ |
| 2727 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2728 | struct xdr_stream *xdr, |
| 2729 | struct nfs4_secinfo_arg *args) |
| 2730 | { |
| 2731 | struct compound_hdr hdr = { |
| 2732 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2733 | }; |
| 2734 | |
| 2735 | encode_compound_hdr(xdr, req, &hdr); |
| 2736 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2737 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2738 | encode_secinfo(xdr, args->name, &hdr); |
| 2739 | encode_nops(&hdr); |
| 2740 | } |
| 2741 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2742 | /* |
| 2743 | * Encode FSID_PRESENT request |
| 2744 | */ |
| 2745 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2746 | struct xdr_stream *xdr, |
| 2747 | struct nfs4_fsid_present_arg *args) |
| 2748 | { |
| 2749 | struct compound_hdr hdr = { |
| 2750 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2751 | }; |
| 2752 | |
| 2753 | encode_compound_hdr(xdr, req, &hdr); |
| 2754 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2755 | encode_putfh(xdr, args->fh, &hdr); |
| 2756 | encode_getfh(xdr, &hdr); |
| 2757 | if (args->renew) |
| 2758 | encode_renew(xdr, args->clientid, &hdr); |
| 2759 | encode_nops(&hdr); |
| 2760 | } |
| 2761 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2762 | #if defined(CONFIG_NFS_V4_1) |
| 2763 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2764 | * BIND_CONN_TO_SESSION request |
| 2765 | */ |
| 2766 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2767 | struct xdr_stream *xdr, |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2768 | struct nfs41_bind_conn_to_session_args *args) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2769 | { |
| 2770 | struct compound_hdr hdr = { |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2771 | .minorversion = args->client->cl_mvops->minor_version, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2772 | }; |
| 2773 | |
| 2774 | encode_compound_hdr(xdr, req, &hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2775 | encode_bind_conn_to_session(xdr, args, &hdr); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2776 | encode_nops(&hdr); |
| 2777 | } |
| 2778 | |
| 2779 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2780 | * EXCHANGE_ID request |
| 2781 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2782 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2783 | struct xdr_stream *xdr, |
| 2784 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2785 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2786 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2787 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2788 | }; |
| 2789 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2790 | encode_compound_hdr(xdr, req, &hdr); |
| 2791 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2792 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2793 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2794 | |
| 2795 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2796 | * a CREATE_SESSION request |
| 2797 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2798 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2799 | struct xdr_stream *xdr, |
| 2800 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2801 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2802 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2803 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2804 | }; |
| 2805 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2806 | encode_compound_hdr(xdr, req, &hdr); |
| 2807 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2808 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2809 | } |
| 2810 | |
| 2811 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2812 | * a DESTROY_SESSION request |
| 2813 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2814 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2815 | struct xdr_stream *xdr, |
| 2816 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2817 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2818 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2819 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2820 | }; |
| 2821 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2822 | encode_compound_hdr(xdr, req, &hdr); |
| 2823 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2824 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2825 | } |
| 2826 | |
| 2827 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2828 | * a DESTROY_CLIENTID request |
| 2829 | */ |
| 2830 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2831 | struct xdr_stream *xdr, |
| 2832 | struct nfs_client *clp) |
| 2833 | { |
| 2834 | struct compound_hdr hdr = { |
| 2835 | .minorversion = clp->cl_mvops->minor_version, |
| 2836 | }; |
| 2837 | |
| 2838 | encode_compound_hdr(xdr, req, &hdr); |
| 2839 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2840 | encode_nops(&hdr); |
| 2841 | } |
| 2842 | |
| 2843 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2844 | * a SEQUENCE request |
| 2845 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2846 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2847 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2848 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2849 | struct compound_hdr hdr = { |
| 2850 | .minorversion = nfs4_xdr_minorversion(args), |
| 2851 | }; |
| 2852 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2853 | encode_compound_hdr(xdr, req, &hdr); |
| 2854 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2855 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2856 | } |
| 2857 | |
| 2858 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2859 | * a GET_LEASE_TIME request |
| 2860 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2861 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2862 | struct xdr_stream *xdr, |
| 2863 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2864 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2865 | struct compound_hdr hdr = { |
| 2866 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2867 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2868 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2869 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2870 | encode_compound_hdr(xdr, req, &hdr); |
| 2871 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2872 | encode_putrootfh(xdr, &hdr); |
| 2873 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2874 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2875 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2876 | |
| 2877 | /* |
| 2878 | * a RECLAIM_COMPLETE request |
| 2879 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2880 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2881 | struct xdr_stream *xdr, |
| 2882 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2883 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2884 | struct compound_hdr hdr = { |
| 2885 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2886 | }; |
| 2887 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2888 | encode_compound_hdr(xdr, req, &hdr); |
| 2889 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2890 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2891 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2892 | } |
| 2893 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2894 | /* |
| 2895 | * Encode GETDEVICEINFO request |
| 2896 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2897 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2898 | struct xdr_stream *xdr, |
| 2899 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2900 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2901 | struct compound_hdr hdr = { |
| 2902 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2903 | }; |
| 2904 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2905 | encode_compound_hdr(xdr, req, &hdr); |
| 2906 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2907 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2908 | |
| 2909 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2910 | * so that notification bitmap is put in xdr_buf tail */ |
| 2911 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2912 | args->pdev->pages, args->pdev->pgbase, |
| 2913 | args->pdev->pglen); |
| 2914 | |
| 2915 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2916 | } |
| 2917 | |
| 2918 | /* |
| 2919 | * Encode LAYOUTGET request |
| 2920 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2921 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2922 | struct xdr_stream *xdr, |
| 2923 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2924 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2925 | struct compound_hdr hdr = { |
| 2926 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2927 | }; |
| 2928 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2929 | encode_compound_hdr(xdr, req, &hdr); |
| 2930 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2931 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2932 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2933 | |
| 2934 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2935 | args->layout.pages, 0, args->layout.pglen); |
| 2936 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2937 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2938 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2939 | |
| 2940 | /* |
| 2941 | * Encode LAYOUTCOMMIT request |
| 2942 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2943 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2944 | struct xdr_stream *xdr, |
| 2945 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2946 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2947 | struct nfs4_layoutcommit_data *data = |
| 2948 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2949 | struct compound_hdr hdr = { |
| 2950 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2951 | }; |
| 2952 | |
| 2953 | encode_compound_hdr(xdr, req, &hdr); |
| 2954 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2955 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2956 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2957 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2958 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2959 | } |
| 2960 | |
| 2961 | /* |
| 2962 | * Encode LAYOUTRETURN request |
| 2963 | */ |
| 2964 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2965 | struct xdr_stream *xdr, |
| 2966 | struct nfs4_layoutreturn_args *args) |
| 2967 | { |
| 2968 | struct compound_hdr hdr = { |
| 2969 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2970 | }; |
| 2971 | |
| 2972 | encode_compound_hdr(xdr, req, &hdr); |
| 2973 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2974 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2975 | encode_layoutreturn(xdr, args, &hdr); |
| 2976 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2977 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2978 | |
| 2979 | /* |
| 2980 | * Encode SECINFO_NO_NAME request |
| 2981 | */ |
| 2982 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2983 | struct xdr_stream *xdr, |
| 2984 | struct nfs41_secinfo_no_name_args *args) |
| 2985 | { |
| 2986 | struct compound_hdr hdr = { |
| 2987 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2988 | }; |
| 2989 | |
| 2990 | encode_compound_hdr(xdr, req, &hdr); |
| 2991 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2992 | encode_putrootfh(xdr, &hdr); |
| 2993 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2994 | encode_nops(&hdr); |
| 2995 | return 0; |
| 2996 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2997 | |
| 2998 | /* |
| 2999 | * Encode TEST_STATEID request |
| 3000 | */ |
| 3001 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 3002 | struct xdr_stream *xdr, |
| 3003 | struct nfs41_test_stateid_args *args) |
| 3004 | { |
| 3005 | struct compound_hdr hdr = { |
| 3006 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3007 | }; |
| 3008 | |
| 3009 | encode_compound_hdr(xdr, req, &hdr); |
| 3010 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3011 | encode_test_stateid(xdr, args, &hdr); |
| 3012 | encode_nops(&hdr); |
| 3013 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3014 | |
| 3015 | /* |
| 3016 | * Encode FREE_STATEID request |
| 3017 | */ |
| 3018 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 3019 | struct xdr_stream *xdr, |
| 3020 | struct nfs41_free_stateid_args *args) |
| 3021 | { |
| 3022 | struct compound_hdr hdr = { |
| 3023 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3024 | }; |
| 3025 | |
| 3026 | encode_compound_hdr(xdr, req, &hdr); |
| 3027 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3028 | encode_free_stateid(xdr, args, &hdr); |
| 3029 | encode_nops(&hdr); |
| 3030 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3031 | #endif /* CONFIG_NFS_V4_1 */ |
| 3032 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3033 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3034 | { |
| 3035 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3036 | "Remaining buffer length is %tu words.\n", |
| 3037 | func, xdr->end - xdr->p); |
| 3038 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3039 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3040 | 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] | 3041 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3042 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3043 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3044 | p = xdr_inline_decode(xdr, 4); |
| 3045 | if (unlikely(!p)) |
| 3046 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3047 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3048 | p = xdr_inline_decode(xdr, *len); |
| 3049 | if (unlikely(!p)) |
| 3050 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | *string = (char *)p; |
| 3052 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3053 | out_overflow: |
| 3054 | print_overflow_msg(__func__, xdr); |
| 3055 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | } |
| 3057 | |
| 3058 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 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 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3062 | p = xdr_inline_decode(xdr, 8); |
| 3063 | if (unlikely(!p)) |
| 3064 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3065 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3066 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3067 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3068 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3069 | if (unlikely(!p)) |
| 3070 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3071 | hdr->tag = (char *)p; |
| 3072 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3073 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3074 | if (unlikely(hdr->nops < 1)) |
| 3075 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3077 | out_overflow: |
| 3078 | print_overflow_msg(__func__, xdr); |
| 3079 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3080 | } |
| 3081 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3082 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3083 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3084 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3085 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3086 | uint32_t opnum; |
| 3087 | int32_t nfserr; |
| 3088 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3089 | p = xdr_inline_decode(xdr, 8); |
| 3090 | if (unlikely(!p)) |
| 3091 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3092 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3093 | if (unlikely(opnum != expected)) |
| 3094 | goto out_bad_operation; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3095 | nfserr = be32_to_cpup(p); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3096 | if (nfserr == NFS_OK) |
| 3097 | *nfs_retval = 0; |
| 3098 | else |
| 3099 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
| 3100 | return true; |
| 3101 | out_bad_operation: |
| 3102 | dprintk("nfs: Server returned operation" |
| 3103 | " %d but we issued a request for %d\n", |
| 3104 | opnum, expected); |
| 3105 | *nfs_retval = -EREMOTEIO; |
| 3106 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3107 | out_overflow: |
| 3108 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3109 | *nfs_retval = -EIO; |
| 3110 | return false; |
| 3111 | } |
| 3112 | |
| 3113 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3114 | { |
| 3115 | int retval; |
| 3116 | |
| 3117 | __decode_op_hdr(xdr, expected, &retval); |
| 3118 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3119 | } |
| 3120 | |
| 3121 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3122 | 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] | 3123 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3124 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3125 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3126 | char *str; |
| 3127 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3128 | p = xdr_inline_decode(xdr, 12); |
| 3129 | if (likely(p)) |
| 3130 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3131 | print_overflow_msg(__func__, xdr); |
| 3132 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3133 | } |
| 3134 | |
| 3135 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3136 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3137 | uint32_t bmlen; |
| 3138 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3139 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3140 | p = xdr_inline_decode(xdr, 4); |
| 3141 | if (unlikely(!p)) |
| 3142 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3143 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3144 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3145 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3146 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3147 | if (unlikely(!p)) |
| 3148 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3149 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3150 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3151 | if (bmlen > 1) { |
| 3152 | bitmap[1] = be32_to_cpup(p++); |
| 3153 | if (bmlen > 2) |
| 3154 | bitmap[2] = be32_to_cpup(p); |
| 3155 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3156 | } |
| 3157 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3158 | out_overflow: |
| 3159 | print_overflow_msg(__func__, xdr); |
| 3160 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | } |
| 3162 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3163 | 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] | 3164 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3165 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3167 | p = xdr_inline_decode(xdr, 4); |
| 3168 | if (unlikely(!p)) |
| 3169 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3170 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3171 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3173 | out_overflow: |
| 3174 | print_overflow_msg(__func__, xdr); |
| 3175 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | } |
| 3177 | |
| 3178 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3179 | { |
| 3180 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3181 | int ret; |
| 3182 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3183 | if (unlikely(ret < 0)) |
| 3184 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3186 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3187 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3188 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3189 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3190 | return 0; |
| 3191 | } |
| 3192 | |
| 3193 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3194 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3195 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3196 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | |
| 3198 | *type = 0; |
| 3199 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3200 | return -EIO; |
| 3201 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3202 | p = xdr_inline_decode(xdr, 4); |
| 3203 | if (unlikely(!p)) |
| 3204 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3205 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3207 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3208 | return -EIO; |
| 3209 | } |
| 3210 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3211 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3212 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3213 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3214 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3215 | out_overflow: |
| 3216 | print_overflow_msg(__func__, xdr); |
| 3217 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | } |
| 3219 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3220 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3221 | uint32_t *bitmap, uint32_t *type) |
| 3222 | { |
| 3223 | __be32 *p; |
| 3224 | |
| 3225 | *type = 0; |
| 3226 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3227 | return -EIO; |
| 3228 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3229 | p = xdr_inline_decode(xdr, 4); |
| 3230 | if (unlikely(!p)) |
| 3231 | goto out_overflow; |
| 3232 | *type = be32_to_cpup(p); |
| 3233 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3234 | } |
| 3235 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3236 | return 0; |
| 3237 | out_overflow: |
| 3238 | print_overflow_msg(__func__, xdr); |
| 3239 | return -EIO; |
| 3240 | } |
| 3241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3243 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3244 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3245 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3246 | |
| 3247 | *change = 0; |
| 3248 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3249 | return -EIO; |
| 3250 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3251 | p = xdr_inline_decode(xdr, 8); |
| 3252 | if (unlikely(!p)) |
| 3253 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3254 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3256 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3257 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3258 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3260 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3261 | out_overflow: |
| 3262 | print_overflow_msg(__func__, xdr); |
| 3263 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3264 | } |
| 3265 | |
| 3266 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3267 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3268 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3269 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | |
| 3271 | *size = 0; |
| 3272 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3273 | return -EIO; |
| 3274 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3275 | p = xdr_inline_decode(xdr, 8); |
| 3276 | if (unlikely(!p)) |
| 3277 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3278 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3279 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3280 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3281 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3282 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3283 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3284 | out_overflow: |
| 3285 | print_overflow_msg(__func__, xdr); |
| 3286 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3287 | } |
| 3288 | |
| 3289 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3290 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3291 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | |
| 3293 | *res = 0; |
| 3294 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3295 | return -EIO; |
| 3296 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3297 | p = xdr_inline_decode(xdr, 4); |
| 3298 | if (unlikely(!p)) |
| 3299 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3300 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3302 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3303 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3305 | out_overflow: |
| 3306 | print_overflow_msg(__func__, xdr); |
| 3307 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | } |
| 3309 | |
| 3310 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3311 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3312 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3313 | |
| 3314 | *res = 0; |
| 3315 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3316 | return -EIO; |
| 3317 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3318 | p = xdr_inline_decode(xdr, 4); |
| 3319 | if (unlikely(!p)) |
| 3320 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3321 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3322 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3323 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3324 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3326 | out_overflow: |
| 3327 | print_overflow_msg(__func__, xdr); |
| 3328 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3329 | } |
| 3330 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3331 | 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] | 3332 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3333 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3334 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | |
| 3336 | fsid->major = 0; |
| 3337 | fsid->minor = 0; |
| 3338 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3339 | return -EIO; |
| 3340 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3341 | p = xdr_inline_decode(xdr, 16); |
| 3342 | if (unlikely(!p)) |
| 3343 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3344 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3345 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3347 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3349 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | (unsigned long long)fsid->major, |
| 3351 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3352 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3353 | out_overflow: |
| 3354 | print_overflow_msg(__func__, xdr); |
| 3355 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3356 | } |
| 3357 | |
| 3358 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3359 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3360 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | |
| 3362 | *res = 60; |
| 3363 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3364 | return -EIO; |
| 3365 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3366 | p = xdr_inline_decode(xdr, 4); |
| 3367 | if (unlikely(!p)) |
| 3368 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3369 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3370 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3371 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3372 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3373 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3374 | out_overflow: |
| 3375 | print_overflow_msg(__func__, xdr); |
| 3376 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3377 | } |
| 3378 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3379 | 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] | 3380 | { |
| 3381 | __be32 *p; |
| 3382 | |
| 3383 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3384 | return -EIO; |
| 3385 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3386 | p = xdr_inline_decode(xdr, 4); |
| 3387 | if (unlikely(!p)) |
| 3388 | goto out_overflow; |
| 3389 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3390 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3391 | } |
| 3392 | return 0; |
| 3393 | out_overflow: |
| 3394 | print_overflow_msg(__func__, xdr); |
| 3395 | return -EIO; |
| 3396 | } |
| 3397 | |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 3398 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
| 3399 | uint32_t *bitmap, uint32_t *bitmask) |
| 3400 | { |
| 3401 | if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) { |
| 3402 | int ret; |
| 3403 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3404 | if (unlikely(ret < 0)) |
| 3405 | return ret; |
| 3406 | bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT; |
| 3407 | } else |
| 3408 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3409 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3410 | bitmask[0], bitmask[1], bitmask[2]); |
| 3411 | return 0; |
| 3412 | } |
| 3413 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3414 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3415 | { |
| 3416 | __be32 *p; |
| 3417 | int len; |
| 3418 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3419 | if (fh != NULL) |
| 3420 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3421 | |
| 3422 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3423 | return -EIO; |
| 3424 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3425 | p = xdr_inline_decode(xdr, 4); |
| 3426 | if (unlikely(!p)) |
| 3427 | goto out_overflow; |
| 3428 | len = be32_to_cpup(p); |
| 3429 | if (len > NFS4_FHSIZE) |
| 3430 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3431 | p = xdr_inline_decode(xdr, len); |
| 3432 | if (unlikely(!p)) |
| 3433 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3434 | if (fh != NULL) { |
| 3435 | memcpy(fh->data, p, len); |
| 3436 | fh->size = len; |
| 3437 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3438 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3439 | } |
| 3440 | return 0; |
| 3441 | out_overflow: |
| 3442 | print_overflow_msg(__func__, xdr); |
| 3443 | return -EIO; |
| 3444 | } |
| 3445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3446 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3447 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3448 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3450 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3452 | return -EIO; |
| 3453 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3454 | p = xdr_inline_decode(xdr, 4); |
| 3455 | if (unlikely(!p)) |
| 3456 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3457 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3458 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3459 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3460 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3461 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3462 | out_overflow: |
| 3463 | print_overflow_msg(__func__, xdr); |
| 3464 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | } |
| 3466 | |
| 3467 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3468 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3469 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3470 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3471 | |
| 3472 | *fileid = 0; |
| 3473 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3474 | return -EIO; |
| 3475 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3476 | p = xdr_inline_decode(xdr, 8); |
| 3477 | if (unlikely(!p)) |
| 3478 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3479 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3480 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3481 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3482 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3483 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3484 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3485 | out_overflow: |
| 3486 | print_overflow_msg(__func__, xdr); |
| 3487 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3488 | } |
| 3489 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3490 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3491 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3492 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3493 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3494 | |
| 3495 | *fileid = 0; |
| 3496 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3497 | return -EIO; |
| 3498 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3499 | p = xdr_inline_decode(xdr, 8); |
| 3500 | if (unlikely(!p)) |
| 3501 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3502 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3503 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3504 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3505 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3506 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3507 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3508 | out_overflow: |
| 3509 | print_overflow_msg(__func__, xdr); |
| 3510 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3511 | } |
| 3512 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3514 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3515 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3516 | int status = 0; |
| 3517 | |
| 3518 | *res = 0; |
| 3519 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3520 | return -EIO; |
| 3521 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3522 | p = xdr_inline_decode(xdr, 8); |
| 3523 | if (unlikely(!p)) |
| 3524 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3525 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3526 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3527 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3528 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3529 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3530 | out_overflow: |
| 3531 | print_overflow_msg(__func__, xdr); |
| 3532 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3533 | } |
| 3534 | |
| 3535 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3536 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3537 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3538 | int status = 0; |
| 3539 | |
| 3540 | *res = 0; |
| 3541 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3542 | return -EIO; |
| 3543 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3544 | p = xdr_inline_decode(xdr, 8); |
| 3545 | if (unlikely(!p)) |
| 3546 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3547 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3548 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3549 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3550 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3551 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3552 | out_overflow: |
| 3553 | print_overflow_msg(__func__, xdr); |
| 3554 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3558 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3559 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3560 | int status = 0; |
| 3561 | |
| 3562 | *res = 0; |
| 3563 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3564 | return -EIO; |
| 3565 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3566 | p = xdr_inline_decode(xdr, 8); |
| 3567 | if (unlikely(!p)) |
| 3568 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3569 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3570 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3571 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3572 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3573 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3574 | out_overflow: |
| 3575 | print_overflow_msg(__func__, xdr); |
| 3576 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3577 | } |
| 3578 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3579 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3580 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3581 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3582 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3583 | int status = 0; |
| 3584 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3585 | p = xdr_inline_decode(xdr, 4); |
| 3586 | if (unlikely(!p)) |
| 3587 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3588 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3589 | if (n == 0) |
| 3590 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3591 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3592 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3593 | dprintk("cannot parse %d components in path\n", n); |
| 3594 | goto out_eio; |
| 3595 | } |
| 3596 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3597 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3598 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3599 | if (unlikely(status != 0)) |
| 3600 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3601 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3602 | pr_cont("%s%.*s ", |
| 3603 | (path->ncomponents != n ? "/ " : ""), |
| 3604 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3605 | } |
| 3606 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3607 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3608 | root_path: |
| 3609 | /* a root pathname is sent as a zero component4 */ |
| 3610 | path->ncomponents = 1; |
| 3611 | path->components[0].len=0; |
| 3612 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3613 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3614 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3615 | out_eio: |
| 3616 | dprintk(" status %d", status); |
| 3617 | status = -EIO; |
| 3618 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3619 | out_overflow: |
| 3620 | print_overflow_msg(__func__, xdr); |
| 3621 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | 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] | 3625 | { |
| 3626 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3627 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3628 | int status = -EIO; |
| 3629 | |
| 3630 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3631 | goto out; |
| 3632 | status = 0; |
| 3633 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3634 | goto out; |
Kinglong Mee | f54423a | 2015-11-18 10:39:26 +0800 | [diff] [blame] | 3635 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3636 | status = -EIO; |
| 3637 | /* Ignore borken servers that return unrequested attrs */ |
| 3638 | if (unlikely(res == NULL)) |
| 3639 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3640 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3641 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3642 | if (unlikely(status != 0)) |
| 3643 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3644 | p = xdr_inline_decode(xdr, 4); |
| 3645 | if (unlikely(!p)) |
| 3646 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3647 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3648 | if (n <= 0) |
| 3649 | goto out_eio; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3650 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3651 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3652 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3653 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3654 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3655 | break; |
| 3656 | loc = &res->locations[res->nlocations]; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3657 | p = xdr_inline_decode(xdr, 4); |
| 3658 | if (unlikely(!p)) |
| 3659 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3660 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3661 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3662 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3663 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3664 | struct nfs4_string *server; |
| 3665 | |
| 3666 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3667 | unsigned int i; |
| 3668 | dprintk("%s: using first %u of %u servers " |
| 3669 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3670 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3671 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3672 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3673 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3674 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3675 | char *data; |
| 3676 | status = decode_opaque_inline(xdr, &len, &data); |
| 3677 | if (unlikely(status != 0)) |
| 3678 | goto out_eio; |
| 3679 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3680 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3681 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3682 | server = &loc->servers[loc->nservers]; |
| 3683 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3684 | if (unlikely(status != 0)) |
| 3685 | goto out_eio; |
| 3686 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3687 | } |
| 3688 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3689 | if (unlikely(status != 0)) |
| 3690 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3691 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3692 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3693 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3694 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3695 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3696 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3697 | out_overflow: |
| 3698 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3699 | out_eio: |
| 3700 | status = -EIO; |
| 3701 | goto out; |
| 3702 | } |
| 3703 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3704 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3705 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3706 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | int status = 0; |
| 3708 | |
| 3709 | *res = 0; |
| 3710 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3711 | return -EIO; |
| 3712 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3713 | p = xdr_inline_decode(xdr, 8); |
| 3714 | if (unlikely(!p)) |
| 3715 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3716 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3717 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3718 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3719 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3720 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3721 | out_overflow: |
| 3722 | print_overflow_msg(__func__, xdr); |
| 3723 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | } |
| 3725 | |
| 3726 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3727 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3728 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | int status = 0; |
| 3730 | |
| 3731 | *maxlink = 1; |
| 3732 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3733 | return -EIO; |
| 3734 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3735 | p = xdr_inline_decode(xdr, 4); |
| 3736 | if (unlikely(!p)) |
| 3737 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3738 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3739 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3740 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3741 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3742 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3743 | out_overflow: |
| 3744 | print_overflow_msg(__func__, xdr); |
| 3745 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3749 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3750 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | int status = 0; |
| 3752 | |
| 3753 | *maxname = 1024; |
| 3754 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3755 | return -EIO; |
| 3756 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3757 | p = xdr_inline_decode(xdr, 4); |
| 3758 | if (unlikely(!p)) |
| 3759 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3760 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3761 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3762 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3763 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3765 | out_overflow: |
| 3766 | print_overflow_msg(__func__, xdr); |
| 3767 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3768 | } |
| 3769 | |
| 3770 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3771 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3772 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3773 | int status = 0; |
| 3774 | |
| 3775 | *res = 1024; |
| 3776 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3777 | return -EIO; |
| 3778 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3779 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3780 | p = xdr_inline_decode(xdr, 8); |
| 3781 | if (unlikely(!p)) |
| 3782 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3783 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | if (maxread > 0x7FFFFFFF) |
| 3785 | maxread = 0x7FFFFFFF; |
| 3786 | *res = (uint32_t)maxread; |
| 3787 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3788 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3789 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3791 | out_overflow: |
| 3792 | print_overflow_msg(__func__, xdr); |
| 3793 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3794 | } |
| 3795 | |
| 3796 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3797 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3798 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3799 | int status = 0; |
| 3800 | |
| 3801 | *res = 1024; |
| 3802 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3803 | return -EIO; |
| 3804 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3805 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3806 | p = xdr_inline_decode(xdr, 8); |
| 3807 | if (unlikely(!p)) |
| 3808 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3809 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | if (maxwrite > 0x7FFFFFFF) |
| 3811 | maxwrite = 0x7FFFFFFF; |
| 3812 | *res = (uint32_t)maxwrite; |
| 3813 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3814 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3815 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3817 | out_overflow: |
| 3818 | print_overflow_msg(__func__, xdr); |
| 3819 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | } |
| 3821 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3822 | 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] | 3823 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3824 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3825 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3826 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | |
| 3828 | *mode = 0; |
| 3829 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3830 | return -EIO; |
| 3831 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3832 | p = xdr_inline_decode(xdr, 4); |
| 3833 | if (unlikely(!p)) |
| 3834 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3835 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3836 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3837 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3838 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3839 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3840 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3841 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3842 | out_overflow: |
| 3843 | print_overflow_msg(__func__, xdr); |
| 3844 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3845 | } |
| 3846 | |
| 3847 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3848 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3849 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3850 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3851 | |
| 3852 | *nlink = 1; |
| 3853 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3854 | return -EIO; |
| 3855 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3856 | p = xdr_inline_decode(xdr, 4); |
| 3857 | if (unlikely(!p)) |
| 3858 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3859 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3860 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3861 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3862 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3863 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3864 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3865 | out_overflow: |
| 3866 | print_overflow_msg(__func__, xdr); |
| 3867 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | } |
| 3869 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3870 | 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] | 3871 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3872 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3873 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3874 | uint32_t len; |
| 3875 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3876 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3877 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3878 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3879 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3880 | return -EIO; |
| 3881 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3882 | p = xdr_inline_decode(xdr, 4); |
| 3883 | if (unlikely(!p)) |
| 3884 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3885 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3886 | p = xdr_inline_decode(xdr, len); |
| 3887 | if (unlikely(!p)) |
| 3888 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3889 | if (owner_name != NULL) { |
| 3890 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3891 | if (owner_name->data != NULL) { |
| 3892 | owner_name->len = len; |
| 3893 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3894 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3895 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3896 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3897 | ret = NFS_ATTR_FATTR_OWNER; |
| 3898 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3899 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3900 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3902 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3903 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3904 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3905 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3906 | 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] | 3907 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3908 | out_overflow: |
| 3909 | print_overflow_msg(__func__, xdr); |
| 3910 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3911 | } |
| 3912 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3913 | 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] | 3914 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3915 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3916 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3917 | uint32_t len; |
| 3918 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3919 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3920 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3921 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3922 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3923 | return -EIO; |
| 3924 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3925 | p = xdr_inline_decode(xdr, 4); |
| 3926 | if (unlikely(!p)) |
| 3927 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3928 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3929 | p = xdr_inline_decode(xdr, len); |
| 3930 | if (unlikely(!p)) |
| 3931 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3932 | if (group_name != NULL) { |
| 3933 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3934 | if (group_name->data != NULL) { |
| 3935 | group_name->len = len; |
| 3936 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3937 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3938 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3939 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3940 | ret = NFS_ATTR_FATTR_GROUP; |
| 3941 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3942 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3943 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3944 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3945 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3946 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3947 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3948 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3949 | 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] | 3950 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3951 | out_overflow: |
| 3952 | print_overflow_msg(__func__, xdr); |
| 3953 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | } |
| 3955 | |
| 3956 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3957 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3958 | uint32_t major = 0, minor = 0; |
| 3959 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3960 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3961 | |
| 3962 | *rdev = MKDEV(0,0); |
| 3963 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3964 | return -EIO; |
| 3965 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3966 | dev_t tmp; |
| 3967 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3968 | p = xdr_inline_decode(xdr, 8); |
| 3969 | if (unlikely(!p)) |
| 3970 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3971 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3972 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | tmp = MKDEV(major, minor); |
| 3974 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3975 | *rdev = tmp; |
| 3976 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3977 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3978 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3979 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3980 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3981 | out_overflow: |
| 3982 | print_overflow_msg(__func__, xdr); |
| 3983 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3984 | } |
| 3985 | |
| 3986 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3987 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3988 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3989 | int status = 0; |
| 3990 | |
| 3991 | *res = 0; |
| 3992 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3993 | return -EIO; |
| 3994 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3995 | p = xdr_inline_decode(xdr, 8); |
| 3996 | if (unlikely(!p)) |
| 3997 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3998 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3999 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4000 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4001 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4002 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4003 | out_overflow: |
| 4004 | print_overflow_msg(__func__, xdr); |
| 4005 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | } |
| 4007 | |
| 4008 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4009 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4010 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4011 | int status = 0; |
| 4012 | |
| 4013 | *res = 0; |
| 4014 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 4015 | return -EIO; |
| 4016 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4017 | p = xdr_inline_decode(xdr, 8); |
| 4018 | if (unlikely(!p)) |
| 4019 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4020 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4021 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4022 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4023 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4024 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4025 | out_overflow: |
| 4026 | print_overflow_msg(__func__, xdr); |
| 4027 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4031 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4032 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4033 | int status = 0; |
| 4034 | |
| 4035 | *res = 0; |
| 4036 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4037 | return -EIO; |
| 4038 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4039 | p = xdr_inline_decode(xdr, 8); |
| 4040 | if (unlikely(!p)) |
| 4041 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4042 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4043 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4044 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4045 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4046 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4047 | out_overflow: |
| 4048 | print_overflow_msg(__func__, xdr); |
| 4049 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4053 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4054 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4055 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | |
| 4057 | *used = 0; |
| 4058 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4059 | return -EIO; |
| 4060 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4061 | p = xdr_inline_decode(xdr, 8); |
| 4062 | if (unlikely(!p)) |
| 4063 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4064 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4065 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4066 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4067 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4068 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4069 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4070 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4071 | out_overflow: |
| 4072 | print_overflow_msg(__func__, xdr); |
| 4073 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4077 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4078 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | uint64_t sec; |
| 4080 | uint32_t nsec; |
| 4081 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4082 | p = xdr_inline_decode(xdr, 12); |
| 4083 | if (unlikely(!p)) |
| 4084 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4085 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4086 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4087 | time->tv_sec = (time_t)sec; |
| 4088 | time->tv_nsec = (long)nsec; |
| 4089 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4090 | out_overflow: |
| 4091 | print_overflow_msg(__func__, xdr); |
| 4092 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4093 | } |
| 4094 | |
| 4095 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4096 | { |
| 4097 | int status = 0; |
| 4098 | |
| 4099 | time->tv_sec = 0; |
| 4100 | time->tv_nsec = 0; |
| 4101 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4102 | return -EIO; |
| 4103 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4104 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4105 | if (status == 0) |
| 4106 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4107 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4108 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4109 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | return status; |
| 4111 | } |
| 4112 | |
| 4113 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4114 | { |
| 4115 | int status = 0; |
| 4116 | |
| 4117 | time->tv_sec = 0; |
| 4118 | time->tv_nsec = 0; |
| 4119 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4120 | return -EIO; |
| 4121 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4122 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4123 | if (status == 0) |
| 4124 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4125 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4126 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4127 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4128 | return status; |
| 4129 | } |
| 4130 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4131 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4132 | struct timespec *time) |
| 4133 | { |
| 4134 | int status = 0; |
| 4135 | |
| 4136 | time->tv_sec = 0; |
| 4137 | time->tv_nsec = 0; |
| 4138 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4139 | return -EIO; |
| 4140 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4141 | status = decode_attr_time(xdr, time); |
| 4142 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4143 | } |
| 4144 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4145 | (long)time->tv_nsec); |
| 4146 | return status; |
| 4147 | } |
| 4148 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4149 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4150 | struct nfs4_label *label) |
| 4151 | { |
| 4152 | uint32_t pi = 0; |
| 4153 | uint32_t lfs = 0; |
| 4154 | __u32 len; |
| 4155 | __be32 *p; |
| 4156 | int status = 0; |
| 4157 | |
| 4158 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4159 | return -EIO; |
| 4160 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4161 | p = xdr_inline_decode(xdr, 4); |
| 4162 | if (unlikely(!p)) |
| 4163 | goto out_overflow; |
| 4164 | lfs = be32_to_cpup(p++); |
| 4165 | p = xdr_inline_decode(xdr, 4); |
| 4166 | if (unlikely(!p)) |
| 4167 | goto out_overflow; |
| 4168 | pi = be32_to_cpup(p++); |
| 4169 | p = xdr_inline_decode(xdr, 4); |
| 4170 | if (unlikely(!p)) |
| 4171 | goto out_overflow; |
| 4172 | len = be32_to_cpup(p++); |
| 4173 | p = xdr_inline_decode(xdr, len); |
| 4174 | if (unlikely(!p)) |
| 4175 | goto out_overflow; |
| 4176 | if (len < NFS4_MAXLABELLEN) { |
| 4177 | if (label) { |
| 4178 | memcpy(label->label, p, len); |
| 4179 | label->len = len; |
| 4180 | label->pi = pi; |
| 4181 | label->lfs = lfs; |
| 4182 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4183 | } |
| 4184 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4185 | } else |
| 4186 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4187 | __func__, len); |
| 4188 | } |
| 4189 | if (label && label->label) |
| 4190 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4191 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4192 | return status; |
| 4193 | |
| 4194 | out_overflow: |
| 4195 | print_overflow_msg(__func__, xdr); |
| 4196 | return -EIO; |
| 4197 | } |
| 4198 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4199 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4200 | { |
| 4201 | int status = 0; |
| 4202 | |
| 4203 | time->tv_sec = 0; |
| 4204 | time->tv_nsec = 0; |
| 4205 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4206 | return -EIO; |
| 4207 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4208 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4209 | if (status == 0) |
| 4210 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4212 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4213 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | return status; |
| 4215 | } |
| 4216 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4217 | 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] | 4218 | { |
| 4219 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4220 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4221 | |
| 4222 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4223 | dprintk("%s: server returned incorrect attribute length: " |
| 4224 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4225 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4226 | attrwords << 2, |
| 4227 | (attrwords < nwords) ? '<' : '>', |
| 4228 | nwords << 2); |
| 4229 | return -EIO; |
| 4230 | } |
| 4231 | return 0; |
| 4232 | } |
| 4233 | |
| 4234 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4235 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4236 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4237 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4238 | p = xdr_inline_decode(xdr, 20); |
| 4239 | if (unlikely(!p)) |
| 4240 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4241 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4242 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4243 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4244 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4245 | out_overflow: |
| 4246 | print_overflow_msg(__func__, xdr); |
| 4247 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4248 | } |
| 4249 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4250 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4251 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4252 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | uint32_t supp, acc; |
| 4254 | int status; |
| 4255 | |
| 4256 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4257 | if (status) |
| 4258 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4259 | p = xdr_inline_decode(xdr, 8); |
| 4260 | if (unlikely(!p)) |
| 4261 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4262 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4263 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4264 | *supported = supp; |
| 4265 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4266 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4267 | out_overflow: |
| 4268 | print_overflow_msg(__func__, xdr); |
| 4269 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4270 | } |
| 4271 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4272 | 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] | 4273 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4274 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4275 | |
| 4276 | p = xdr_inline_decode(xdr, len); |
| 4277 | if (likely(p)) { |
| 4278 | memcpy(buf, p, len); |
| 4279 | return 0; |
| 4280 | } |
| 4281 | print_overflow_msg(__func__, xdr); |
| 4282 | return -EIO; |
| 4283 | } |
| 4284 | |
| 4285 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4286 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4287 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4288 | } |
| 4289 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4290 | static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4291 | { |
| 4292 | stateid->type = NFS4_OPEN_STATEID_TYPE; |
| 4293 | return decode_stateid(xdr, stateid); |
| 4294 | } |
| 4295 | |
| 4296 | static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4297 | { |
| 4298 | stateid->type = NFS4_LOCK_STATEID_TYPE; |
| 4299 | return decode_stateid(xdr, stateid); |
| 4300 | } |
| 4301 | |
| 4302 | static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4303 | { |
| 4304 | stateid->type = NFS4_DELEGATION_STATEID_TYPE; |
| 4305 | return decode_stateid(xdr, stateid); |
| 4306 | } |
| 4307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4308 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4309 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4310 | int status; |
| 4311 | |
| 4312 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4313 | if (status != -EIO) |
| 4314 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4315 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4316 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4317 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4318 | } |
| 4319 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4320 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4321 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4322 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4323 | } |
| 4324 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4325 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4326 | { |
| 4327 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4328 | } |
| 4329 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4330 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4331 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4332 | int status; |
| 4333 | |
| 4334 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4335 | if (!status) |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4336 | status = decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4337 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4338 | } |
| 4339 | |
| 4340 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4341 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4342 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4343 | uint32_t bmlen; |
| 4344 | int status; |
| 4345 | |
| 4346 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4347 | if (status) |
| 4348 | return status; |
| 4349 | if ((status = decode_change_info(xdr, cinfo))) |
| 4350 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4351 | p = xdr_inline_decode(xdr, 4); |
| 4352 | if (unlikely(!p)) |
| 4353 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4354 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4355 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4356 | if (likely(p)) |
| 4357 | return 0; |
| 4358 | out_overflow: |
| 4359 | print_overflow_msg(__func__, xdr); |
| 4360 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4361 | } |
| 4362 | |
| 4363 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4364 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4365 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4366 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4367 | int status; |
| 4368 | |
| 4369 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4370 | goto xdr_error; |
| 4371 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4372 | goto xdr_error; |
| 4373 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4374 | goto xdr_error; |
| 4375 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4376 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4377 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4378 | &res->fh_expire_type)) != 0) |
| 4379 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4380 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4381 | goto xdr_error; |
| 4382 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4383 | goto xdr_error; |
| 4384 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4385 | goto xdr_error; |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 4386 | if ((status = decode_attr_exclcreat_supported(xdr, bitmap, |
| 4387 | res->exclcreat_bitmask)) != 0) |
| 4388 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4389 | status = verify_attr_len(xdr, savep, attrlen); |
| 4390 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4391 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4392 | return status; |
| 4393 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4395 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4396 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4397 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4398 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4399 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4401 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4402 | goto xdr_error; |
| 4403 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4404 | goto xdr_error; |
| 4405 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4406 | goto xdr_error; |
| 4407 | |
| 4408 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4409 | goto xdr_error; |
| 4410 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4411 | goto xdr_error; |
| 4412 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4413 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4414 | |
| 4415 | status = -EIO; |
| 4416 | if (unlikely(bitmap[0])) |
| 4417 | goto xdr_error; |
| 4418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4419 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4420 | goto xdr_error; |
| 4421 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4422 | goto xdr_error; |
| 4423 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4424 | goto xdr_error; |
| 4425 | |
| 4426 | status = verify_attr_len(xdr, savep, attrlen); |
| 4427 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4428 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4429 | return status; |
| 4430 | } |
| 4431 | |
| 4432 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4433 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4434 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4435 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4438 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4439 | goto xdr_error; |
| 4440 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4441 | goto xdr_error; |
| 4442 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4443 | goto xdr_error; |
| 4444 | |
| 4445 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4446 | goto xdr_error; |
| 4447 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4448 | goto xdr_error; |
| 4449 | |
| 4450 | status = verify_attr_len(xdr, savep, attrlen); |
| 4451 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4452 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4453 | return status; |
| 4454 | } |
| 4455 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4456 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4457 | uint32_t *bitmap, |
| 4458 | uint64_t *res, |
| 4459 | uint32_t hint_bit) |
| 4460 | { |
| 4461 | __be32 *p; |
| 4462 | |
| 4463 | *res = 0; |
| 4464 | if (likely(bitmap[0] & hint_bit)) { |
| 4465 | p = xdr_inline_decode(xdr, 8); |
| 4466 | if (unlikely(!p)) |
| 4467 | goto out_overflow; |
| 4468 | xdr_decode_hyper(p, res); |
| 4469 | } |
| 4470 | return 0; |
| 4471 | out_overflow: |
| 4472 | print_overflow_msg(__func__, xdr); |
| 4473 | return -EIO; |
| 4474 | } |
| 4475 | |
| 4476 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4477 | struct nfs4_threshold *res) |
| 4478 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4479 | __be32 *p; |
| 4480 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4481 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4482 | int status; |
| 4483 | |
| 4484 | /* layout type */ |
| 4485 | p = xdr_inline_decode(xdr, 4); |
| 4486 | if (unlikely(!p)) { |
| 4487 | print_overflow_msg(__func__, xdr); |
| 4488 | return -EIO; |
| 4489 | } |
| 4490 | res->l_type = be32_to_cpup(p); |
| 4491 | |
| 4492 | /* thi_hintset bitmap */ |
| 4493 | status = decode_attr_bitmap(xdr, bitmap); |
| 4494 | if (status < 0) |
| 4495 | goto xdr_error; |
| 4496 | |
| 4497 | /* thi_hintlist length */ |
| 4498 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4499 | if (status < 0) |
| 4500 | goto xdr_error; |
| 4501 | /* thi_hintlist */ |
| 4502 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4503 | if (status < 0) |
| 4504 | goto xdr_error; |
| 4505 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4506 | if (status < 0) |
| 4507 | goto xdr_error; |
| 4508 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4509 | THRESHOLD_RD_IO); |
| 4510 | if (status < 0) |
| 4511 | goto xdr_error; |
| 4512 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4513 | THRESHOLD_WR_IO); |
| 4514 | if (status < 0) |
| 4515 | goto xdr_error; |
| 4516 | |
| 4517 | status = verify_attr_len(xdr, savep, attrlen); |
| 4518 | res->bm = bitmap[0]; |
| 4519 | |
| 4520 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4521 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4522 | res->wr_io_sz); |
| 4523 | xdr_error: |
| 4524 | dprintk("%s ret=%d!\n", __func__, status); |
| 4525 | return status; |
| 4526 | } |
| 4527 | |
| 4528 | /* |
| 4529 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4530 | */ |
| 4531 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4532 | uint32_t *bitmap, |
| 4533 | struct nfs4_threshold *res) |
| 4534 | { |
| 4535 | __be32 *p; |
| 4536 | int status = 0; |
| 4537 | uint32_t num; |
| 4538 | |
| 4539 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4540 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4541 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4542 | /* Did the server return an unrequested attribute? */ |
| 4543 | if (unlikely(res == NULL)) |
| 4544 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4545 | p = xdr_inline_decode(xdr, 4); |
| 4546 | if (unlikely(!p)) |
| 4547 | goto out_overflow; |
| 4548 | num = be32_to_cpup(p); |
| 4549 | if (num == 0) |
| 4550 | return 0; |
| 4551 | if (num > 1) |
| 4552 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4553 | "drivers per filesystem not supported\n", |
| 4554 | __func__); |
| 4555 | |
| 4556 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4557 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4558 | } |
| 4559 | return status; |
| 4560 | out_overflow: |
| 4561 | print_overflow_msg(__func__, xdr); |
| 4562 | return -EIO; |
| 4563 | } |
| 4564 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4565 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4566 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4567 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4568 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4569 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4570 | int status; |
| 4571 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4572 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4573 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4574 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4575 | status = decode_attr_type(xdr, bitmap, &type); |
| 4576 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4577 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4578 | fattr->mode = 0; |
| 4579 | if (status != 0) { |
| 4580 | fattr->mode |= nfs_type2fmt[type]; |
| 4581 | fattr->valid |= status; |
| 4582 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4583 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4584 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4585 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4586 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4587 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4588 | |
| 4589 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4590 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4591 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4592 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4593 | |
| 4594 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4595 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4596 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4597 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4598 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4599 | err = 0; |
| 4600 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4601 | if (status < 0) |
| 4602 | goto xdr_error; |
| 4603 | |
| 4604 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4605 | if (status < 0) |
| 4606 | goto xdr_error; |
| 4607 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4608 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4609 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4610 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4611 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4612 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4613 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4614 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4615 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4616 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4617 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4618 | status = -EIO; |
| 4619 | if (unlikely(bitmap[0])) |
| 4620 | goto xdr_error; |
| 4621 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4622 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4623 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4624 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4625 | if (status != 0) { |
| 4626 | fattr->mode |= fmode; |
| 4627 | fattr->valid |= status; |
| 4628 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4629 | |
| 4630 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4631 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4633 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4634 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4635 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4636 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4637 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4638 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4639 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4640 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4641 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4642 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4643 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4644 | |
| 4645 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4646 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4647 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4648 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4649 | |
| 4650 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4651 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4652 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4653 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4654 | |
| 4655 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4656 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4657 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4658 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4659 | |
| 4660 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4661 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4662 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4663 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4664 | |
| 4665 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4666 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4667 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4668 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4669 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4670 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4671 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4672 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4673 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4674 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4675 | status = -EIO; |
| 4676 | if (unlikely(bitmap[1])) |
| 4677 | goto xdr_error; |
| 4678 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4679 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4680 | if (status < 0) |
| 4681 | goto xdr_error; |
| 4682 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4683 | if (label) { |
| 4684 | status = decode_attr_security_label(xdr, bitmap, label); |
| 4685 | if (status < 0) |
| 4686 | goto xdr_error; |
| 4687 | fattr->valid |= status; |
| 4688 | } |
| 4689 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4690 | xdr_error: |
| 4691 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4692 | return status; |
| 4693 | } |
| 4694 | |
| 4695 | 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] | 4696 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4697 | struct nfs4_label *label, const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4698 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4699 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4700 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4701 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4702 | int status; |
| 4703 | |
| 4704 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4705 | if (status < 0) |
| 4706 | goto xdr_error; |
| 4707 | |
| 4708 | status = decode_attr_bitmap(xdr, bitmap); |
| 4709 | if (status < 0) |
| 4710 | goto xdr_error; |
| 4711 | |
| 4712 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4713 | if (status < 0) |
| 4714 | goto xdr_error; |
| 4715 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4716 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
| 4717 | label, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4718 | if (status < 0) |
| 4719 | goto xdr_error; |
| 4720 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4721 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4722 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4723 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4724 | return status; |
| 4725 | } |
| 4726 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4727 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 4728 | struct nfs4_label *label, const struct nfs_server *server) |
| 4729 | { |
| 4730 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); |
| 4731 | } |
| 4732 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4733 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4734 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4735 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4736 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4737 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4738 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4739 | /* |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4740 | * Decode potentially multiple layout types. |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4741 | */ |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4742 | static int decode_pnfs_layout_types(struct xdr_stream *xdr, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4743 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4744 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4745 | __be32 *p; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4746 | uint32_t i; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4747 | |
| 4748 | p = xdr_inline_decode(xdr, 4); |
| 4749 | if (unlikely(!p)) |
| 4750 | goto out_overflow; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4751 | fsinfo->nlayouttypes = be32_to_cpup(p); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4752 | |
| 4753 | /* pNFS is not supported by the underlying file system */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4754 | if (fsinfo->nlayouttypes == 0) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4755 | return 0; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4756 | |
| 4757 | /* Decode and set first layout type, move xdr->p past unused types */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4758 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4759 | if (unlikely(!p)) |
| 4760 | goto out_overflow; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4761 | |
| 4762 | /* If we get too many, then just cap it at the max */ |
| 4763 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
| 4764 | printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n", |
| 4765 | __func__, fsinfo->nlayouttypes); |
| 4766 | fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES; |
| 4767 | } |
| 4768 | |
| 4769 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
| 4770 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4771 | return 0; |
| 4772 | out_overflow: |
| 4773 | print_overflow_msg(__func__, xdr); |
| 4774 | return -EIO; |
| 4775 | } |
| 4776 | |
| 4777 | /* |
| 4778 | * The type of file system exported. |
| 4779 | * Note we must ensure that layouttype is set in any non-error case. |
| 4780 | */ |
| 4781 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4782 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4783 | { |
| 4784 | int status = 0; |
| 4785 | |
| 4786 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4787 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4788 | return -EIO; |
| 4789 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4790 | status = decode_pnfs_layout_types(xdr, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4791 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4792 | } |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4793 | return status; |
| 4794 | } |
| 4795 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4796 | /* |
| 4797 | * The prefered block size for layout directed io |
| 4798 | */ |
| 4799 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4800 | uint32_t *res) |
| 4801 | { |
| 4802 | __be32 *p; |
| 4803 | |
| 4804 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4805 | *res = 0; |
| 4806 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4807 | p = xdr_inline_decode(xdr, 4); |
| 4808 | if (unlikely(!p)) { |
| 4809 | print_overflow_msg(__func__, xdr); |
| 4810 | return -EIO; |
| 4811 | } |
| 4812 | *res = be32_to_cpup(p); |
| 4813 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4814 | } |
| 4815 | return 0; |
| 4816 | } |
| 4817 | |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4818 | /* |
| 4819 | * The granularity of a CLONE operation. |
| 4820 | */ |
| 4821 | static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4822 | uint32_t *res) |
| 4823 | { |
| 4824 | __be32 *p; |
| 4825 | |
| 4826 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4827 | *res = 0; |
| 4828 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
| 4829 | p = xdr_inline_decode(xdr, 4); |
| 4830 | if (unlikely(!p)) { |
| 4831 | print_overflow_msg(__func__, xdr); |
| 4832 | return -EIO; |
| 4833 | } |
| 4834 | *res = be32_to_cpup(p); |
| 4835 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
| 4836 | } |
| 4837 | return 0; |
| 4838 | } |
| 4839 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4840 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4841 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4842 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4843 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4844 | int status; |
| 4845 | |
| 4846 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4847 | goto xdr_error; |
| 4848 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4849 | goto xdr_error; |
| 4850 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4851 | goto xdr_error; |
| 4852 | |
| 4853 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4854 | |
| 4855 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4856 | goto xdr_error; |
| 4857 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4858 | goto xdr_error; |
| 4859 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4860 | goto xdr_error; |
| 4861 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4862 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4863 | goto xdr_error; |
| 4864 | fsinfo->wtpref = fsinfo->wtmax; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4865 | |
| 4866 | status = -EIO; |
| 4867 | if (unlikely(bitmap[0])) |
| 4868 | goto xdr_error; |
| 4869 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4870 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4871 | if (status != 0) |
| 4872 | goto xdr_error; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4873 | status = decode_attr_pnfstype(xdr, bitmap, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4874 | if (status != 0) |
| 4875 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4876 | |
| 4877 | status = -EIO; |
| 4878 | if (unlikely(bitmap[1])) |
| 4879 | goto xdr_error; |
| 4880 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4881 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4882 | if (status) |
| 4883 | goto xdr_error; |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4884 | status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize); |
| 4885 | if (status) |
| 4886 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4887 | |
| 4888 | status = verify_attr_len(xdr, savep, attrlen); |
| 4889 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4890 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4891 | return status; |
| 4892 | } |
| 4893 | |
| 4894 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4895 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4896 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4897 | uint32_t len; |
| 4898 | int status; |
| 4899 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4900 | /* Zero handle first to allow comparisons */ |
| 4901 | memset(fh, 0, sizeof(*fh)); |
| 4902 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4903 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4904 | if (status) |
| 4905 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4906 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4907 | p = xdr_inline_decode(xdr, 4); |
| 4908 | if (unlikely(!p)) |
| 4909 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4910 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4911 | if (len > NFS4_FHSIZE) |
| 4912 | return -EIO; |
| 4913 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4914 | p = xdr_inline_decode(xdr, len); |
| 4915 | if (unlikely(!p)) |
| 4916 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4917 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4918 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4919 | out_overflow: |
| 4920 | print_overflow_msg(__func__, xdr); |
| 4921 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4922 | } |
| 4923 | |
| 4924 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4925 | { |
| 4926 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4927 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4928 | status = decode_op_hdr(xdr, OP_LINK); |
| 4929 | if (status) |
| 4930 | return status; |
| 4931 | return decode_change_info(xdr, cinfo); |
| 4932 | } |
| 4933 | |
| 4934 | /* |
| 4935 | * We create the owner, so we know a proper owner.id length is 4. |
| 4936 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4937 | 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] | 4938 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4939 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4940 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4941 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4942 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4943 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4944 | if (unlikely(!p)) |
| 4945 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4946 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4947 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4948 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4949 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4950 | fl->fl_start = (loff_t)offset; |
| 4951 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4952 | if (length == ~(uint64_t)0) |
| 4953 | fl->fl_end = OFFSET_MAX; |
| 4954 | fl->fl_type = F_WRLCK; |
| 4955 | if (type & 1) |
| 4956 | fl->fl_type = F_RDLCK; |
| 4957 | fl->fl_pid = 0; |
| 4958 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4959 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4960 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4961 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4962 | if (likely(p)) |
| 4963 | return -NFS4ERR_DENIED; |
| 4964 | out_overflow: |
| 4965 | print_overflow_msg(__func__, xdr); |
| 4966 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4967 | } |
| 4968 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4969 | 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] | 4970 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4971 | int status; |
| 4972 | |
| 4973 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4974 | if (status == -EIO) |
| 4975 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4976 | if (status == 0) { |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4977 | status = decode_lock_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4978 | if (unlikely(status)) |
| 4979 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4980 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4981 | status = decode_lock_denied(xdr, NULL); |
| 4982 | if (res->open_seqid != NULL) |
| 4983 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4984 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4985 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4986 | return status; |
| 4987 | } |
| 4988 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4989 | 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] | 4990 | { |
| 4991 | int status; |
| 4992 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4993 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4994 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4995 | return status; |
| 4996 | } |
| 4997 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4998 | 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] | 4999 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5000 | int status; |
| 5001 | |
| 5002 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5003 | if (status != -EIO) |
| 5004 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5005 | if (status == 0) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5006 | status = decode_lock_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5007 | return status; |
| 5008 | } |
| 5009 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 5010 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 5011 | { |
| 5012 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 5013 | } |
| 5014 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5015 | static int decode_lookup(struct xdr_stream *xdr) |
| 5016 | { |
| 5017 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 5018 | } |
| 5019 | |
| 5020 | /* This is too sick! */ |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5021 | static int decode_space_limit(struct xdr_stream *xdr, |
| 5022 | unsigned long *pagemod_limit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5023 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5024 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5025 | uint32_t limit_type, nblocks, blocksize; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5026 | u64 maxsize = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5027 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5028 | p = xdr_inline_decode(xdr, 12); |
| 5029 | if (unlikely(!p)) |
| 5030 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5031 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5032 | switch (limit_type) { |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5033 | case NFS4_LIMIT_SIZE: |
| 5034 | xdr_decode_hyper(p, &maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5035 | break; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5036 | case NFS4_LIMIT_BLOCKS: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5037 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5038 | blocksize = be32_to_cpup(p); |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5039 | maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5040 | } |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 5041 | maxsize >>= PAGE_SHIFT; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5042 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5043 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5044 | out_overflow: |
| 5045 | print_overflow_msg(__func__, xdr); |
| 5046 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5047 | } |
| 5048 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5049 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| 5050 | uint32_t delegation_type, |
| 5051 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5052 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5053 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5054 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5055 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5056 | status = decode_delegation_stateid(xdr, &res->delegation); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5057 | if (unlikely(status)) |
| 5058 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5059 | p = xdr_inline_decode(xdr, 4); |
| 5060 | if (unlikely(!p)) |
| 5061 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5062 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5063 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5064 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5065 | case NFS4_OPEN_DELEGATE_READ: |
| 5066 | res->delegation_type = FMODE_READ; |
| 5067 | break; |
| 5068 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5069 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5070 | if (decode_space_limit(xdr, &res->pagemod_limit) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5071 | return -EIO; |
| 5072 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 5073 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5074 | out_overflow: |
| 5075 | print_overflow_msg(__func__, xdr); |
| 5076 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5077 | } |
| 5078 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5079 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5080 | { |
| 5081 | __be32 *p; |
| 5082 | uint32_t why_no_delegation; |
| 5083 | |
| 5084 | p = xdr_inline_decode(xdr, 4); |
| 5085 | if (unlikely(!p)) |
| 5086 | goto out_overflow; |
| 5087 | why_no_delegation = be32_to_cpup(p); |
| 5088 | switch (why_no_delegation) { |
| 5089 | case WND4_CONTENTION: |
| 5090 | case WND4_RESOURCE: |
| 5091 | xdr_inline_decode(xdr, 4); |
| 5092 | /* Ignore for now */ |
| 5093 | } |
| 5094 | return 0; |
| 5095 | out_overflow: |
| 5096 | print_overflow_msg(__func__, xdr); |
| 5097 | return -EIO; |
| 5098 | } |
| 5099 | |
| 5100 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5101 | { |
| 5102 | __be32 *p; |
| 5103 | uint32_t delegation_type; |
| 5104 | |
| 5105 | p = xdr_inline_decode(xdr, 4); |
| 5106 | if (unlikely(!p)) |
| 5107 | goto out_overflow; |
| 5108 | delegation_type = be32_to_cpup(p); |
| 5109 | res->delegation_type = 0; |
| 5110 | switch (delegation_type) { |
| 5111 | case NFS4_OPEN_DELEGATE_NONE: |
| 5112 | return 0; |
| 5113 | case NFS4_OPEN_DELEGATE_READ: |
| 5114 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5115 | return decode_rw_delegation(xdr, delegation_type, res); |
| 5116 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
| 5117 | return decode_no_delegation(xdr, res); |
| 5118 | } |
| 5119 | return -EIO; |
| 5120 | out_overflow: |
| 5121 | print_overflow_msg(__func__, xdr); |
| 5122 | return -EIO; |
| 5123 | } |
| 5124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5125 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5126 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5127 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5128 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5129 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5130 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5131 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 5132 | return status; |
| 5133 | nfs_increment_open_seqid(status, res->seqid); |
| 5134 | if (status) |
| 5135 | return status; |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5136 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5137 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5138 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5139 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5140 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5141 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5142 | p = xdr_inline_decode(xdr, 8); |
| 5143 | if (unlikely(!p)) |
| 5144 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5145 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5146 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5147 | if (bmlen > 10) |
| 5148 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5149 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5150 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5151 | if (unlikely(!p)) |
| 5152 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5153 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5154 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5155 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5156 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5157 | res->attrset[i] = 0; |
| 5158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5159 | return decode_delegation(xdr, res); |
| 5160 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5161 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5162 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5163 | out_overflow: |
| 5164 | print_overflow_msg(__func__, xdr); |
| 5165 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5166 | } |
| 5167 | |
| 5168 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5169 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5170 | int status; |
| 5171 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5172 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5173 | if (status != -EIO) |
| 5174 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5175 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5176 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5177 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5178 | } |
| 5179 | |
| 5180 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5181 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5182 | int status; |
| 5183 | |
| 5184 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5185 | if (status != -EIO) |
| 5186 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5187 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5188 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5189 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5190 | } |
| 5191 | |
| 5192 | static int decode_putfh(struct xdr_stream *xdr) |
| 5193 | { |
| 5194 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5195 | } |
| 5196 | |
| 5197 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5198 | { |
| 5199 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5200 | } |
| 5201 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5202 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5203 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5204 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5205 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5206 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | int status; |
| 5208 | |
| 5209 | status = decode_op_hdr(xdr, OP_READ); |
| 5210 | if (status) |
| 5211 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5212 | p = xdr_inline_decode(xdr, 8); |
| 5213 | if (unlikely(!p)) |
| 5214 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5215 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5216 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5217 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5218 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5219 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5220 | "count %u > recvd %u\n", count, recvd); |
| 5221 | count = recvd; |
| 5222 | eof = 0; |
| 5223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5224 | res->eof = eof; |
| 5225 | res->count = count; |
| 5226 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5227 | out_overflow: |
| 5228 | print_overflow_msg(__func__, xdr); |
| 5229 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | } |
| 5231 | |
| 5232 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5233 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5234 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5235 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5236 | |
| 5237 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5238 | if (!status) |
| 5239 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5240 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5241 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5242 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5243 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5244 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5245 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5246 | } |
| 5247 | |
| 5248 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5249 | { |
| 5250 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5251 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5252 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5253 | int status; |
| 5254 | |
| 5255 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5256 | if (status) |
| 5257 | return status; |
| 5258 | |
| 5259 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5260 | p = xdr_inline_decode(xdr, 4); |
| 5261 | if (unlikely(!p)) |
| 5262 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5263 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5264 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5265 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5266 | return -ENAMETOOLONG; |
| 5267 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5268 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5269 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5270 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | "count %u > recvd %u\n", len, recvd); |
| 5272 | return -EIO; |
| 5273 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5274 | /* |
| 5275 | * The XDR encode routine has set things up so that |
| 5276 | * the link text will be copied directly into the |
| 5277 | * buffer. We just have to do overflow-checking, |
| 5278 | * and and null-terminate the text (the VFS expects |
| 5279 | * null-termination). |
| 5280 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5281 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5282 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5283 | out_overflow: |
| 5284 | print_overflow_msg(__func__, xdr); |
| 5285 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5286 | } |
| 5287 | |
| 5288 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5289 | { |
| 5290 | int status; |
| 5291 | |
| 5292 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5293 | if (status) |
| 5294 | goto out; |
| 5295 | status = decode_change_info(xdr, cinfo); |
| 5296 | out: |
| 5297 | return status; |
| 5298 | } |
| 5299 | |
| 5300 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5301 | struct nfs4_change_info *new_cinfo) |
| 5302 | { |
| 5303 | int status; |
| 5304 | |
| 5305 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5306 | if (status) |
| 5307 | goto out; |
| 5308 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5309 | goto out; |
| 5310 | status = decode_change_info(xdr, new_cinfo); |
| 5311 | out: |
| 5312 | return status; |
| 5313 | } |
| 5314 | |
| 5315 | static int decode_renew(struct xdr_stream *xdr) |
| 5316 | { |
| 5317 | return decode_op_hdr(xdr, OP_RENEW); |
| 5318 | } |
| 5319 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5320 | static int |
| 5321 | decode_restorefh(struct xdr_stream *xdr) |
| 5322 | { |
| 5323 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5324 | } |
| 5325 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5326 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5327 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5328 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5329 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5330 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5331 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5332 | int status; |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5333 | unsigned int pg_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5334 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5335 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5336 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5337 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5338 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5339 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5340 | |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5341 | /* Calculate the offset of the page data */ |
| 5342 | pg_offset = xdr->buf->head[0].iov_len; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5343 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5344 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5345 | goto out; |
| 5346 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5347 | goto out; |
| 5348 | |
| 5349 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5350 | return -EIO; |
| 5351 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5352 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5353 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5354 | * are stored with the acl data to handle the problem of |
| 5355 | * variable length bitmaps.*/ |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5356 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5357 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5358 | |
| 5359 | /* Check for receive buffer overflow */ |
| 5360 | if (res->acl_len > (xdr->nwords << 2) || |
| 5361 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5362 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5363 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5364 | attrlen, xdr->nwords << 2); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5365 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5366 | } else |
| 5367 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5368 | |
| 5369 | out: |
| 5370 | return status; |
| 5371 | } |
| 5372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5373 | static int |
| 5374 | decode_savefh(struct xdr_stream *xdr) |
| 5375 | { |
| 5376 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5377 | } |
| 5378 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5379 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5380 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5381 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5382 | uint32_t bmlen; |
| 5383 | int status; |
| 5384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5385 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5386 | if (status) |
| 5387 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5388 | p = xdr_inline_decode(xdr, 4); |
| 5389 | if (unlikely(!p)) |
| 5390 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5391 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5392 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5393 | if (likely(p)) |
| 5394 | return 0; |
| 5395 | out_overflow: |
| 5396 | print_overflow_msg(__func__, xdr); |
| 5397 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5398 | } |
| 5399 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5400 | 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] | 5401 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5402 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5403 | uint32_t opnum; |
| 5404 | int32_t nfserr; |
| 5405 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5406 | p = xdr_inline_decode(xdr, 8); |
| 5407 | if (unlikely(!p)) |
| 5408 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5409 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5410 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5411 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5412 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5413 | return -EIO; |
| 5414 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5415 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5416 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5417 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5418 | if (unlikely(!p)) |
| 5419 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5420 | p = xdr_decode_hyper(p, &res->clientid); |
| 5421 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5422 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5423 | uint32_t len; |
| 5424 | |
| 5425 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5426 | p = xdr_inline_decode(xdr, 4); |
| 5427 | if (unlikely(!p)) |
| 5428 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5429 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5430 | p = xdr_inline_decode(xdr, len); |
| 5431 | if (unlikely(!p)) |
| 5432 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5433 | |
| 5434 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5435 | p = xdr_inline_decode(xdr, 4); |
| 5436 | if (unlikely(!p)) |
| 5437 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5438 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5439 | p = xdr_inline_decode(xdr, len); |
| 5440 | if (unlikely(!p)) |
| 5441 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5442 | return -NFSERR_CLID_INUSE; |
| 5443 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5444 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5445 | |
| 5446 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5447 | out_overflow: |
| 5448 | print_overflow_msg(__func__, xdr); |
| 5449 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5450 | } |
| 5451 | |
| 5452 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5453 | { |
| 5454 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5455 | } |
| 5456 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5457 | 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] | 5458 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5459 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5460 | int status; |
| 5461 | |
| 5462 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5463 | if (status) |
| 5464 | return status; |
| 5465 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5466 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5467 | if (unlikely(!p)) |
| 5468 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5469 | res->count = be32_to_cpup(p++); |
| 5470 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5471 | return decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5472 | out_overflow: |
| 5473 | print_overflow_msg(__func__, xdr); |
| 5474 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5475 | } |
| 5476 | |
| 5477 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5478 | { |
| 5479 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5480 | } |
| 5481 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5482 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5483 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5484 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5485 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5486 | __be32 *p; |
| 5487 | |
| 5488 | p = xdr_inline_decode(xdr, 4); |
| 5489 | if (unlikely(!p)) |
| 5490 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5491 | oid_len = be32_to_cpup(p); |
| 5492 | if (oid_len > GSS_OID_MAX_LEN) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5493 | goto out_err; |
| 5494 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5495 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5496 | if (unlikely(!p)) |
| 5497 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5498 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5499 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5500 | |
| 5501 | p = xdr_inline_decode(xdr, 8); |
| 5502 | if (unlikely(!p)) |
| 5503 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5504 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5505 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5506 | |
| 5507 | return 0; |
| 5508 | |
| 5509 | out_overflow: |
| 5510 | print_overflow_msg(__func__, xdr); |
| 5511 | return -EIO; |
| 5512 | out_err: |
| 5513 | return -EINVAL; |
| 5514 | } |
| 5515 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5516 | 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] | 5517 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5518 | struct nfs4_secinfo4 *sec_flavor; |
| 5519 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5520 | int status; |
| 5521 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5522 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5523 | p = xdr_inline_decode(xdr, 4); |
| 5524 | if (unlikely(!p)) |
| 5525 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5526 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5527 | res->flavors->num_flavors = 0; |
| 5528 | num_flavors = be32_to_cpup(p); |
| 5529 | |
| 5530 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5531 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5532 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5533 | break; |
| 5534 | |
| 5535 | p = xdr_inline_decode(xdr, 4); |
| 5536 | if (unlikely(!p)) |
| 5537 | goto out_overflow; |
| 5538 | sec_flavor->flavor = be32_to_cpup(p); |
| 5539 | |
| 5540 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5541 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5542 | if (status) |
| 5543 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5544 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5545 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5546 | } |
| 5547 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5548 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5549 | out: |
| 5550 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5551 | out_overflow: |
| 5552 | print_overflow_msg(__func__, xdr); |
| 5553 | return -EIO; |
| 5554 | } |
| 5555 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5556 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5557 | { |
| 5558 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5559 | if (status) |
| 5560 | return status; |
| 5561 | return decode_secinfo_common(xdr, res); |
| 5562 | } |
| 5563 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5564 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5565 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5566 | { |
| 5567 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5568 | if (status) |
| 5569 | return status; |
| 5570 | return decode_secinfo_common(xdr, res); |
| 5571 | } |
| 5572 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5573 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5574 | { |
| 5575 | __be32 *p; |
| 5576 | uint32_t bitmap_words; |
| 5577 | unsigned int i; |
| 5578 | |
| 5579 | p = xdr_inline_decode(xdr, 4); |
| 5580 | bitmap_words = be32_to_cpup(p++); |
| 5581 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) |
| 5582 | return -EIO; |
| 5583 | p = xdr_inline_decode(xdr, 4 * bitmap_words); |
| 5584 | for (i = 0; i < bitmap_words; i++) |
| 5585 | op_map->u.words[i] = be32_to_cpup(p++); |
| 5586 | |
| 5587 | return 0; |
| 5588 | } |
| 5589 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5590 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5591 | struct nfs41_exchange_id_res *res) |
| 5592 | { |
| 5593 | __be32 *p; |
| 5594 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5595 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5596 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5597 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5598 | |
| 5599 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5600 | if (status) |
| 5601 | return status; |
| 5602 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5603 | p = xdr_inline_decode(xdr, 8); |
| 5604 | if (unlikely(!p)) |
| 5605 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5606 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5607 | p = xdr_inline_decode(xdr, 12); |
| 5608 | if (unlikely(!p)) |
| 5609 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5610 | res->seqid = be32_to_cpup(p++); |
| 5611 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5612 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5613 | res->state_protect.how = be32_to_cpup(p); |
| 5614 | switch (res->state_protect.how) { |
| 5615 | case SP4_NONE: |
| 5616 | break; |
| 5617 | case SP4_MACH_CRED: |
| 5618 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5619 | if (status) |
| 5620 | return status; |
| 5621 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5622 | if (status) |
| 5623 | return status; |
| 5624 | break; |
| 5625 | default: |
| 5626 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5627 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5628 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5629 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5630 | /* server_owner4.so_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5631 | p = xdr_inline_decode(xdr, 8); |
| 5632 | if (unlikely(!p)) |
| 5633 | goto out_overflow; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5634 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5635 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5636 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5637 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5638 | if (unlikely(status)) |
| 5639 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5640 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5641 | return -EIO; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5642 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5643 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5644 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5645 | /* server_scope4 */ |
| 5646 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5647 | if (unlikely(status)) |
| 5648 | return status; |
| 5649 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5650 | return -EIO; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5651 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5652 | res->server_scope->server_scope_sz = dummy; |
| 5653 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5654 | /* Implementation Id */ |
| 5655 | p = xdr_inline_decode(xdr, 4); |
| 5656 | if (unlikely(!p)) |
| 5657 | goto out_overflow; |
| 5658 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5659 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5660 | if (impl_id_count) { |
| 5661 | /* nii_domain */ |
| 5662 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5663 | if (unlikely(status)) |
| 5664 | return status; |
| 5665 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5666 | return -EIO; |
| 5667 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5668 | |
| 5669 | /* nii_name */ |
| 5670 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5671 | if (unlikely(status)) |
| 5672 | return status; |
| 5673 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5674 | return -EIO; |
| 5675 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5676 | |
| 5677 | /* nii_date */ |
| 5678 | p = xdr_inline_decode(xdr, 12); |
| 5679 | if (unlikely(!p)) |
| 5680 | goto out_overflow; |
| 5681 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5682 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5683 | |
| 5684 | /* if there's more than one entry, ignore the rest */ |
| 5685 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5686 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5687 | out_overflow: |
| 5688 | print_overflow_msg(__func__, xdr); |
| 5689 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5690 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5691 | |
| 5692 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5693 | struct nfs4_channel_attrs *attrs) |
| 5694 | { |
| 5695 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5696 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5697 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5698 | p = xdr_inline_decode(xdr, 28); |
| 5699 | if (unlikely(!p)) |
| 5700 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5701 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5702 | if (val) |
| 5703 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5704 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5705 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5706 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5707 | attrs->max_ops = be32_to_cpup(p++); |
| 5708 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5709 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5710 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5711 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5712 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5713 | return -EINVAL; |
| 5714 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5715 | if (nr_attrs == 1) { |
| 5716 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5717 | if (unlikely(!p)) |
| 5718 | goto out_overflow; |
| 5719 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5720 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5721 | out_overflow: |
| 5722 | print_overflow_msg(__func__, xdr); |
| 5723 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5724 | } |
| 5725 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5726 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5727 | { |
| 5728 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5729 | } |
| 5730 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5731 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5732 | struct nfs41_bind_conn_to_session_res *res) |
| 5733 | { |
| 5734 | __be32 *p; |
| 5735 | int status; |
| 5736 | |
| 5737 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5738 | if (!status) |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5739 | status = decode_sessionid(xdr, &res->sessionid); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5740 | if (unlikely(status)) |
| 5741 | return status; |
| 5742 | |
| 5743 | /* dir flags, rdma mode bool */ |
| 5744 | p = xdr_inline_decode(xdr, 8); |
| 5745 | if (unlikely(!p)) |
| 5746 | goto out_overflow; |
| 5747 | |
| 5748 | res->dir = be32_to_cpup(p++); |
| 5749 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5750 | return -EIO; |
| 5751 | if (be32_to_cpup(p) == 0) |
| 5752 | res->use_conn_in_rdma_mode = false; |
| 5753 | else |
| 5754 | res->use_conn_in_rdma_mode = true; |
| 5755 | |
| 5756 | return 0; |
| 5757 | out_overflow: |
| 5758 | print_overflow_msg(__func__, xdr); |
| 5759 | return -EIO; |
| 5760 | } |
| 5761 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5762 | static int decode_create_session(struct xdr_stream *xdr, |
| 5763 | struct nfs41_create_session_res *res) |
| 5764 | { |
| 5765 | __be32 *p; |
| 5766 | int status; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5767 | |
| 5768 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5769 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5770 | status = decode_sessionid(xdr, &res->sessionid); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5771 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5772 | return status; |
| 5773 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5774 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5775 | p = xdr_inline_decode(xdr, 8); |
| 5776 | if (unlikely(!p)) |
| 5777 | goto out_overflow; |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5778 | res->seqid = be32_to_cpup(p++); |
| 5779 | res->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5780 | |
| 5781 | /* Channel attributes */ |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5782 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5783 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5784 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5785 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5786 | out_overflow: |
| 5787 | print_overflow_msg(__func__, xdr); |
| 5788 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5789 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5790 | |
| 5791 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5792 | { |
| 5793 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5794 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5795 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5796 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5797 | { |
| 5798 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5799 | } |
| 5800 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5801 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5802 | { |
| 5803 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5804 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5805 | #endif /* CONFIG_NFS_V4_1 */ |
| 5806 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5807 | static int decode_sequence(struct xdr_stream *xdr, |
| 5808 | struct nfs4_sequence_res *res, |
| 5809 | struct rpc_rqst *rqstp) |
| 5810 | { |
| 5811 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5812 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5813 | struct nfs4_sessionid id; |
| 5814 | u32 dummy; |
| 5815 | int status; |
| 5816 | __be32 *p; |
| 5817 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5818 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5819 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5820 | if (!res->sr_slot->table->session) |
| 5821 | return 0; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5822 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5823 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5824 | if (!status) |
| 5825 | status = decode_sessionid(xdr, &id); |
| 5826 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5827 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5828 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5829 | /* |
| 5830 | * If the server returns different values for sessionID, slotID or |
| 5831 | * sequence number, the server is looney tunes. |
| 5832 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5833 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5834 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5835 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5836 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5837 | NFS4_MAX_SESSIONID_LEN)) { |
| 5838 | dprintk("%s Invalid session id\n", __func__); |
| 5839 | goto out_err; |
| 5840 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5841 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5842 | p = xdr_inline_decode(xdr, 20); |
| 5843 | if (unlikely(!p)) |
| 5844 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5845 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5846 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5847 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5848 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5849 | dprintk("%s Invalid sequence number\n", __func__); |
| 5850 | goto out_err; |
| 5851 | } |
| 5852 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5853 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5854 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5855 | dprintk("%s Invalid slot id\n", __func__); |
| 5856 | goto out_err; |
| 5857 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5858 | /* highest slot id */ |
| 5859 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5860 | /* target highest slot id */ |
| 5861 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5862 | /* result flags */ |
| 5863 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5864 | status = 0; |
| 5865 | out_err: |
| 5866 | res->sr_status = status; |
| 5867 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5868 | out_overflow: |
| 5869 | print_overflow_msg(__func__, xdr); |
| 5870 | status = -EIO; |
| 5871 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5872 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5873 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5874 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5875 | } |
| 5876 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5877 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5878 | static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 5879 | { |
| 5880 | stateid->type = NFS4_LAYOUT_STATEID_TYPE; |
| 5881 | return decode_stateid(xdr, stateid); |
| 5882 | } |
| 5883 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5884 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5885 | struct nfs4_getdeviceinfo_res *res) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5886 | { |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5887 | struct pnfs_device *pdev = res->pdev; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5888 | __be32 *p; |
| 5889 | uint32_t len, type; |
| 5890 | int status; |
| 5891 | |
| 5892 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5893 | if (status) { |
| 5894 | if (status == -ETOOSMALL) { |
| 5895 | p = xdr_inline_decode(xdr, 4); |
| 5896 | if (unlikely(!p)) |
| 5897 | goto out_overflow; |
| 5898 | pdev->mincount = be32_to_cpup(p); |
| 5899 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5900 | __func__, pdev->mincount); |
| 5901 | } |
| 5902 | return status; |
| 5903 | } |
| 5904 | |
| 5905 | p = xdr_inline_decode(xdr, 8); |
| 5906 | if (unlikely(!p)) |
| 5907 | goto out_overflow; |
| 5908 | type = be32_to_cpup(p++); |
| 5909 | if (type != pdev->layout_type) { |
| 5910 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5911 | __func__, pdev->layout_type, type); |
| 5912 | return -EINVAL; |
| 5913 | } |
| 5914 | /* |
| 5915 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5916 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5917 | * and places the remaining xdr data in xdr_buf->tail |
| 5918 | */ |
| 5919 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5920 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 5921 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5922 | |
| 5923 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5924 | p = xdr_inline_decode(xdr, 4); |
| 5925 | if (unlikely(!p)) |
| 5926 | goto out_overflow; |
| 5927 | len = be32_to_cpup(p); |
| 5928 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5929 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5930 | |
| 5931 | p = xdr_inline_decode(xdr, 4 * len); |
| 5932 | if (unlikely(!p)) |
| 5933 | goto out_overflow; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5934 | |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5935 | res->notification = be32_to_cpup(p++); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5936 | for (i = 1; i < len; i++) { |
| 5937 | if (be32_to_cpup(p++)) { |
| 5938 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5939 | __func__); |
| 5940 | return -EIO; |
| 5941 | } |
| 5942 | } |
| 5943 | } |
| 5944 | return 0; |
| 5945 | out_overflow: |
| 5946 | print_overflow_msg(__func__, xdr); |
| 5947 | return -EIO; |
| 5948 | } |
| 5949 | |
| 5950 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5951 | struct nfs4_layoutget_res *res) |
| 5952 | { |
| 5953 | __be32 *p; |
| 5954 | int status; |
| 5955 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5956 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5957 | |
| 5958 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5959 | if (status) |
| 5960 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5961 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5962 | if (unlikely(!p)) |
| 5963 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5964 | res->return_on_close = be32_to_cpup(p); |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5965 | decode_layout_stateid(xdr, &res->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5966 | p = xdr_inline_decode(xdr, 4); |
| 5967 | if (unlikely(!p)) |
| 5968 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5969 | layout_count = be32_to_cpup(p); |
| 5970 | if (!layout_count) { |
| 5971 | dprintk("%s: server responded with empty layout array\n", |
| 5972 | __func__); |
| 5973 | return -EINVAL; |
| 5974 | } |
| 5975 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5976 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5977 | if (unlikely(!p)) |
| 5978 | goto out_overflow; |
| 5979 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5980 | p = xdr_decode_hyper(p, &res->range.length); |
| 5981 | res->range.iomode = be32_to_cpup(p++); |
| 5982 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5983 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5984 | |
| 5985 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5986 | __func__, |
| 5987 | (unsigned long)res->range.offset, |
| 5988 | (unsigned long)res->range.length, |
| 5989 | res->range.iomode, |
| 5990 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5991 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5992 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5993 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5994 | if (res->layoutp->len > recvd) { |
| 5995 | dprintk("NFS: server cheating in layoutget reply: " |
| 5996 | "layout len %u > recvd %u\n", |
| 5997 | res->layoutp->len, recvd); |
| 5998 | return -EINVAL; |
| 5999 | } |
| 6000 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6001 | if (layout_count > 1) { |
| 6002 | /* We only handle a length one array at the moment. Any |
| 6003 | * further entries are just ignored. Note that this means |
| 6004 | * the client may see a response that is less than the |
| 6005 | * minimum it requested. |
| 6006 | */ |
| 6007 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 6008 | __func__, layout_count); |
| 6009 | } |
| 6010 | |
| 6011 | return 0; |
| 6012 | out_overflow: |
| 6013 | print_overflow_msg(__func__, xdr); |
| 6014 | return -EIO; |
| 6015 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6016 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6017 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 6018 | struct nfs4_layoutreturn_res *res) |
| 6019 | { |
| 6020 | __be32 *p; |
| 6021 | int status; |
| 6022 | |
| 6023 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 6024 | if (status) |
| 6025 | return status; |
| 6026 | p = xdr_inline_decode(xdr, 4); |
| 6027 | if (unlikely(!p)) |
| 6028 | goto out_overflow; |
| 6029 | res->lrs_present = be32_to_cpup(p); |
| 6030 | if (res->lrs_present) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 6031 | status = decode_layout_stateid(xdr, &res->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6032 | return status; |
| 6033 | out_overflow: |
| 6034 | print_overflow_msg(__func__, xdr); |
| 6035 | return -EIO; |
| 6036 | } |
| 6037 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6038 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 6039 | struct rpc_rqst *req, |
| 6040 | struct nfs4_layoutcommit_res *res) |
| 6041 | { |
| 6042 | __be32 *p; |
| 6043 | __u32 sizechanged; |
| 6044 | int status; |
| 6045 | |
| 6046 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 6047 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6048 | if (status) |
| 6049 | return status; |
| 6050 | |
| 6051 | p = xdr_inline_decode(xdr, 4); |
| 6052 | if (unlikely(!p)) |
| 6053 | goto out_overflow; |
| 6054 | sizechanged = be32_to_cpup(p); |
| 6055 | |
| 6056 | if (sizechanged) { |
| 6057 | /* throw away new size */ |
| 6058 | p = xdr_inline_decode(xdr, 8); |
| 6059 | if (unlikely(!p)) |
| 6060 | goto out_overflow; |
| 6061 | } |
| 6062 | return 0; |
| 6063 | out_overflow: |
| 6064 | print_overflow_msg(__func__, xdr); |
| 6065 | return -EIO; |
| 6066 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6067 | |
| 6068 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 6069 | struct nfs41_test_stateid_res *res) |
| 6070 | { |
| 6071 | __be32 *p; |
| 6072 | int status; |
| 6073 | int num_res; |
| 6074 | |
| 6075 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 6076 | if (status) |
| 6077 | return status; |
| 6078 | |
| 6079 | p = xdr_inline_decode(xdr, 4); |
| 6080 | if (unlikely(!p)) |
| 6081 | goto out_overflow; |
| 6082 | num_res = be32_to_cpup(p++); |
| 6083 | if (num_res != 1) |
| 6084 | goto out; |
| 6085 | |
| 6086 | p = xdr_inline_decode(xdr, 4); |
| 6087 | if (unlikely(!p)) |
| 6088 | goto out_overflow; |
| 6089 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 6090 | |
| 6091 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6092 | out_overflow: |
| 6093 | print_overflow_msg(__func__, xdr); |
| 6094 | out: |
| 6095 | return -EIO; |
| 6096 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6097 | |
| 6098 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 6099 | struct nfs41_free_stateid_res *res) |
| 6100 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 6101 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6102 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6103 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 6104 | #else |
| 6105 | static inline |
| 6106 | int decode_layoutreturn(struct xdr_stream *xdr, |
| 6107 | struct nfs4_layoutreturn_res *res) |
| 6108 | { |
| 6109 | return 0; |
| 6110 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6111 | #endif /* CONFIG_NFS_V4_1 */ |
| 6112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6113 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 6114 | * END OF "GENERIC" DECODE ROUTINES. |
| 6115 | */ |
| 6116 | |
| 6117 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6118 | * Decode OPEN_DOWNGRADE response |
| 6119 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6120 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 6121 | struct xdr_stream *xdr, |
| 6122 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6123 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6124 | struct compound_hdr hdr; |
| 6125 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6126 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6127 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6128 | if (status) |
| 6129 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6130 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6131 | if (status) |
| 6132 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6133 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6134 | if (status) |
| 6135 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6136 | status = decode_open_downgrade(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6137 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6138 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6139 | } |
| 6140 | |
| 6141 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6142 | * Decode ACCESS response |
| 6143 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6144 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6145 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6146 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6147 | struct compound_hdr hdr; |
| 6148 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6149 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6150 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6151 | if (status) |
| 6152 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6153 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6154 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6155 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6156 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6157 | if (status != 0) |
| 6158 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6159 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6160 | if (status != 0) |
| 6161 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6162 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6163 | out: |
| 6164 | return status; |
| 6165 | } |
| 6166 | |
| 6167 | /* |
| 6168 | * Decode LOOKUP response |
| 6169 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6170 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6171 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6172 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | struct compound_hdr hdr; |
| 6174 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6175 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6176 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6177 | if (status) |
| 6178 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6179 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6180 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6182 | status = decode_putfh(xdr); |
| 6183 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6184 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6185 | status = decode_lookup(xdr); |
| 6186 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6187 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6188 | status = decode_getfh(xdr, res->fh); |
| 6189 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6190 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6191 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | out: |
| 6193 | return status; |
| 6194 | } |
| 6195 | |
| 6196 | /* |
| 6197 | * Decode LOOKUP_ROOT response |
| 6198 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6199 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6200 | struct xdr_stream *xdr, |
| 6201 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6203 | struct compound_hdr hdr; |
| 6204 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6205 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6206 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6207 | if (status) |
| 6208 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6209 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6210 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6211 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6212 | status = decode_putrootfh(xdr); |
| 6213 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6214 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6215 | status = decode_getfh(xdr, res->fh); |
| 6216 | if (status == 0) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6217 | status = decode_getfattr_label(xdr, res->fattr, |
| 6218 | res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6219 | out: |
| 6220 | return status; |
| 6221 | } |
| 6222 | |
| 6223 | /* |
| 6224 | * Decode REMOVE response |
| 6225 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6226 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6227 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | struct compound_hdr hdr; |
| 6230 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6231 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6232 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6233 | if (status) |
| 6234 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6235 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6236 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6237 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6238 | status = decode_putfh(xdr); |
| 6239 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6240 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6241 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6242 | out: |
| 6243 | return status; |
| 6244 | } |
| 6245 | |
| 6246 | /* |
| 6247 | * Decode RENAME response |
| 6248 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6249 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6250 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6251 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6252 | struct compound_hdr hdr; |
| 6253 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6254 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6255 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6256 | if (status) |
| 6257 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6258 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6259 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6260 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6261 | status = decode_putfh(xdr); |
| 6262 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6264 | status = decode_savefh(xdr); |
| 6265 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6266 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6267 | status = decode_putfh(xdr); |
| 6268 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6269 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6270 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6271 | out: |
| 6272 | return status; |
| 6273 | } |
| 6274 | |
| 6275 | /* |
| 6276 | * Decode LINK response |
| 6277 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6278 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6279 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6280 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6281 | struct compound_hdr hdr; |
| 6282 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6283 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6284 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6285 | if (status) |
| 6286 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6287 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6288 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6289 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6290 | status = decode_putfh(xdr); |
| 6291 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6292 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | status = decode_savefh(xdr); |
| 6294 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6295 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6296 | status = decode_putfh(xdr); |
| 6297 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6298 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6299 | status = decode_link(xdr, &res->cinfo); |
| 6300 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6301 | goto out; |
| 6302 | /* |
| 6303 | * Note order: OP_LINK leaves the directory as the current |
| 6304 | * filehandle. |
| 6305 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6306 | status = decode_restorefh(xdr); |
| 6307 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6308 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6309 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6310 | out: |
| 6311 | return status; |
| 6312 | } |
| 6313 | |
| 6314 | /* |
| 6315 | * Decode CREATE response |
| 6316 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6317 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6318 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6319 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6320 | struct compound_hdr hdr; |
| 6321 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6322 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6323 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6324 | if (status) |
| 6325 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6326 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6327 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6329 | status = decode_putfh(xdr); |
| 6330 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6331 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6332 | status = decode_create(xdr, &res->dir_cinfo); |
| 6333 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6334 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6335 | status = decode_getfh(xdr, res->fh); |
| 6336 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6337 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6338 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6339 | out: |
| 6340 | return status; |
| 6341 | } |
| 6342 | |
| 6343 | /* |
| 6344 | * Decode SYMLINK response |
| 6345 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6346 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6347 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6348 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6349 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6350 | } |
| 6351 | |
| 6352 | /* |
| 6353 | * Decode GETATTR response |
| 6354 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6355 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6356 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6357 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6358 | struct compound_hdr hdr; |
| 6359 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6360 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6361 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | if (status) |
| 6363 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6364 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6365 | if (status) |
| 6366 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6367 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6368 | if (status) |
| 6369 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6370 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | out: |
| 6372 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6373 | } |
| 6374 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6375 | /* |
| 6376 | * Encode an SETACL request |
| 6377 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6378 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6379 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6380 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6381 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6382 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6383 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6384 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6385 | encode_compound_hdr(xdr, req, &hdr); |
| 6386 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6387 | encode_putfh(xdr, args->fh, &hdr); |
| 6388 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6389 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6390 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6391 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6392 | /* |
| 6393 | * Decode SETACL response |
| 6394 | */ |
| 6395 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6396 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6397 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6398 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6399 | struct compound_hdr hdr; |
| 6400 | int status; |
| 6401 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6402 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6403 | if (status) |
| 6404 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6405 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6406 | if (status) |
| 6407 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6408 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6409 | if (status) |
| 6410 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6411 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6412 | out: |
| 6413 | return status; |
| 6414 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6415 | |
| 6416 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6417 | * Decode GETACL response |
| 6418 | */ |
| 6419 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6420 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6421 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6422 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6423 | struct compound_hdr hdr; |
| 6424 | int status; |
| 6425 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6426 | if (res->acl_scratch != NULL) { |
| 6427 | void *p = page_address(res->acl_scratch); |
| 6428 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6429 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6430 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6431 | if (status) |
| 6432 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6433 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6434 | if (status) |
| 6435 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6436 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6437 | if (status) |
| 6438 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6439 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6440 | |
| 6441 | out: |
| 6442 | return status; |
| 6443 | } |
| 6444 | |
| 6445 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6446 | * Decode CLOSE response |
| 6447 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6448 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6449 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6450 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6451 | struct compound_hdr hdr; |
| 6452 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6453 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6454 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6455 | if (status) |
| 6456 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6457 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6458 | if (status) |
| 6459 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6460 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6461 | if (status) |
| 6462 | goto out; |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame^] | 6463 | if (res->lr_res) { |
| 6464 | status = decode_layoutreturn(xdr, res->lr_res); |
| 6465 | res->lr_ret = status; |
| 6466 | if (status) |
| 6467 | goto out; |
| 6468 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6469 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6470 | if (status != 0) |
| 6471 | goto out; |
| 6472 | /* |
| 6473 | * Note: Server may do delete on close for this file |
| 6474 | * in which case the getattr call will fail with |
| 6475 | * an ESTALE error. Shouldn't be a problem, |
| 6476 | * though, since fattr->valid will remain unset. |
| 6477 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6478 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6480 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6481 | } |
| 6482 | |
| 6483 | /* |
| 6484 | * Decode OPEN response |
| 6485 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6486 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6487 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6488 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6489 | struct compound_hdr hdr; |
| 6490 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6492 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6493 | if (status) |
| 6494 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6495 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6496 | if (status) |
| 6497 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6498 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6499 | if (status) |
| 6500 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6501 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6502 | if (status) |
| 6503 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6504 | status = decode_getfh(xdr, &res->fh); |
| 6505 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6506 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6507 | if (res->access_request) |
| 6508 | decode_access(xdr, &res->access_supported, &res->access_result); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6509 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6510 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6511 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6512 | } |
| 6513 | |
| 6514 | /* |
| 6515 | * Decode OPEN_CONFIRM response |
| 6516 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6517 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6518 | struct xdr_stream *xdr, |
| 6519 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6520 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6521 | struct compound_hdr hdr; |
| 6522 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6523 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6524 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6525 | if (status) |
| 6526 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6527 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6528 | if (status) |
| 6529 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6530 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6531 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6532 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6533 | } |
| 6534 | |
| 6535 | /* |
| 6536 | * Decode OPEN response |
| 6537 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6538 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6539 | struct xdr_stream *xdr, |
| 6540 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6541 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6542 | struct compound_hdr hdr; |
| 6543 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6544 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6545 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6546 | if (status) |
| 6547 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6548 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6549 | if (status) |
| 6550 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6551 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6552 | if (status) |
| 6553 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6554 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6555 | if (status) |
| 6556 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6557 | if (res->access_request) |
| 6558 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6559 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6560 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6561 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6562 | } |
| 6563 | |
| 6564 | /* |
| 6565 | * Decode SETATTR response |
| 6566 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6567 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6568 | struct xdr_stream *xdr, |
| 6569 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6570 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6571 | struct compound_hdr hdr; |
| 6572 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6574 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6575 | if (status) |
| 6576 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6577 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6578 | if (status) |
| 6579 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6580 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6581 | if (status) |
| 6582 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6583 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6584 | if (status) |
| 6585 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6586 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6587 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6588 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6589 | } |
| 6590 | |
| 6591 | /* |
| 6592 | * Decode LOCK response |
| 6593 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6594 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6595 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6596 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6597 | struct compound_hdr hdr; |
| 6598 | int status; |
| 6599 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6600 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6601 | if (status) |
| 6602 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6603 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6604 | if (status) |
| 6605 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6606 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6607 | if (status) |
| 6608 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6609 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6610 | out: |
| 6611 | return status; |
| 6612 | } |
| 6613 | |
| 6614 | /* |
| 6615 | * Decode LOCKT response |
| 6616 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6617 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6618 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6619 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6620 | struct compound_hdr hdr; |
| 6621 | int status; |
| 6622 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6623 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6624 | if (status) |
| 6625 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6626 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6627 | if (status) |
| 6628 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6629 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6630 | if (status) |
| 6631 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6632 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6633 | out: |
| 6634 | return status; |
| 6635 | } |
| 6636 | |
| 6637 | /* |
| 6638 | * Decode LOCKU response |
| 6639 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6640 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6641 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6642 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6643 | struct compound_hdr hdr; |
| 6644 | int status; |
| 6645 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6646 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6647 | if (status) |
| 6648 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6649 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6650 | if (status) |
| 6651 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6652 | status = decode_putfh(xdr); |
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_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6656 | out: |
| 6657 | return status; |
| 6658 | } |
| 6659 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6660 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6661 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6662 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6663 | struct compound_hdr hdr; |
| 6664 | int status; |
| 6665 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6666 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6667 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6668 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6669 | return status; |
| 6670 | } |
| 6671 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6672 | /* |
| 6673 | * Decode READLINK response |
| 6674 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6675 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6676 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6677 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6678 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6679 | struct compound_hdr hdr; |
| 6680 | int status; |
| 6681 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6682 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6683 | if (status) |
| 6684 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6685 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6686 | if (status) |
| 6687 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6688 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6689 | if (status) |
| 6690 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6691 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6692 | out: |
| 6693 | return status; |
| 6694 | } |
| 6695 | |
| 6696 | /* |
| 6697 | * Decode READDIR response |
| 6698 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6699 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6700 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6701 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6702 | struct compound_hdr hdr; |
| 6703 | int status; |
| 6704 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6705 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6706 | if (status) |
| 6707 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6708 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6709 | if (status) |
| 6710 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6711 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6712 | if (status) |
| 6713 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6714 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6715 | out: |
| 6716 | return status; |
| 6717 | } |
| 6718 | |
| 6719 | /* |
| 6720 | * Decode Read response |
| 6721 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6722 | 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] | 6723 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6724 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6725 | struct compound_hdr hdr; |
| 6726 | int status; |
| 6727 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6728 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6729 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6730 | if (status) |
| 6731 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6732 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6733 | if (status) |
| 6734 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6735 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6736 | if (status) |
| 6737 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6738 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6739 | if (!status) |
| 6740 | status = res->count; |
| 6741 | out: |
| 6742 | return status; |
| 6743 | } |
| 6744 | |
| 6745 | /* |
| 6746 | * Decode WRITE response |
| 6747 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6748 | 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] | 6749 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6750 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6751 | struct compound_hdr hdr; |
| 6752 | int status; |
| 6753 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6754 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6755 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6756 | if (status) |
| 6757 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6758 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6759 | if (status) |
| 6760 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6761 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6762 | if (status) |
| 6763 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6764 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6765 | if (status) |
| 6766 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6767 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6768 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6769 | if (!status) |
| 6770 | status = res->count; |
| 6771 | out: |
| 6772 | return status; |
| 6773 | } |
| 6774 | |
| 6775 | /* |
| 6776 | * Decode COMMIT response |
| 6777 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6778 | 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] | 6779 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6780 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6781 | struct compound_hdr hdr; |
| 6782 | int status; |
| 6783 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6784 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6785 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6786 | if (status) |
| 6787 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6788 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6789 | if (status) |
| 6790 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6791 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6792 | if (status) |
| 6793 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6794 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6795 | out: |
| 6796 | return status; |
| 6797 | } |
| 6798 | |
| 6799 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6800 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6801 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6802 | 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] | 6803 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6804 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6805 | struct compound_hdr hdr; |
| 6806 | int status; |
| 6807 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6808 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6809 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6810 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6811 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6812 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6813 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6814 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6815 | return status; |
| 6816 | } |
| 6817 | |
| 6818 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6819 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6820 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6821 | 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] | 6822 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6823 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6824 | struct compound_hdr hdr; |
| 6825 | int status; |
| 6826 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6827 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6828 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6829 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6830 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6831 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6832 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6833 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6834 | return status; |
| 6835 | } |
| 6836 | |
| 6837 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6838 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6839 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6840 | 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] | 6841 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6842 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6843 | struct compound_hdr hdr; |
| 6844 | int status; |
| 6845 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6846 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6847 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6848 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6849 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6850 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6851 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6852 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6853 | return status; |
| 6854 | } |
| 6855 | |
| 6856 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6857 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6858 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6859 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6860 | struct xdr_stream *xdr, |
| 6861 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6862 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6863 | struct compound_hdr hdr; |
| 6864 | int status; |
| 6865 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6866 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6867 | if (status) |
| 6868 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6869 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6870 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6871 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6872 | status = decode_putfh(xdr); |
| 6873 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6874 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6875 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6876 | out: |
| 6877 | return status; |
| 6878 | } |
| 6879 | |
| 6880 | /* |
| 6881 | * Decode RENEW response |
| 6882 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6883 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6884 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6885 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6886 | struct compound_hdr hdr; |
| 6887 | int status; |
| 6888 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6889 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6890 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6891 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6892 | return status; |
| 6893 | } |
| 6894 | |
| 6895 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6896 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6897 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6898 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6899 | struct xdr_stream *xdr, |
| 6900 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6901 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6902 | struct compound_hdr hdr; |
| 6903 | int status; |
| 6904 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6905 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6906 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6907 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6908 | return status; |
| 6909 | } |
| 6910 | |
| 6911 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6912 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6913 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6914 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 6915 | struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6916 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6917 | struct compound_hdr hdr; |
| 6918 | int status; |
| 6919 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6920 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6921 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6922 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6923 | return status; |
| 6924 | } |
| 6925 | |
| 6926 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6927 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6928 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6929 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6930 | struct xdr_stream *xdr, |
| 6931 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6932 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6933 | struct compound_hdr hdr; |
| 6934 | int status; |
| 6935 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6936 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6937 | if (status) |
| 6938 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6939 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6940 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6941 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6942 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6943 | if (status != 0) |
| 6944 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6945 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6946 | if (status != 0) |
| 6947 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6948 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6949 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6950 | return status; |
| 6951 | } |
| 6952 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6953 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6954 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6955 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6956 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6957 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6958 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6959 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6960 | struct compound_hdr hdr; |
| 6961 | int status; |
| 6962 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6963 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6964 | if (status) |
| 6965 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6966 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6967 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6968 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6969 | status = decode_putfh(xdr); |
| 6970 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6971 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6972 | if (res->migration) { |
| 6973 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6974 | status = decode_getfattr_generic(xdr, |
| 6975 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6976 | NULL, res->fs_locations, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6977 | NULL, res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6978 | if (status) |
| 6979 | goto out; |
| 6980 | if (res->renew) |
| 6981 | status = decode_renew(xdr); |
| 6982 | } else { |
| 6983 | status = decode_lookup(xdr); |
| 6984 | if (status) |
| 6985 | goto out; |
| 6986 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6987 | status = decode_getfattr_generic(xdr, |
| 6988 | &res->fs_locations->fattr, |
| 6989 | NULL, res->fs_locations, |
| 6990 | NULL, res->fs_locations->server); |
| 6991 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6992 | out: |
| 6993 | return status; |
| 6994 | } |
| 6995 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6996 | /* |
| 6997 | * Decode SECINFO response |
| 6998 | */ |
| 6999 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 7000 | struct xdr_stream *xdr, |
| 7001 | struct nfs4_secinfo_res *res) |
| 7002 | { |
| 7003 | struct compound_hdr hdr; |
| 7004 | int status; |
| 7005 | |
| 7006 | status = decode_compound_hdr(xdr, &hdr); |
| 7007 | if (status) |
| 7008 | goto out; |
| 7009 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7010 | if (status) |
| 7011 | goto out; |
| 7012 | status = decode_putfh(xdr); |
| 7013 | if (status) |
| 7014 | goto out; |
| 7015 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7016 | out: |
| 7017 | return status; |
| 7018 | } |
| 7019 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7020 | /* |
| 7021 | * Decode FSID_PRESENT response |
| 7022 | */ |
| 7023 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 7024 | struct xdr_stream *xdr, |
| 7025 | struct nfs4_fsid_present_res *res) |
| 7026 | { |
| 7027 | struct compound_hdr hdr; |
| 7028 | int status; |
| 7029 | |
| 7030 | status = decode_compound_hdr(xdr, &hdr); |
| 7031 | if (status) |
| 7032 | goto out; |
| 7033 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7034 | if (status) |
| 7035 | goto out; |
| 7036 | status = decode_putfh(xdr); |
| 7037 | if (status) |
| 7038 | goto out; |
| 7039 | status = decode_getfh(xdr, res->fh); |
| 7040 | if (status) |
| 7041 | goto out; |
| 7042 | if (res->renew) |
| 7043 | status = decode_renew(xdr); |
| 7044 | out: |
| 7045 | return status; |
| 7046 | } |
| 7047 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7048 | #if defined(CONFIG_NFS_V4_1) |
| 7049 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 7050 | * Decode BIND_CONN_TO_SESSION response |
| 7051 | */ |
| 7052 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 7053 | struct xdr_stream *xdr, |
| 7054 | void *res) |
| 7055 | { |
| 7056 | struct compound_hdr hdr; |
| 7057 | int status; |
| 7058 | |
| 7059 | status = decode_compound_hdr(xdr, &hdr); |
| 7060 | if (!status) |
| 7061 | status = decode_bind_conn_to_session(xdr, res); |
| 7062 | return status; |
| 7063 | } |
| 7064 | |
| 7065 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7066 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7067 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7068 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 7069 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7070 | void *res) |
| 7071 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7072 | struct compound_hdr hdr; |
| 7073 | int status; |
| 7074 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7075 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7076 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7077 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7078 | return status; |
| 7079 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7080 | |
| 7081 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7082 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7083 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7084 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 7085 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7086 | struct nfs41_create_session_res *res) |
| 7087 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7088 | struct compound_hdr hdr; |
| 7089 | int status; |
| 7090 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7091 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7092 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7093 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7094 | return status; |
| 7095 | } |
| 7096 | |
| 7097 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7098 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7099 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7100 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 7101 | struct xdr_stream *xdr, |
| 7102 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7103 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7104 | struct compound_hdr hdr; |
| 7105 | int status; |
| 7106 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7107 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7108 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7109 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7110 | return status; |
| 7111 | } |
| 7112 | |
| 7113 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7114 | * Decode DESTROY_CLIENTID response |
| 7115 | */ |
| 7116 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 7117 | struct xdr_stream *xdr, |
| 7118 | void *res) |
| 7119 | { |
| 7120 | struct compound_hdr hdr; |
| 7121 | int status; |
| 7122 | |
| 7123 | status = decode_compound_hdr(xdr, &hdr); |
| 7124 | if (!status) |
| 7125 | status = decode_destroy_clientid(xdr, res); |
| 7126 | return status; |
| 7127 | } |
| 7128 | |
| 7129 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7130 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7131 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7132 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 7133 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7134 | struct nfs4_sequence_res *res) |
| 7135 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7136 | struct compound_hdr hdr; |
| 7137 | int status; |
| 7138 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7139 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7140 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7141 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7142 | return status; |
| 7143 | } |
| 7144 | |
| 7145 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7146 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7147 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7148 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 7149 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7150 | struct nfs4_get_lease_time_res *res) |
| 7151 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7152 | struct compound_hdr hdr; |
| 7153 | int status; |
| 7154 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7155 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7156 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7157 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7158 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7159 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7160 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7161 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7162 | return status; |
| 7163 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7164 | |
| 7165 | /* |
| 7166 | * Decode RECLAIM_COMPLETE response |
| 7167 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7168 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7169 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7170 | struct nfs41_reclaim_complete_res *res) |
| 7171 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7172 | struct compound_hdr hdr; |
| 7173 | int status; |
| 7174 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7175 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7176 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7177 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7178 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7179 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7180 | return status; |
| 7181 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7182 | |
| 7183 | /* |
| 7184 | * Decode GETDEVINFO response |
| 7185 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7186 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7187 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7188 | struct nfs4_getdeviceinfo_res *res) |
| 7189 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7190 | struct compound_hdr hdr; |
| 7191 | int status; |
| 7192 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7193 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7194 | if (status != 0) |
| 7195 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7196 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7197 | if (status != 0) |
| 7198 | goto out; |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 7199 | status = decode_getdeviceinfo(xdr, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7200 | out: |
| 7201 | return status; |
| 7202 | } |
| 7203 | |
| 7204 | /* |
| 7205 | * Decode LAYOUTGET response |
| 7206 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7207 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7208 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7209 | struct nfs4_layoutget_res *res) |
| 7210 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7211 | struct compound_hdr hdr; |
| 7212 | int status; |
| 7213 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7214 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7215 | if (status) |
| 7216 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7217 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7218 | if (status) |
| 7219 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7220 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7221 | if (status) |
| 7222 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7223 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7224 | out: |
| 7225 | return status; |
| 7226 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7227 | |
| 7228 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7229 | * Decode LAYOUTRETURN response |
| 7230 | */ |
| 7231 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7232 | struct xdr_stream *xdr, |
| 7233 | struct nfs4_layoutreturn_res *res) |
| 7234 | { |
| 7235 | struct compound_hdr hdr; |
| 7236 | int status; |
| 7237 | |
| 7238 | status = decode_compound_hdr(xdr, &hdr); |
| 7239 | if (status) |
| 7240 | goto out; |
| 7241 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7242 | if (status) |
| 7243 | goto out; |
| 7244 | status = decode_putfh(xdr); |
| 7245 | if (status) |
| 7246 | goto out; |
| 7247 | status = decode_layoutreturn(xdr, res); |
| 7248 | out: |
| 7249 | return status; |
| 7250 | } |
| 7251 | |
| 7252 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7253 | * Decode LAYOUTCOMMIT response |
| 7254 | */ |
| 7255 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7256 | struct xdr_stream *xdr, |
| 7257 | struct nfs4_layoutcommit_res *res) |
| 7258 | { |
| 7259 | struct compound_hdr hdr; |
| 7260 | int status; |
| 7261 | |
| 7262 | status = decode_compound_hdr(xdr, &hdr); |
| 7263 | if (status) |
| 7264 | goto out; |
| 7265 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7266 | if (status) |
| 7267 | goto out; |
| 7268 | status = decode_putfh(xdr); |
| 7269 | if (status) |
| 7270 | goto out; |
| 7271 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7272 | if (status) |
| 7273 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7274 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7275 | out: |
| 7276 | return status; |
| 7277 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7278 | |
| 7279 | /* |
| 7280 | * Decode SECINFO_NO_NAME response |
| 7281 | */ |
| 7282 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7283 | struct xdr_stream *xdr, |
| 7284 | struct nfs4_secinfo_res *res) |
| 7285 | { |
| 7286 | struct compound_hdr hdr; |
| 7287 | int status; |
| 7288 | |
| 7289 | status = decode_compound_hdr(xdr, &hdr); |
| 7290 | if (status) |
| 7291 | goto out; |
| 7292 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7293 | if (status) |
| 7294 | goto out; |
| 7295 | status = decode_putrootfh(xdr); |
| 7296 | if (status) |
| 7297 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7298 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7299 | out: |
| 7300 | return status; |
| 7301 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7302 | |
| 7303 | /* |
| 7304 | * Decode TEST_STATEID response |
| 7305 | */ |
| 7306 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7307 | struct xdr_stream *xdr, |
| 7308 | struct nfs41_test_stateid_res *res) |
| 7309 | { |
| 7310 | struct compound_hdr hdr; |
| 7311 | int status; |
| 7312 | |
| 7313 | status = decode_compound_hdr(xdr, &hdr); |
| 7314 | if (status) |
| 7315 | goto out; |
| 7316 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7317 | if (status) |
| 7318 | goto out; |
| 7319 | status = decode_test_stateid(xdr, res); |
| 7320 | out: |
| 7321 | return status; |
| 7322 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7323 | |
| 7324 | /* |
| 7325 | * Decode FREE_STATEID response |
| 7326 | */ |
| 7327 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7328 | struct xdr_stream *xdr, |
| 7329 | struct nfs41_free_stateid_res *res) |
| 7330 | { |
| 7331 | struct compound_hdr hdr; |
| 7332 | int status; |
| 7333 | |
| 7334 | status = decode_compound_hdr(xdr, &hdr); |
| 7335 | if (status) |
| 7336 | goto out; |
| 7337 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7338 | if (status) |
| 7339 | goto out; |
| 7340 | status = decode_free_stateid(xdr, res); |
| 7341 | out: |
| 7342 | return status; |
| 7343 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7344 | #endif /* CONFIG_NFS_V4_1 */ |
| 7345 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7346 | /** |
| 7347 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7348 | * the local page cache. |
| 7349 | * @xdr: XDR stream where entry resides |
| 7350 | * @entry: buffer to fill in with entry data |
| 7351 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7352 | * |
| 7353 | * Returns zero if successful, otherwise a negative errno value is |
| 7354 | * returned. |
| 7355 | * |
| 7356 | * This function is not invoked during READDIR reply decoding, but |
| 7357 | * rather whenever an application invokes the getdents(2) system call |
| 7358 | * on a directory already in our cache. |
| 7359 | */ |
| 7360 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 7361 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7362 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7363 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7364 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7365 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7366 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7367 | if (unlikely(!p)) |
| 7368 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7369 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7370 | p = xdr_inline_decode(xdr, 4); |
| 7371 | if (unlikely(!p)) |
| 7372 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7373 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7374 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7375 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7376 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7377 | } |
| 7378 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7379 | p = xdr_inline_decode(xdr, 12); |
| 7380 | if (unlikely(!p)) |
| 7381 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7382 | entry->prev_cookie = entry->cookie; |
| 7383 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7384 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7385 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7386 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7387 | if (unlikely(!p)) |
| 7388 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7389 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7390 | |
| 7391 | /* |
| 7392 | * In case the server doesn't return an inode number, |
| 7393 | * we fake one here. (We don't use inode number 0, |
| 7394 | * since glibc seems to choke on it...) |
| 7395 | */ |
| 7396 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7397 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7398 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7399 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7400 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7401 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7402 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7403 | goto out_overflow; |
| 7404 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7405 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7406 | NULL, entry->label, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7407 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7408 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7409 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7410 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7411 | entry->ino = entry->fattr->fileid; |
| 7412 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7413 | entry->d_type = DT_UNKNOWN; |
| 7414 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7415 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7416 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7417 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7418 | |
| 7419 | out_overflow: |
| 7420 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7421 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7422 | } |
| 7423 | |
| 7424 | /* |
| 7425 | * We need to translate between nfs status return values and |
| 7426 | * the local errno values which may not be the same. |
| 7427 | */ |
| 7428 | static struct { |
| 7429 | int stat; |
| 7430 | int errno; |
| 7431 | } nfs_errtbl[] = { |
| 7432 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7433 | { NFS4ERR_PERM, -EPERM }, |
| 7434 | { NFS4ERR_NOENT, -ENOENT }, |
| 7435 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7436 | { NFS4ERR_NXIO, -ENXIO }, |
| 7437 | { NFS4ERR_ACCESS, -EACCES }, |
| 7438 | { NFS4ERR_EXIST, -EEXIST }, |
| 7439 | { NFS4ERR_XDEV, -EXDEV }, |
| 7440 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7441 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7442 | { NFS4ERR_INVAL, -EINVAL }, |
| 7443 | { NFS4ERR_FBIG, -EFBIG }, |
| 7444 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7445 | { NFS4ERR_ROFS, -EROFS }, |
| 7446 | { NFS4ERR_MLINK, -EMLINK }, |
| 7447 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7448 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7449 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7450 | { NFS4ERR_STALE, -ESTALE }, |
| 7451 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7452 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7453 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7454 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7455 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7456 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7457 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7458 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7459 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7460 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7461 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7462 | }; |
| 7463 | |
| 7464 | /* |
| 7465 | * Convert an NFS error code to a local one. |
| 7466 | * This one is used jointly by NFSv2 and NFSv3. |
| 7467 | */ |
| 7468 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7469 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7470 | { |
| 7471 | int i; |
| 7472 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7473 | if (nfs_errtbl[i].stat == stat) |
| 7474 | return nfs_errtbl[i].errno; |
| 7475 | } |
| 7476 | if (stat <= 10000 || stat > 10100) { |
| 7477 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7478 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7479 | } |
| 7480 | /* If we cannot translate the error, the recovery routines should |
| 7481 | * handle it. |
| 7482 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7483 | * not conflict with native Linux error codes. |
| 7484 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7485 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7486 | } |
| 7487 | |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7488 | #ifdef CONFIG_NFS_V4_2 |
| 7489 | #include "nfs42xdr.c" |
| 7490 | #endif /* CONFIG_NFS_V4_2 */ |
| 7491 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7492 | #define PROC(proc, argtype, restype) \ |
| 7493 | [NFSPROC4_CLNT_##proc] = { \ |
| 7494 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7495 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7496 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7497 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7498 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7499 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7500 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7501 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7502 | |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7503 | #define STUB(proc) \ |
| 7504 | [NFSPROC4_CLNT_##proc] = { \ |
| 7505 | .p_name = #proc, \ |
| 7506 | } |
| 7507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7508 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7509 | PROC(READ, enc_read, dec_read), |
| 7510 | PROC(WRITE, enc_write, dec_write), |
| 7511 | PROC(COMMIT, enc_commit, dec_commit), |
| 7512 | PROC(OPEN, enc_open, dec_open), |
| 7513 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7514 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7515 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7516 | PROC(CLOSE, enc_close, dec_close), |
| 7517 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7518 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7519 | PROC(RENEW, enc_renew, dec_renew), |
| 7520 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7521 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7522 | PROC(LOCK, enc_lock, dec_lock), |
| 7523 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7524 | PROC(LOCKU, enc_locku, dec_locku), |
| 7525 | PROC(ACCESS, enc_access, dec_access), |
| 7526 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7527 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7528 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7529 | PROC(REMOVE, enc_remove, dec_remove), |
| 7530 | PROC(RENAME, enc_rename, dec_rename), |
| 7531 | PROC(LINK, enc_link, dec_link), |
| 7532 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7533 | PROC(CREATE, enc_create, dec_create), |
| 7534 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7535 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7536 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7537 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7538 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7539 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7540 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7541 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7542 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7543 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7544 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7545 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7546 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7547 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7548 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7549 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7550 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7551 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7552 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7553 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7554 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7555 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7556 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7557 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7558 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7559 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7560 | STUB(GETDEVICELIST), |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7561 | PROC(BIND_CONN_TO_SESSION, |
| 7562 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7563 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7564 | #endif /* CONFIG_NFS_V4_1 */ |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7565 | #ifdef CONFIG_NFS_V4_2 |
| 7566 | PROC(SEEK, enc_seek, dec_seek), |
Anna Schumaker | f4ac167 | 2014-11-25 13:18:15 -0500 | [diff] [blame] | 7567 | PROC(ALLOCATE, enc_allocate, dec_allocate), |
Anna Schumaker | 624bd5b | 2014-11-25 13:18:16 -0500 | [diff] [blame] | 7568 | PROC(DEALLOCATE, enc_deallocate, dec_deallocate), |
Trond Myklebust | be3a5d2 | 2015-06-23 19:51:55 +0800 | [diff] [blame] | 7569 | PROC(LAYOUTSTATS, enc_layoutstats, dec_layoutstats), |
Peng Tao | 3602277 | 2015-09-26 02:24:34 +0800 | [diff] [blame] | 7570 | PROC(CLONE, enc_clone, dec_clone), |
Anna Schumaker | 2e72448 | 2013-05-21 16:53:03 -0400 | [diff] [blame] | 7571 | PROC(COPY, enc_copy, dec_copy), |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7572 | #endif /* CONFIG_NFS_V4_2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7573 | }; |
| 7574 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7575 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7576 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7577 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7578 | .procs = nfs4_procedures |
| 7579 | }; |
| 7580 | |
| 7581 | /* |
| 7582 | * Local variables: |
| 7583 | * c-basic-offset: 8 |
| 7584 | * End: |
| 7585 | */ |