Commit | Line | Data |
---|---|---|
1da177e4 LT |
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> | |
6c0195a4 | 11 | * |
1da177e4 LT |
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> | |
1da177e4 LT |
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> | |
db8ac8ba WAA |
47 | #include <linux/module.h> |
48 | #include <linux/utsname.h> | |
1da177e4 | 49 | #include <linux/sunrpc/clnt.h> |
2449ea2e | 50 | #include <linux/sunrpc/msg_prot.h> |
5a5ea0d4 | 51 | #include <linux/sunrpc/gss_api.h> |
1da177e4 LT |
52 | #include <linux/nfs.h> |
53 | #include <linux/nfs4.h> | |
54 | #include <linux/nfs_fs.h> | |
f092075d | 55 | |
4ce79717 | 56 | #include "nfs4_fs.h" |
f23f6584 | 57 | #include "nfs4trace.h" |
4882ef72 | 58 | #include "internal.h" |
40c64c26 | 59 | #include "nfs4idmap.h" |
76e697ba | 60 | #include "nfs4session.h" |
b1f69b75 | 61 | #include "pnfs.h" |
f092075d | 62 | #include "netns.h" |
1da177e4 LT |
63 | |
64 | #define NFSDBG_FACILITY NFSDBG_XDR | |
65 | ||
66 | /* Mapping from NFS error code to "errno" error code. */ | |
67 | #define errno_NFSERR_IO EIO | |
68 | ||
56f487f8 | 69 | struct compound_hdr; |
0a8ea437 | 70 | static int nfs4_stat_to_errno(int); |
56f487f8 FI |
71 | static void encode_layoutget(struct xdr_stream *xdr, |
72 | const struct nfs4_layoutget_args *args, | |
73 | struct compound_hdr *hdr); | |
74 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | |
75 | struct nfs4_layoutget_res *res); | |
1da177e4 LT |
76 | |
77 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ | |
78 | #ifdef DEBUG | |
79 | #define NFS4_MAXTAGLEN 20 | |
80 | #else | |
81 | #define NFS4_MAXTAGLEN 0 | |
82 | #endif | |
83 | ||
6c0195a4 | 84 | /* lock,open owner id: |
9f958ab8 | 85 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
1da177e4 | 86 | */ |
9ed5af26 | 87 | #define pagepad_maxsz (1) |
95b72eb0 | 88 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
d035c36c | 89 | #define lock_owner_id_maxsz (1 + 1 + 4) |
9104a55d | 90 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
1da177e4 LT |
91 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
92 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) | |
93 | #define op_encode_hdr_maxsz (1) | |
94 | #define op_decode_hdr_maxsz (2) | |
9104a55d TM |
95 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
96 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
97 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | |
98 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | |
1da177e4 LT |
99 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
100 | (NFS4_FHSIZE >> 2)) | |
101 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) | |
102 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) | |
103 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) | |
104 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) | |
105 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ | |
106 | ((3+NFS4_FHSIZE) >> 2)) | |
e5012d1f | 107 | #define nfs4_fattr_bitmap_maxsz 4 |
96928206 | 108 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
36b3743f | 109 | #define nfstime4_maxsz (3) |
1da177e4 LT |
110 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
111 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) | |
bd625ba8 TM |
112 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
113 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) | |
aa9c2669 DQ |
114 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
115 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ | |
116 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) | |
aa9c2669 DQ |
117 | #else |
118 | #define nfs4_label_maxsz 0 | |
aa9c2669 | 119 | #endif |
88034c3d AA |
120 | /* We support only one layout type per file system */ |
121 | #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8) | |
96928206 BF |
122 | /* This is based on getfattr, which uses the most attributes: */ |
123 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ | |
36b3743f TM |
124 | 3*nfstime4_maxsz + \ |
125 | nfs4_owner_maxsz + \ | |
aa9c2669 DQ |
126 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
127 | decode_mdsthreshold_maxsz)) | |
96928206 BF |
128 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
129 | nfs4_fattr_value_maxsz) | |
130 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) | |
9104a55d TM |
131 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
132 | 1 + 2 + 1 + \ | |
133 | nfs4_owner_maxsz + \ | |
134 | nfs4_group_maxsz + \ | |
aa9c2669 | 135 | nfs4_label_maxsz + \ |
36b3743f TM |
136 | 1 + nfstime4_maxsz + \ |
137 | 1 + nfstime4_maxsz) | |
1da177e4 LT |
138 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
139 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) | |
56ae19f3 TM |
140 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
141 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) | |
2f42b5d0 | 142 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
dae100c2 FI |
143 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
144 | * layout types will be returned. | |
145 | */ | |
146 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ | |
57a789a1 TM |
147 | nfs4_fattr_bitmap_maxsz + 1 + \ |
148 | 1 /* lease time */ + \ | |
149 | 2 /* max filesize */ + \ | |
150 | 2 /* max read */ + \ | |
151 | 2 /* max write */ + \ | |
152 | nfstime4_maxsz /* time delta */ + \ | |
153 | 5 /* fs layout types */ + \ | |
154 | 1 /* layout blksize */ + \ | |
155 | 1 /* clone blksize */ + \ | |
7f08a335 | 156 | 1 /* change attr type */ + \ |
57a789a1 | 157 | 1 /* xattr support */) |
1da177e4 LT |
158 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
159 | #define decode_renew_maxsz (op_decode_hdr_maxsz) | |
160 | #define encode_setclientid_maxsz \ | |
161 | (op_encode_hdr_maxsz + \ | |
cc38bac3 | 162 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
b8fb2f59 JL |
163 | /* client name */ \ |
164 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
cc38bac3 | 165 | 1 /* sc_prog */ + \ |
6dd3436b CL |
166 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
167 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ | |
cc38bac3 | 168 | 1) /* sc_cb_ident */ |
1da177e4 LT |
169 | #define decode_setclientid_maxsz \ |
170 | (op_decode_hdr_maxsz + \ | |
6dd3436b CL |
171 | 2 /* clientid */ + \ |
172 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ | |
173 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ | |
174 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | |
1da177e4 LT |
175 | #define encode_setclientid_confirm_maxsz \ |
176 | (op_encode_hdr_maxsz + \ | |
177 | 3 + (NFS4_VERIFIER_SIZE >> 2)) | |
178 | #define decode_setclientid_confirm_maxsz \ | |
179 | (op_decode_hdr_maxsz) | |
e6889620 TM |
180 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
181 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) | |
5b5faaf6 JL |
182 | #define encode_lookupp_maxsz (op_encode_hdr_maxsz) |
183 | #define decode_lookupp_maxsz (op_decode_hdr_maxsz) | |
2cebf828 TM |
184 | #define encode_share_access_maxsz \ |
185 | (2) | |
4882ef72 | 186 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
2cebf828 TM |
187 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
188 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) | |
189 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ | |
190 | 2 + encode_share_access_maxsz + 2 + \ | |
191 | open_owner_id_maxsz + \ | |
192 | encode_opentype_maxsz + \ | |
193 | encode_claim_null_maxsz) | |
5a1f6d9e | 194 | #define decode_space_limit_maxsz (3) |
2cebf828 | 195 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
9104a55d | 196 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
5a1f6d9e | 197 | decode_space_limit_maxsz + \ |
2cebf828 TM |
198 | decode_ace_maxsz) |
199 | #define decode_change_info_maxsz (5) | |
200 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ | |
9104a55d | 201 | decode_stateid_maxsz + \ |
2cebf828 TM |
202 | decode_change_info_maxsz + 1 + \ |
203 | nfs4_fattr_bitmap_maxsz + \ | |
204 | decode_delegation_maxsz) | |
9104a55d TM |
205 | #define encode_open_confirm_maxsz \ |
206 | (op_encode_hdr_maxsz + \ | |
207 | encode_stateid_maxsz + 1) | |
208 | #define decode_open_confirm_maxsz \ | |
209 | (op_decode_hdr_maxsz + \ | |
210 | decode_stateid_maxsz) | |
211 | #define encode_open_downgrade_maxsz \ | |
212 | (op_encode_hdr_maxsz + \ | |
213 | encode_stateid_maxsz + 1 + \ | |
214 | encode_share_access_maxsz) | |
215 | #define decode_open_downgrade_maxsz \ | |
216 | (op_decode_hdr_maxsz + \ | |
217 | decode_stateid_maxsz) | |
218 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ | |
219 | 1 + encode_stateid_maxsz) | |
220 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ | |
221 | decode_stateid_maxsz) | |
222 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ | |
223 | encode_stateid_maxsz + \ | |
224 | encode_attrs_maxsz) | |
225 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ | |
226 | nfs4_fattr_bitmap_maxsz) | |
227 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ | |
228 | encode_stateid_maxsz + 3) | |
9ed5af26 | 229 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2 + pagepad_maxsz) |
9104a55d | 230 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
aa9c2669 DQ |
231 | 2 + encode_verifier_maxsz + 5 + \ |
232 | nfs4_label_maxsz) | |
9104a55d | 233 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
9ed5af26 | 234 | decode_verifier_maxsz + pagepad_maxsz) |
9104a55d | 235 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
9ed5af26 | 236 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz) |
9104a55d TM |
237 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
238 | encode_stateid_maxsz + 4) | |
239 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ | |
240 | 2 + decode_verifier_maxsz) | |
241 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) | |
242 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ | |
243 | decode_verifier_maxsz) | |
1da177e4 LT |
244 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
245 | nfs4_name_maxsz) | |
6ce18391 BH |
246 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
247 | decode_change_info_maxsz) | |
1da177e4 LT |
248 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
249 | 2 * nfs4_name_maxsz) | |
6ce18391 BH |
250 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
251 | decode_change_info_maxsz + \ | |
252 | decode_change_info_maxsz) | |
1da177e4 LT |
253 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
254 | nfs4_name_maxsz) | |
6ce18391 | 255 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
daccbded | 256 | #define encode_lockowner_maxsz (7) |
9104a55d TM |
257 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
258 | 7 + \ | |
daccbded TM |
259 | 1 + encode_stateid_maxsz + 1 + \ |
260 | encode_lockowner_maxsz) | |
9104a55d TM |
261 | #define decode_lock_denied_maxsz \ |
262 | (8 + decode_lockowner_maxsz) | |
263 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ | |
264 | decode_lock_denied_maxsz) | |
daccbded TM |
265 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
266 | encode_lockowner_maxsz) | |
9104a55d TM |
267 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
268 | decode_lock_denied_maxsz) | |
269 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ | |
270 | encode_stateid_maxsz + \ | |
271 | 4) | |
272 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ | |
273 | decode_stateid_maxsz) | |
d3c7b7cc TM |
274 | #define encode_release_lockowner_maxsz \ |
275 | (op_encode_hdr_maxsz + \ | |
276 | encode_lockowner_maxsz) | |
277 | #define decode_release_lockowner_maxsz \ | |
278 | (op_decode_hdr_maxsz) | |
9104a55d TM |
279 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
280 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) | |
1da177e4 LT |
281 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
282 | 1 + nfs4_name_maxsz + \ | |
94a6d753 | 283 | 1 + \ |
96928206 | 284 | nfs4_fattr_maxsz) |
1da177e4 LT |
285 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
286 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ | |
9104a55d TM |
287 | 1 + 2 + nfs4_name_maxsz + \ |
288 | encode_attrs_maxsz) | |
2cebf828 TM |
289 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
290 | decode_change_info_maxsz + \ | |
291 | nfs4_fattr_bitmap_maxsz) | |
9104a55d TM |
292 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
293 | #define decode_statfs_maxsz (decode_getattr_maxsz) | |
1da177e4 LT |
294 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
295 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) | |
9104a55d TM |
296 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
297 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ | |
9ed5af26 | 298 | nfs4_fattr_bitmap_maxsz + 1 + pagepad_maxsz) |
9104a55d TM |
299 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
300 | encode_stateid_maxsz + 3) | |
301 | #define decode_setacl_maxsz (decode_setattr_maxsz) | |
e6889620 TM |
302 | #define encode_fs_locations_maxsz \ |
303 | (encode_getattr_maxsz) | |
304 | #define decode_fs_locations_maxsz \ | |
9ed5af26 | 305 | (pagepad_maxsz) |
5a5ea0d4 | 306 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
1650add2 | 307 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
9b7b9fcc AA |
308 | |
309 | #if defined(CONFIG_NFS_V4_1) | |
fc931582 | 310 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
d751f748 JR |
311 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
312 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) | |
fc931582 | 313 | |
99fe60d0 BH |
314 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
315 | encode_verifier_maxsz + \ | |
316 | 1 /* co_ownerid.len */ + \ | |
b8fb2f59 JL |
317 | /* eia_clientowner */ \ |
318 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
99fe60d0 BH |
319 | 1 /* flags */ + \ |
320 | 1 /* spa_how */ + \ | |
2031cd1a WAA |
321 | /* max is SP4_MACH_CRED (for now) */ + \ |
322 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
323 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
db8ac8ba WAA |
324 | 1 /* implementation id array of size 1 */ + \ |
325 | 1 /* nii_domain */ + \ | |
326 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
327 | 1 /* nii_name */ + \ | |
d751f748 | 328 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
db8ac8ba | 329 | 3 /* nii_date */) |
99fe60d0 BH |
330 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
331 | 2 /* eir_clientid */ + \ | |
332 | 1 /* eir_sequenceid */ + \ | |
333 | 1 /* eir_flags */ + \ | |
334 | 1 /* spr_how */ + \ | |
2031cd1a WAA |
335 | /* max is SP4_MACH_CRED (for now) */ + \ |
336 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
337 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
99fe60d0 BH |
338 | 2 /* eir_server_owner.so_minor_id */ + \ |
339 | /* eir_server_owner.so_major_id<> */ \ | |
340 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | |
341 | /* eir_server_scope<> */ \ | |
342 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | |
343 | 1 /* eir_server_impl_id array length */ + \ | |
7d2ed9ac WAA |
344 | 1 /* nii_domain */ + \ |
345 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
346 | 1 /* nii_name */ + \ | |
347 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
348 | 3 /* nii_date */) | |
fc931582 AA |
349 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
350 | #define decode_channel_attrs_maxsz (6 + \ | |
351 | 1 /* ca_rdma_ird.len */ + \ | |
352 | 1 /* ca_rdma_ird */) | |
353 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ | |
354 | 2 /* csa_clientid */ + \ | |
355 | 1 /* csa_sequence */ + \ | |
356 | 1 /* csa_flags */ + \ | |
357 | encode_channel_attrs_maxsz + \ | |
358 | encode_channel_attrs_maxsz + \ | |
359 | 1 /* csa_cb_program */ + \ | |
360 | 1 /* csa_sec_parms.len (1) */ + \ | |
361 | 1 /* cb_secflavor (AUTH_SYS) */ + \ | |
362 | 1 /* stamp */ + \ | |
363 | 1 /* machinename.len */ + \ | |
364 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ | |
365 | 1 /* uid */ + \ | |
366 | 1 /* gid */ + \ | |
367 | 1 /* gids.len (0) */) | |
368 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ | |
369 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
370 | 1 /* csr_sequence */ + \ | |
371 | 1 /* csr_flags */ + \ | |
372 | decode_channel_attrs_maxsz + \ | |
373 | decode_channel_attrs_maxsz) | |
7c44f1ae WAA |
374 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
375 | /* bctsa_sessid */ \ | |
376 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
377 | 1 /* bctsa_dir */ + \ | |
378 | 1 /* bctsa_use_conn_in_rdma_mode */) | |
379 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ | |
380 | /* bctsr_sessid */ \ | |
381 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
382 | 1 /* bctsr_dir */ + \ | |
383 | 1 /* bctsr_use_conn_in_rdma_mode */) | |
0f3e66c6 AA |
384 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
385 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) | |
66245539 TM |
386 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
387 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) | |
fc01cea9 AA |
388 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
389 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) | |
390 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ | |
391 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | |
18019753 RL |
392 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
393 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) | |
84c9dee3 CH |
394 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
395 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ | |
396 | 1 /* layout type */ + \ | |
397 | 1 /* maxcount */ + \ | |
398 | 1 /* bitmap size */ + \ | |
399 | 1 /* notification bitmap length */ + \ | |
400 | 1 /* notification bitmap, word 0 */) | |
b1f69b75 AA |
401 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
402 | 1 /* layout type */ + \ | |
403 | 1 /* opaque devaddr4 length */ + \ | |
404 | /* devaddr4 payload is read into page */ \ | |
405 | 1 /* notification bitmap length */ + \ | |
02ef04e4 | 406 | 1 /* notification bitmap, word 0 */ + \ |
9ed5af26 | 407 | pagepad_maxsz /* possible XDR padding */) |
b1f69b75 AA |
408 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
409 | encode_stateid_maxsz) | |
410 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ | |
411 | decode_stateid_maxsz + \ | |
9ed5af26 TM |
412 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + \ |
413 | pagepad_maxsz) | |
863a3c6c AA |
414 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
415 | 2 /* offset */ + \ | |
416 | 2 /* length */ + \ | |
417 | 1 /* reclaim */ + \ | |
418 | encode_stateid_maxsz + \ | |
419 | 1 /* new offset (true) */ + \ | |
420 | 2 /* last byte written */ + \ | |
421 | 1 /* nt_timechanged (false) */ + \ | |
422 | 1 /* layoutupdate4 layout type */ + \ | |
5f919c9f CH |
423 | 1 /* layoutupdate4 opaqueue len */) |
424 | /* the actual content of layoutupdate4 should | |
425 | be allocated by drivers and spliced in | |
426 | using xdr_write_pages */ | |
863a3c6c | 427 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
cbe82603 BH |
428 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
429 | encode_stateid_maxsz + \ | |
6669cb8b TM |
430 | 1 + \ |
431 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) | |
cbe82603 BH |
432 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
433 | 1 + decode_stateid_maxsz) | |
fca78d6d BS |
434 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
435 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz | |
7d974794 BS |
436 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
437 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
438 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) | |
9aeda35f BS |
439 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
440 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
9f79fb48 | 441 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
9b7b9fcc AA |
442 | #else /* CONFIG_NFS_V4_1 */ |
443 | #define encode_sequence_maxsz 0 | |
444 | #define decode_sequence_maxsz 0 | |
cf805165 TM |
445 | #define encode_layoutreturn_maxsz 0 |
446 | #define decode_layoutreturn_maxsz 0 | |
56f487f8 FI |
447 | #define encode_layoutget_maxsz 0 |
448 | #define decode_layoutget_maxsz 0 | |
9b7b9fcc AA |
449 | #endif /* CONFIG_NFS_V4_1 */ |
450 | ||
1da177e4 LT |
451 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
452 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ | |
453 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 454 | encode_sequence_maxsz + \ |
1da177e4 | 455 | encode_putfh_maxsz + \ |
9104a55d | 456 | encode_read_maxsz) |
1da177e4 | 457 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 458 | decode_sequence_maxsz + \ |
1da177e4 | 459 | decode_putfh_maxsz + \ |
9104a55d | 460 | decode_read_maxsz) |
1da177e4 | 461 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 462 | encode_sequence_maxsz + \ |
1da177e4 | 463 | encode_putfh_maxsz + \ |
9104a55d | 464 | encode_readlink_maxsz) |
1da177e4 | 465 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 466 | decode_sequence_maxsz + \ |
1da177e4 | 467 | decode_putfh_maxsz + \ |
9104a55d | 468 | decode_readlink_maxsz) |
1da177e4 | 469 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 470 | encode_sequence_maxsz + \ |
1da177e4 | 471 | encode_putfh_maxsz + \ |
9104a55d | 472 | encode_readdir_maxsz) |
1da177e4 | 473 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 474 | decode_sequence_maxsz + \ |
1da177e4 | 475 | decode_putfh_maxsz + \ |
9104a55d | 476 | decode_readdir_maxsz) |
1da177e4 | 477 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 478 | encode_sequence_maxsz + \ |
1da177e4 | 479 | encode_putfh_maxsz + \ |
9104a55d | 480 | encode_write_maxsz + \ |
4f9838c7 | 481 | encode_getattr_maxsz) |
1da177e4 | 482 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 483 | decode_sequence_maxsz + \ |
1da177e4 | 484 | decode_putfh_maxsz + \ |
9104a55d | 485 | decode_write_maxsz + \ |
4f9838c7 | 486 | decode_getattr_maxsz) |
1da177e4 | 487 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 488 | encode_sequence_maxsz + \ |
1da177e4 | 489 | encode_putfh_maxsz + \ |
8582715e | 490 | encode_commit_maxsz) |
1da177e4 | 491 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 492 | decode_sequence_maxsz + \ |
1da177e4 | 493 | decode_putfh_maxsz + \ |
8582715e | 494 | decode_commit_maxsz) |
1da177e4 | 495 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 496 | encode_sequence_maxsz + \ |
2cebf828 | 497 | encode_putfh_maxsz + \ |
2cebf828 | 498 | encode_open_maxsz + \ |
6168f62c | 499 | encode_access_maxsz + \ |
2cebf828 | 500 | encode_getfh_maxsz + \ |
56f487f8 FI |
501 | encode_getattr_maxsz + \ |
502 | encode_layoutget_maxsz) | |
1da177e4 | 503 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 504 | decode_sequence_maxsz + \ |
2cebf828 | 505 | decode_putfh_maxsz + \ |
2cebf828 | 506 | decode_open_maxsz + \ |
6168f62c | 507 | decode_access_maxsz + \ |
2cebf828 | 508 | decode_getfh_maxsz + \ |
56f487f8 FI |
509 | decode_getattr_maxsz + \ |
510 | decode_layoutget_maxsz) | |
9104a55d TM |
511 | #define NFS4_enc_open_confirm_sz \ |
512 | (compound_encode_hdr_maxsz + \ | |
513 | encode_putfh_maxsz + \ | |
514 | encode_open_confirm_maxsz) | |
515 | #define NFS4_dec_open_confirm_sz \ | |
516 | (compound_decode_hdr_maxsz + \ | |
517 | decode_putfh_maxsz + \ | |
518 | decode_open_confirm_maxsz) | |
1da177e4 | 519 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 520 | encode_sequence_maxsz + \ |
1da177e4 | 521 | encode_putfh_maxsz + \ |
2cebf828 | 522 | encode_open_maxsz + \ |
6168f62c | 523 | encode_access_maxsz + \ |
56f487f8 FI |
524 | encode_getattr_maxsz + \ |
525 | encode_layoutget_maxsz) | |
1da177e4 | 526 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 527 | decode_sequence_maxsz + \ |
1da177e4 | 528 | decode_putfh_maxsz + \ |
2cebf828 | 529 | decode_open_maxsz + \ |
6168f62c | 530 | decode_access_maxsz + \ |
56f487f8 FI |
531 | decode_getattr_maxsz + \ |
532 | decode_layoutget_maxsz) | |
1da177e4 LT |
533 | #define NFS4_enc_open_downgrade_sz \ |
534 | (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 535 | encode_sequence_maxsz + \ |
9104a55d | 536 | encode_putfh_maxsz + \ |
b6808145 | 537 | encode_layoutreturn_maxsz + \ |
3947b74d | 538 | encode_open_downgrade_maxsz) |
1da177e4 LT |
539 | #define NFS4_dec_open_downgrade_sz \ |
540 | (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 541 | decode_sequence_maxsz + \ |
9104a55d | 542 | decode_putfh_maxsz + \ |
b6808145 | 543 | decode_layoutreturn_maxsz + \ |
3947b74d | 544 | decode_open_downgrade_maxsz) |
9104a55d | 545 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 546 | encode_sequence_maxsz + \ |
9104a55d | 547 | encode_putfh_maxsz + \ |
cf805165 | 548 | encode_layoutreturn_maxsz + \ |
9104a55d TM |
549 | encode_close_maxsz + \ |
550 | encode_getattr_maxsz) | |
551 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 552 | decode_sequence_maxsz + \ |
9104a55d | 553 | decode_putfh_maxsz + \ |
cf805165 | 554 | decode_layoutreturn_maxsz + \ |
9104a55d TM |
555 | decode_close_maxsz + \ |
556 | decode_getattr_maxsz) | |
557 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 558 | encode_sequence_maxsz + \ |
9104a55d TM |
559 | encode_putfh_maxsz + \ |
560 | encode_setattr_maxsz + \ | |
561 | encode_getattr_maxsz) | |
562 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 563 | decode_sequence_maxsz + \ |
9104a55d TM |
564 | decode_putfh_maxsz + \ |
565 | decode_setattr_maxsz + \ | |
566 | decode_getattr_maxsz) | |
1da177e4 | 567 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 568 | encode_sequence_maxsz + \ |
1da177e4 LT |
569 | encode_putfh_maxsz + \ |
570 | encode_fsinfo_maxsz) | |
571 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 572 | decode_sequence_maxsz + \ |
1da177e4 LT |
573 | decode_putfh_maxsz + \ |
574 | decode_fsinfo_maxsz) | |
575 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ | |
576 | encode_renew_maxsz) | |
577 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ | |
578 | decode_renew_maxsz) | |
579 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ | |
580 | encode_setclientid_maxsz) | |
581 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ | |
582 | decode_setclientid_maxsz) | |
583 | #define NFS4_enc_setclientid_confirm_sz \ | |
584 | (compound_encode_hdr_maxsz + \ | |
83ca7f5a | 585 | encode_setclientid_confirm_maxsz) |
1da177e4 LT |
586 | #define NFS4_dec_setclientid_confirm_sz \ |
587 | (compound_decode_hdr_maxsz + \ | |
83ca7f5a | 588 | decode_setclientid_confirm_maxsz) |
1da177e4 | 589 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 590 | encode_sequence_maxsz + \ |
1da177e4 | 591 | encode_putfh_maxsz + \ |
9104a55d | 592 | encode_lock_maxsz) |
1da177e4 | 593 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 594 | decode_sequence_maxsz + \ |
1da177e4 | 595 | decode_putfh_maxsz + \ |
9104a55d | 596 | decode_lock_maxsz) |
1da177e4 | 597 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 598 | encode_sequence_maxsz + \ |
1da177e4 | 599 | encode_putfh_maxsz + \ |
9104a55d TM |
600 | encode_lockt_maxsz) |
601 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 602 | decode_sequence_maxsz + \ |
9104a55d TM |
603 | decode_putfh_maxsz + \ |
604 | decode_lockt_maxsz) | |
1da177e4 | 605 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 606 | encode_sequence_maxsz + \ |
1da177e4 | 607 | encode_putfh_maxsz + \ |
9104a55d | 608 | encode_locku_maxsz) |
1da177e4 | 609 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 610 | decode_sequence_maxsz + \ |
1da177e4 | 611 | decode_putfh_maxsz + \ |
9104a55d | 612 | decode_locku_maxsz) |
d3c7b7cc TM |
613 | #define NFS4_enc_release_lockowner_sz \ |
614 | (compound_encode_hdr_maxsz + \ | |
615 | encode_lockowner_maxsz) | |
616 | #define NFS4_dec_release_lockowner_sz \ | |
617 | (compound_decode_hdr_maxsz + \ | |
618 | decode_lockowner_maxsz) | |
1da177e4 | 619 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 620 | encode_sequence_maxsz + \ |
1da177e4 | 621 | encode_putfh_maxsz + \ |
76b32999 TM |
622 | encode_access_maxsz + \ |
623 | encode_getattr_maxsz) | |
1da177e4 | 624 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 625 | decode_sequence_maxsz + \ |
1da177e4 | 626 | decode_putfh_maxsz + \ |
76b32999 TM |
627 | decode_access_maxsz + \ |
628 | decode_getattr_maxsz) | |
1da177e4 | 629 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 630 | encode_sequence_maxsz + \ |
1da177e4 | 631 | encode_putfh_maxsz + \ |
44c99933 CL |
632 | encode_getattr_maxsz + \ |
633 | encode_renew_maxsz) | |
1da177e4 | 634 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 635 | decode_sequence_maxsz + \ |
1da177e4 | 636 | decode_putfh_maxsz + \ |
44c99933 CL |
637 | decode_getattr_maxsz + \ |
638 | decode_renew_maxsz) | |
1da177e4 | 639 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 640 | encode_sequence_maxsz + \ |
1da177e4 LT |
641 | encode_putfh_maxsz + \ |
642 | encode_lookup_maxsz + \ | |
643 | encode_getattr_maxsz + \ | |
644 | encode_getfh_maxsz) | |
645 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 646 | decode_sequence_maxsz + \ |
1da177e4 | 647 | decode_putfh_maxsz + \ |
e6889620 | 648 | decode_lookup_maxsz + \ |
1da177e4 LT |
649 | decode_getattr_maxsz + \ |
650 | decode_getfh_maxsz) | |
5b5faaf6 JL |
651 | #define NFS4_enc_lookupp_sz (compound_encode_hdr_maxsz + \ |
652 | encode_sequence_maxsz + \ | |
653 | encode_putfh_maxsz + \ | |
654 | encode_lookupp_maxsz + \ | |
655 | encode_getattr_maxsz + \ | |
656 | encode_getfh_maxsz) | |
657 | #define NFS4_dec_lookupp_sz (compound_decode_hdr_maxsz + \ | |
658 | decode_sequence_maxsz + \ | |
659 | decode_putfh_maxsz + \ | |
660 | decode_lookupp_maxsz + \ | |
661 | decode_getattr_maxsz + \ | |
662 | decode_getfh_maxsz) | |
1da177e4 | 663 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 664 | encode_sequence_maxsz + \ |
1da177e4 LT |
665 | encode_putrootfh_maxsz + \ |
666 | encode_getattr_maxsz + \ | |
667 | encode_getfh_maxsz) | |
668 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 669 | decode_sequence_maxsz + \ |
1da177e4 LT |
670 | decode_putrootfh_maxsz + \ |
671 | decode_getattr_maxsz + \ | |
672 | decode_getfh_maxsz) | |
673 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 674 | encode_sequence_maxsz + \ |
1da177e4 | 675 | encode_putfh_maxsz + \ |
778d2817 | 676 | encode_remove_maxsz) |
1da177e4 | 677 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 678 | decode_sequence_maxsz + \ |
1da177e4 | 679 | decode_putfh_maxsz + \ |
778d2817 | 680 | decode_remove_maxsz) |
1da177e4 | 681 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 682 | encode_sequence_maxsz + \ |
1da177e4 LT |
683 | encode_putfh_maxsz + \ |
684 | encode_savefh_maxsz + \ | |
685 | encode_putfh_maxsz + \ | |
778d2817 | 686 | encode_rename_maxsz) |
1da177e4 | 687 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 688 | decode_sequence_maxsz + \ |
1da177e4 LT |
689 | decode_putfh_maxsz + \ |
690 | decode_savefh_maxsz + \ | |
691 | decode_putfh_maxsz + \ | |
778d2817 | 692 | decode_rename_maxsz) |
1da177e4 | 693 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 694 | encode_sequence_maxsz + \ |
1da177e4 LT |
695 | encode_putfh_maxsz + \ |
696 | encode_savefh_maxsz + \ | |
697 | encode_putfh_maxsz + \ | |
91ba2eee | 698 | encode_link_maxsz + \ |
91ba2eee | 699 | encode_restorefh_maxsz + \ |
a9f6991b | 700 | encode_getattr_maxsz) |
1da177e4 | 701 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 702 | decode_sequence_maxsz + \ |
1da177e4 LT |
703 | decode_putfh_maxsz + \ |
704 | decode_savefh_maxsz + \ | |
705 | decode_putfh_maxsz + \ | |
91ba2eee | 706 | decode_link_maxsz + \ |
91ba2eee TM |
707 | decode_restorefh_maxsz + \ |
708 | decode_getattr_maxsz) | |
1da177e4 | 709 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 710 | encode_sequence_maxsz + \ |
1da177e4 LT |
711 | encode_putfh_maxsz + \ |
712 | encode_symlink_maxsz + \ | |
713 | encode_getattr_maxsz + \ | |
714 | encode_getfh_maxsz) | |
715 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 716 | decode_sequence_maxsz + \ |
1da177e4 LT |
717 | decode_putfh_maxsz + \ |
718 | decode_symlink_maxsz + \ | |
719 | decode_getattr_maxsz + \ | |
720 | decode_getfh_maxsz) | |
721 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 722 | encode_sequence_maxsz + \ |
1da177e4 LT |
723 | encode_putfh_maxsz + \ |
724 | encode_create_maxsz + \ | |
56ae19f3 | 725 | encode_getfh_maxsz + \ |
56ae19f3 | 726 | encode_getattr_maxsz) |
1da177e4 | 727 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 728 | decode_sequence_maxsz + \ |
1da177e4 LT |
729 | decode_putfh_maxsz + \ |
730 | decode_create_maxsz + \ | |
56ae19f3 | 731 | decode_getfh_maxsz + \ |
56ae19f3 | 732 | decode_getattr_maxsz) |
1da177e4 | 733 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 734 | encode_sequence_maxsz + \ |
1da177e4 LT |
735 | encode_putfh_maxsz + \ |
736 | encode_getattr_maxsz) | |
737 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 738 | decode_sequence_maxsz + \ |
1da177e4 LT |
739 | decode_putfh_maxsz + \ |
740 | decode_getattr_maxsz) | |
741 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 742 | encode_sequence_maxsz + \ |
1da177e4 | 743 | encode_putfh_maxsz + \ |
9104a55d | 744 | encode_statfs_maxsz) |
1da177e4 | 745 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 746 | decode_sequence_maxsz + \ |
1da177e4 | 747 | decode_putfh_maxsz + \ |
9104a55d | 748 | decode_statfs_maxsz) |
1da177e4 | 749 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 750 | encode_sequence_maxsz + \ |
ab91f264 | 751 | encode_putfh_maxsz + \ |
1da177e4 LT |
752 | encode_getattr_maxsz) |
753 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 754 | decode_sequence_maxsz + \ |
ab91f264 | 755 | decode_putfh_maxsz + \ |
1da177e4 LT |
756 | decode_getattr_maxsz) |
757 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 758 | encode_sequence_maxsz + \ |
1da177e4 | 759 | encode_putfh_maxsz + \ |
586f1c39 | 760 | encode_layoutreturn_maxsz + \ |
fa178f29 TM |
761 | encode_delegreturn_maxsz + \ |
762 | encode_getattr_maxsz) | |
1da177e4 | 763 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 764 | decode_sequence_maxsz + \ |
d8434d4c | 765 | decode_putfh_maxsz + \ |
586f1c39 | 766 | decode_layoutreturn_maxsz + \ |
fa178f29 TM |
767 | decode_delegreturn_maxsz + \ |
768 | decode_getattr_maxsz) | |
029d105e | 769 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 770 | encode_sequence_maxsz + \ |
029d105e | 771 | encode_putfh_maxsz + \ |
9104a55d | 772 | encode_getacl_maxsz) |
029d105e | 773 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 774 | decode_sequence_maxsz + \ |
029d105e | 775 | decode_putfh_maxsz + \ |
9104a55d | 776 | decode_getacl_maxsz) |
23ec6965 | 777 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 778 | encode_sequence_maxsz + \ |
23ec6965 | 779 | encode_putfh_maxsz + \ |
9104a55d | 780 | encode_setacl_maxsz) |
23ec6965 | 781 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 782 | decode_sequence_maxsz + \ |
23ec6965 | 783 | decode_putfh_maxsz + \ |
9104a55d | 784 | decode_setacl_maxsz) |
683b57b4 TM |
785 | #define NFS4_enc_fs_locations_sz \ |
786 | (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 787 | encode_sequence_maxsz + \ |
683b57b4 | 788 | encode_putfh_maxsz + \ |
e6889620 | 789 | encode_lookup_maxsz + \ |
b03d735b CL |
790 | encode_fs_locations_maxsz + \ |
791 | encode_renew_maxsz) | |
683b57b4 TM |
792 | #define NFS4_dec_fs_locations_sz \ |
793 | (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 794 | decode_sequence_maxsz + \ |
683b57b4 | 795 | decode_putfh_maxsz + \ |
e6889620 | 796 | decode_lookup_maxsz + \ |
b03d735b CL |
797 | decode_fs_locations_maxsz + \ |
798 | decode_renew_maxsz) | |
5a5ea0d4 BS |
799 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
800 | encode_sequence_maxsz + \ | |
801 | encode_putfh_maxsz + \ | |
802 | encode_secinfo_maxsz) | |
803 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ | |
804 | decode_sequence_maxsz + \ | |
805 | decode_putfh_maxsz + \ | |
806 | decode_secinfo_maxsz) | |
44c99933 CL |
807 | #define NFS4_enc_fsid_present_sz \ |
808 | (compound_encode_hdr_maxsz + \ | |
809 | encode_sequence_maxsz + \ | |
810 | encode_putfh_maxsz + \ | |
811 | encode_getfh_maxsz + \ | |
812 | encode_renew_maxsz) | |
813 | #define NFS4_dec_fsid_present_sz \ | |
814 | (compound_decode_hdr_maxsz + \ | |
815 | decode_sequence_maxsz + \ | |
816 | decode_putfh_maxsz + \ | |
817 | decode_getfh_maxsz + \ | |
818 | decode_renew_maxsz) | |
99fe60d0 | 819 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
820 | #define NFS4_enc_bind_conn_to_session_sz \ |
821 | (compound_encode_hdr_maxsz + \ | |
822 | encode_bind_conn_to_session_maxsz) | |
823 | #define NFS4_dec_bind_conn_to_session_sz \ | |
824 | (compound_decode_hdr_maxsz + \ | |
825 | decode_bind_conn_to_session_maxsz) | |
99fe60d0 BH |
826 | #define NFS4_enc_exchange_id_sz \ |
827 | (compound_encode_hdr_maxsz + \ | |
828 | encode_exchange_id_maxsz) | |
829 | #define NFS4_dec_exchange_id_sz \ | |
830 | (compound_decode_hdr_maxsz + \ | |
831 | decode_exchange_id_maxsz) | |
fc931582 AA |
832 | #define NFS4_enc_create_session_sz \ |
833 | (compound_encode_hdr_maxsz + \ | |
834 | encode_create_session_maxsz) | |
835 | #define NFS4_dec_create_session_sz \ | |
836 | (compound_decode_hdr_maxsz + \ | |
837 | decode_create_session_maxsz) | |
0f3e66c6 AA |
838 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
839 | encode_destroy_session_maxsz) | |
840 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ | |
841 | decode_destroy_session_maxsz) | |
66245539 TM |
842 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
843 | encode_destroy_clientid_maxsz) | |
844 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ | |
845 | decode_destroy_clientid_maxsz) | |
fc01cea9 AA |
846 | #define NFS4_enc_sequence_sz \ |
847 | (compound_decode_hdr_maxsz + \ | |
848 | encode_sequence_maxsz) | |
849 | #define NFS4_dec_sequence_sz \ | |
850 | (compound_decode_hdr_maxsz + \ | |
851 | decode_sequence_maxsz) | |
0efb01b2 | 852 | #endif |
2050f0cc AA |
853 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
854 | encode_sequence_maxsz + \ | |
855 | encode_putrootfh_maxsz + \ | |
856 | encode_fsinfo_maxsz) | |
857 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ | |
858 | decode_sequence_maxsz + \ | |
859 | decode_putrootfh_maxsz + \ | |
860 | decode_fsinfo_maxsz) | |
0efb01b2 | 861 | #if defined(CONFIG_NFS_V4_1) |
18019753 RL |
862 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
863 | encode_sequence_maxsz + \ | |
864 | encode_reclaim_complete_maxsz) | |
865 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ | |
866 | decode_sequence_maxsz + \ | |
867 | decode_reclaim_complete_maxsz) | |
b1f69b75 AA |
868 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
869 | encode_sequence_maxsz +\ | |
870 | encode_getdeviceinfo_maxsz) | |
871 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ | |
872 | decode_sequence_maxsz + \ | |
873 | decode_getdeviceinfo_maxsz) | |
874 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ | |
875 | encode_sequence_maxsz + \ | |
876 | encode_putfh_maxsz + \ | |
877 | encode_layoutget_maxsz) | |
878 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ | |
879 | decode_sequence_maxsz + \ | |
880 | decode_putfh_maxsz + \ | |
881 | decode_layoutget_maxsz) | |
863a3c6c AA |
882 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
883 | encode_sequence_maxsz +\ | |
884 | encode_putfh_maxsz + \ | |
885 | encode_layoutcommit_maxsz + \ | |
886 | encode_getattr_maxsz) | |
887 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ | |
888 | decode_sequence_maxsz + \ | |
889 | decode_putfh_maxsz + \ | |
890 | decode_layoutcommit_maxsz + \ | |
891 | decode_getattr_maxsz) | |
cbe82603 BH |
892 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
893 | encode_sequence_maxsz + \ | |
894 | encode_putfh_maxsz + \ | |
895 | encode_layoutreturn_maxsz) | |
896 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ | |
897 | decode_sequence_maxsz + \ | |
898 | decode_putfh_maxsz + \ | |
899 | decode_layoutreturn_maxsz) | |
fca78d6d BS |
900 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
901 | encode_sequence_maxsz + \ | |
902 | encode_putrootfh_maxsz +\ | |
903 | encode_secinfo_no_name_maxsz) | |
904 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ | |
905 | decode_sequence_maxsz + \ | |
906 | decode_putrootfh_maxsz + \ | |
907 | decode_secinfo_no_name_maxsz) | |
7d974794 BS |
908 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
909 | encode_sequence_maxsz + \ | |
910 | encode_test_stateid_maxsz) | |
911 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ | |
912 | decode_sequence_maxsz + \ | |
913 | decode_test_stateid_maxsz) | |
9aeda35f BS |
914 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
915 | encode_sequence_maxsz + \ | |
916 | encode_free_stateid_maxsz) | |
917 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ | |
918 | decode_sequence_maxsz + \ | |
919 | decode_free_stateid_maxsz) | |
2449ea2e AB |
920 | |
921 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | |
922 | compound_encode_hdr_maxsz + | |
923 | encode_sequence_maxsz + | |
924 | encode_putfh_maxsz + | |
925 | encode_getattr_maxsz) * | |
926 | XDR_UNIT); | |
927 | ||
928 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | |
929 | compound_decode_hdr_maxsz + | |
930 | decode_sequence_maxsz + | |
931 | decode_putfh_maxsz) * | |
932 | XDR_UNIT); | |
f1c097be AA |
933 | |
934 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + | |
935 | compound_decode_hdr_maxsz + | |
936 | decode_sequence_maxsz) * | |
937 | XDR_UNIT); | |
938 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); | |
99fe60d0 | 939 | #endif /* CONFIG_NFS_V4_1 */ |
1da177e4 | 940 | |
bca79478 TM |
941 | static const umode_t nfs_type2fmt[] = { |
942 | [NF4BAD] = 0, | |
943 | [NF4REG] = S_IFREG, | |
944 | [NF4DIR] = S_IFDIR, | |
945 | [NF4BLK] = S_IFBLK, | |
946 | [NF4CHR] = S_IFCHR, | |
947 | [NF4LNK] = S_IFLNK, | |
948 | [NF4SOCK] = S_IFSOCK, | |
949 | [NF4FIFO] = S_IFIFO, | |
950 | [NF4ATTRDIR] = 0, | |
951 | [NF4NAMEDATTR] = 0, | |
1da177e4 LT |
952 | }; |
953 | ||
954 | struct compound_hdr { | |
955 | int32_t status; | |
956 | uint32_t nops; | |
d017931c | 957 | __be32 * nops_p; |
1da177e4 LT |
958 | uint32_t taglen; |
959 | char * tag; | |
0c4e8c18 | 960 | uint32_t replen; /* expected reply words */ |
66cc0429 | 961 | u32 minorversion; |
1da177e4 LT |
962 | }; |
963 | ||
13c65ce9 BH |
964 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
965 | { | |
966 | __be32 *p = xdr_reserve_space(xdr, nbytes); | |
967 | BUG_ON(!p); | |
968 | return p; | |
969 | } | |
1da177e4 | 970 | |
cb17e556 TM |
971 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
972 | { | |
ab6e9aaf | 973 | WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); |
cb17e556 TM |
974 | } |
975 | ||
1da177e4 LT |
976 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
977 | { | |
ab6e9aaf | 978 | WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0); |
1da177e4 LT |
979 | } |
980 | ||
4ade9821 TM |
981 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
982 | { | |
ab6e9aaf | 983 | WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0); |
4ade9821 TM |
984 | } |
985 | ||
ff2eb681 TM |
986 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
987 | { | |
ab6e9aaf | 988 | WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0); |
ff2eb681 TM |
989 | } |
990 | ||
37c88763 TM |
991 | static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr, |
992 | const __u32 *bitmap, size_t len) | |
993 | { | |
994 | ssize_t ret; | |
995 | ||
996 | /* Trim empty words */ | |
997 | while (len > 0 && bitmap[len-1] == 0) | |
998 | len--; | |
999 | ret = xdr_stream_encode_uint32_array(xdr, bitmap, len); | |
1000 | if (WARN_ON_ONCE(ret < 0)) | |
1001 | return ret; | |
1002 | return len; | |
1003 | } | |
1004 | ||
1005 | static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask, | |
1006 | __u32 *res, size_t len) | |
1007 | { | |
1008 | size_t i; | |
1009 | __u32 tmp; | |
1010 | ||
1011 | while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0)) | |
1012 | len--; | |
1013 | for (i = len; i-- > 0;) { | |
1014 | tmp = bitmap[i] & mask[i]; | |
1015 | res[i] = tmp; | |
1016 | } | |
1017 | return len; | |
1018 | } | |
1019 | ||
4ade9821 TM |
1020 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
1021 | const struct nfs_seqid *seqid) | |
1022 | { | |
a6796419 TM |
1023 | if (seqid != NULL) |
1024 | encode_uint32(xdr, seqid->sequence->counter); | |
1025 | else | |
1026 | encode_uint32(xdr, 0); | |
4ade9821 TM |
1027 | } |
1028 | ||
0c4e8c18 BH |
1029 | static void encode_compound_hdr(struct xdr_stream *xdr, |
1030 | struct rpc_rqst *req, | |
1031 | struct compound_hdr *hdr) | |
1da177e4 | 1032 | { |
8687b63a | 1033 | __be32 *p; |
0c4e8c18 BH |
1034 | |
1035 | /* initialize running count of expected bytes in reply. | |
1036 | * NOTE: the replied tag SHOULD be the same is the one sent, | |
1037 | * but this is not required as a MUST for the server to do so. */ | |
cf500bac | 1038 | hdr->replen = 3 + hdr->taglen; |
1da177e4 | 1039 | |
7fc38846 | 1040 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
6fdfb0bc TM |
1041 | encode_string(xdr, hdr->taglen, hdr->tag); |
1042 | p = reserve_space(xdr, 8); | |
e75bc1c8 | 1043 | *p++ = cpu_to_be32(hdr->minorversion); |
d017931c | 1044 | hdr->nops_p = p; |
34558513 | 1045 | *p = cpu_to_be32(hdr->nops); |
d017931c AA |
1046 | } |
1047 | ||
ab19b481 TM |
1048 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
1049 | uint32_t replen, | |
1050 | struct compound_hdr *hdr) | |
1051 | { | |
1052 | encode_uint32(xdr, op); | |
1053 | hdr->nops++; | |
1054 | hdr->replen += replen; | |
1055 | } | |
1056 | ||
d017931c AA |
1057 | static void encode_nops(struct compound_hdr *hdr) |
1058 | { | |
7fc38846 | 1059 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
d017931c | 1060 | *hdr->nops_p = htonl(hdr->nops); |
1da177e4 LT |
1061 | } |
1062 | ||
ea9d23f5 TM |
1063 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
1064 | { | |
2d2f24ad | 1065 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
ea9d23f5 TM |
1066 | } |
1067 | ||
1da177e4 LT |
1068 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
1069 | { | |
cb17e556 | 1070 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
1da177e4 LT |
1071 | } |
1072 | ||
36b3743f | 1073 | static __be32 * |
e7d4b05c | 1074 | xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t) |
36b3743f | 1075 | { |
a3167dac | 1076 | p = xdr_encode_hyper(p, t->tv_sec); |
36b3743f TM |
1077 | *p++ = cpu_to_be32(t->tv_nsec); |
1078 | return p; | |
1079 | } | |
1080 | ||
aa9c2669 DQ |
1081 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
1082 | const struct nfs4_label *label, | |
28cf22d0 | 1083 | const umode_t *umask, |
5334c5bd | 1084 | const struct nfs_server *server, |
28cf22d0 | 1085 | const uint32_t attrmask[]) |
1da177e4 LT |
1086 | { |
1087 | char owner_name[IDMAP_NAMESZ]; | |
1088 | char owner_group[IDMAP_NAMESZ]; | |
1089 | int owner_namelen = 0; | |
1090 | int owner_grouplen = 0; | |
8687b63a | 1091 | __be32 *p; |
d7067b2d | 1092 | uint32_t len = 0; |
d7067b2d | 1093 | uint32_t bmval[3] = { 0 }; |
1da177e4 LT |
1094 | |
1095 | /* | |
1096 | * We reserve enough space to write the entire attribute buffer at once. | |
1da177e4 | 1097 | */ |
28cf22d0 | 1098 | if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) { |
d7067b2d | 1099 | bmval[0] |= FATTR4_WORD0_SIZE; |
1da177e4 | 1100 | len += 8; |
d7067b2d TM |
1101 | } |
1102 | if (iap->ia_valid & ATTR_MODE) { | |
28cf22d0 | 1103 | if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) { |
dff25ddb AG |
1104 | bmval[2] |= FATTR4_WORD2_MODE_UMASK; |
1105 | len += 8; | |
28cf22d0 | 1106 | } else if (attrmask[1] & FATTR4_WORD1_MODE) { |
dff25ddb AG |
1107 | bmval[1] |= FATTR4_WORD1_MODE; |
1108 | len += 4; | |
1109 | } | |
d7067b2d | 1110 | } |
28cf22d0 | 1111 | if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) { |
e4fd72a1 | 1112 | owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); |
1da177e4 | 1113 | if (owner_namelen < 0) { |
fe82a183 | 1114 | dprintk("nfs: couldn't resolve uid %d to string\n", |
e5782076 | 1115 | from_kuid(&init_user_ns, iap->ia_uid)); |
1da177e4 LT |
1116 | /* XXX */ |
1117 | strcpy(owner_name, "nobody"); | |
1118 | owner_namelen = sizeof("nobody") - 1; | |
1119 | /* goto out; */ | |
1120 | } | |
d7067b2d | 1121 | bmval[1] |= FATTR4_WORD1_OWNER; |
1da177e4 LT |
1122 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
1123 | } | |
28cf22d0 TM |
1124 | if ((iap->ia_valid & ATTR_GID) && |
1125 | (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) { | |
e4fd72a1 | 1126 | owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); |
1da177e4 | 1127 | if (owner_grouplen < 0) { |
fe82a183 | 1128 | dprintk("nfs: couldn't resolve gid %d to string\n", |
e5782076 | 1129 | from_kgid(&init_user_ns, iap->ia_gid)); |
1da177e4 LT |
1130 | strcpy(owner_group, "nobody"); |
1131 | owner_grouplen = sizeof("nobody") - 1; | |
1132 | /* goto out; */ | |
1133 | } | |
d7067b2d | 1134 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
1da177e4 LT |
1135 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
1136 | } | |
28cf22d0 TM |
1137 | if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
1138 | if (iap->ia_valid & ATTR_ATIME_SET) { | |
1139 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | |
36b3743f | 1140 | len += 4 + (nfstime4_maxsz << 2); |
28cf22d0 TM |
1141 | } else if (iap->ia_valid & ATTR_ATIME) { |
1142 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | |
1143 | len += 4; | |
1144 | } | |
d7067b2d | 1145 | } |
28cf22d0 TM |
1146 | if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
1147 | if (iap->ia_valid & ATTR_MTIME_SET) { | |
1148 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | |
36b3743f | 1149 | len += 4 + (nfstime4_maxsz << 2); |
28cf22d0 TM |
1150 | } else if (iap->ia_valid & ATTR_MTIME) { |
1151 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | |
1152 | len += 4; | |
1153 | } | |
5334c5bd KM |
1154 | } |
1155 | ||
28cf22d0 | 1156 | if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
b4a2cf76 | 1157 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
d7067b2d | 1158 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
b4a2cf76 TM |
1159 | } |
1160 | ||
40a3426c TM |
1161 | xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval)); |
1162 | xdr_stream_encode_opaque_inline(xdr, (void **)&p, len); | |
1da177e4 | 1163 | |
d7067b2d | 1164 | if (bmval[0] & FATTR4_WORD0_SIZE) |
b95be5a9 | 1165 | p = xdr_encode_hyper(p, iap->ia_size); |
d7067b2d | 1166 | if (bmval[1] & FATTR4_WORD1_MODE) |
e75bc1c8 | 1167 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
d7067b2d | 1168 | if (bmval[1] & FATTR4_WORD1_OWNER) |
811652bd | 1169 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
d7067b2d | 1170 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
811652bd | 1171 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
d7067b2d TM |
1172 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
1173 | if (iap->ia_valid & ATTR_ATIME_SET) { | |
1174 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | |
e7d4b05c | 1175 | p = xdr_encode_nfstime4(p, &iap->ia_atime); |
d7067b2d TM |
1176 | } else |
1177 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | |
1da177e4 | 1178 | } |
d7067b2d TM |
1179 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
1180 | if (iap->ia_valid & ATTR_MTIME_SET) { | |
1181 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | |
e7d4b05c | 1182 | p = xdr_encode_nfstime4(p, &iap->ia_mtime); |
d7067b2d TM |
1183 | } else |
1184 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | |
1da177e4 | 1185 | } |
e2751463 | 1186 | if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
aa9c2669 DQ |
1187 | *p++ = cpu_to_be32(label->lfs); |
1188 | *p++ = cpu_to_be32(label->pi); | |
1189 | *p++ = cpu_to_be32(label->len); | |
1190 | p = xdr_encode_opaque_fixed(p, label->label, label->len); | |
1191 | } | |
dff25ddb AG |
1192 | if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { |
1193 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); | |
1194 | *p++ = cpu_to_be32(*umask); | |
1195 | } | |
6c0195a4 | 1196 | |
1da177e4 | 1197 | /* out: */ |
1da177e4 LT |
1198 | } |
1199 | ||
cf8cdbe5 | 1200 | static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr) |
1da177e4 | 1201 | { |
475d4ba0 TM |
1202 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
1203 | encode_uint32(xdr, access); | |
1da177e4 LT |
1204 | } |
1205 | ||
cf8cdbe5 | 1206 | static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1207 | { |
ab19b481 | 1208 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
4ade9821 | 1209 | encode_nfs4_seqid(xdr, arg->seqid); |
566fcec6 | 1210 | encode_nfs4_stateid(xdr, &arg->stateid); |
1da177e4 LT |
1211 | } |
1212 | ||
0b7c0153 | 1213 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr) |
1da177e4 | 1214 | { |
8687b63a | 1215 | __be32 *p; |
6c0195a4 | 1216 | |
475d4ba0 TM |
1217 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
1218 | p = reserve_space(xdr, 12); | |
b95be5a9 | 1219 | p = xdr_encode_hyper(p, args->offset); |
34558513 | 1220 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1221 | } |
1222 | ||
cf8cdbe5 | 1223 | static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr) |
1da177e4 | 1224 | { |
8687b63a | 1225 | __be32 *p; |
6c0195a4 | 1226 | |
475d4ba0 TM |
1227 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
1228 | encode_uint32(xdr, create->ftype); | |
1da177e4 LT |
1229 | |
1230 | switch (create->ftype) { | |
1231 | case NF4LNK: | |
13c65ce9 | 1232 | p = reserve_space(xdr, 4); |
34558513 | 1233 | *p = cpu_to_be32(create->u.symlink.len); |
2fcc213a CL |
1234 | xdr_write_pages(xdr, create->u.symlink.pages, 0, |
1235 | create->u.symlink.len); | |
1236 | xdr->buf->flags |= XDRBUF_WRITE; | |
1da177e4 LT |
1237 | break; |
1238 | ||
1239 | case NF4BLK: case NF4CHR: | |
13c65ce9 | 1240 | p = reserve_space(xdr, 8); |
e75bc1c8 | 1241 | *p++ = cpu_to_be32(create->u.device.specdata1); |
34558513 | 1242 | *p = cpu_to_be32(create->u.device.specdata2); |
1da177e4 LT |
1243 | break; |
1244 | ||
1245 | default: | |
1246 | break; | |
1247 | } | |
1248 | ||
811652bd | 1249 | encode_string(xdr, create->name->len, create->name->name); |
28cf22d0 TM |
1250 | encode_attrs(xdr, create->attrs, create->label, &create->umask, |
1251 | create->server, create->server->attr_bitmask); | |
1da177e4 LT |
1252 | } |
1253 | ||
37c88763 TM |
1254 | static void encode_getattr(struct xdr_stream *xdr, |
1255 | const __u32 *bitmap, const __u32 *mask, size_t len, | |
1256 | struct compound_hdr *hdr) | |
dae100c2 | 1257 | { |
37c88763 | 1258 | __u32 masked_bitmap[nfs4_fattr_bitmap_maxsz]; |
dae100c2 | 1259 | |
ab19b481 | 1260 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
37c88763 TM |
1261 | if (mask) { |
1262 | if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap))) | |
1263 | len = ARRAY_SIZE(masked_bitmap); | |
1264 | len = mask_bitmap4(bitmap, mask, masked_bitmap, len); | |
1265 | bitmap = masked_bitmap; | |
dae100c2 | 1266 | } |
37c88763 | 1267 | xdr_encode_bitmap4(xdr, bitmap, len); |
dae100c2 FI |
1268 | } |
1269 | ||
cf8cdbe5 | 1270 | static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
1da177e4 | 1271 | { |
37c88763 TM |
1272 | encode_getattr(xdr, nfs4_fattr_bitmap, bitmask, |
1273 | ARRAY_SIZE(nfs4_fattr_bitmap), hdr); | |
1da177e4 LT |
1274 | } |
1275 | ||
88034c3d | 1276 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
1549210f | 1277 | const u32 *open_bitmap, |
88034c3d AA |
1278 | struct compound_hdr *hdr) |
1279 | { | |
37c88763 | 1280 | encode_getattr(xdr, open_bitmap, bitmask, 3, hdr); |
88034c3d AA |
1281 | } |
1282 | ||
cf8cdbe5 | 1283 | static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
1da177e4 | 1284 | { |
37c88763 TM |
1285 | encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask, |
1286 | ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr); | |
1da177e4 LT |
1287 | } |
1288 | ||
cf8cdbe5 | 1289 | static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
830b8e33 | 1290 | { |
37c88763 TM |
1291 | encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask, |
1292 | ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr); | |
830b8e33 MN |
1293 | } |
1294 | ||
cf8cdbe5 | 1295 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1296 | { |
ab19b481 | 1297 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
1da177e4 LT |
1298 | } |
1299 | ||
cf8cdbe5 | 1300 | static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1301 | { |
ab19b481 | 1302 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
6fdfb0bc | 1303 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1304 | } |
1305 | ||
911d1aaf TM |
1306 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
1307 | { | |
f44106e2 | 1308 | if (fl->fl_type == F_RDLCK) |
911d1aaf TM |
1309 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
1310 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; | |
1311 | } | |
1312 | ||
1313 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) | |
1314 | { | |
1315 | if (fl->fl_end == OFFSET_MAX) | |
1316 | return ~(uint64_t)0; | |
1317 | return fl->fl_end - fl->fl_start + 1; | |
1318 | } | |
1319 | ||
daccbded TM |
1320 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
1321 | { | |
1322 | __be32 *p; | |
1323 | ||
d035c36c | 1324 | p = reserve_space(xdr, 32); |
daccbded | 1325 | p = xdr_encode_hyper(p, lowner->clientid); |
d035c36c | 1326 | *p++ = cpu_to_be32(20); |
daccbded | 1327 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
d035c36c | 1328 | *p++ = cpu_to_be32(lowner->s_dev); |
daccbded TM |
1329 | xdr_encode_hyper(p, lowner->id); |
1330 | } | |
1331 | ||
1da177e4 LT |
1332 | /* |
1333 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 | |
1334 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 | |
1335 | */ | |
cf8cdbe5 | 1336 | static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr) |
1da177e4 | 1337 | { |
8687b63a | 1338 | __be32 *p; |
1da177e4 | 1339 | |
475d4ba0 TM |
1340 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
1341 | p = reserve_space(xdr, 28); | |
e75bc1c8 BH |
1342 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
1343 | *p++ = cpu_to_be32(args->reclaim); | |
b95be5a9 BH |
1344 | p = xdr_encode_hyper(p, args->fl->fl_start); |
1345 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | |
34558513 | 1346 | *p = cpu_to_be32(args->new_lock_owner); |
911d1aaf | 1347 | if (args->new_lock_owner){ |
4ade9821 | 1348 | encode_nfs4_seqid(xdr, args->open_seqid); |
425c1d4e | 1349 | encode_nfs4_stateid(xdr, &args->open_stateid); |
4ade9821 | 1350 | encode_nfs4_seqid(xdr, args->lock_seqid); |
daccbded | 1351 | encode_lockowner(xdr, &args->lock_owner); |
1da177e4 LT |
1352 | } |
1353 | else { | |
425c1d4e | 1354 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
4ade9821 | 1355 | encode_nfs4_seqid(xdr, args->lock_seqid); |
1da177e4 | 1356 | } |
1da177e4 LT |
1357 | } |
1358 | ||
cf8cdbe5 | 1359 | static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr) |
1da177e4 | 1360 | { |
8687b63a | 1361 | __be32 *p; |
1da177e4 | 1362 | |
475d4ba0 TM |
1363 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
1364 | p = reserve_space(xdr, 20); | |
e75bc1c8 | 1365 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
b95be5a9 BH |
1366 | p = xdr_encode_hyper(p, args->fl->fl_start); |
1367 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | |
daccbded | 1368 | encode_lockowner(xdr, &args->lock_owner); |
1da177e4 LT |
1369 | } |
1370 | ||
cf8cdbe5 | 1371 | static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr) |
1da177e4 | 1372 | { |
8687b63a | 1373 | __be32 *p; |
1da177e4 | 1374 | |
475d4ba0 TM |
1375 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
1376 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); | |
4ade9821 | 1377 | encode_nfs4_seqid(xdr, args->seqid); |
425c1d4e | 1378 | encode_nfs4_stateid(xdr, &args->stateid); |
ea9d23f5 | 1379 | p = reserve_space(xdr, 16); |
b95be5a9 | 1380 | p = xdr_encode_hyper(p, args->fl->fl_start); |
34558513 | 1381 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
1da177e4 LT |
1382 | } |
1383 | ||
d3c7b7cc TM |
1384 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
1385 | { | |
ab19b481 | 1386 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
d3c7b7cc | 1387 | encode_lockowner(xdr, lowner); |
d3c7b7cc TM |
1388 | } |
1389 | ||
cf8cdbe5 | 1390 | static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1391 | { |
ab19b481 | 1392 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
6fdfb0bc | 1393 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1394 | } |
1395 | ||
5b5faaf6 JL |
1396 | static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1397 | { | |
1398 | encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr); | |
1399 | } | |
1400 | ||
6ae37339 | 1401 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
1da177e4 | 1402 | { |
8687b63a | 1403 | __be32 *p; |
1da177e4 | 1404 | |
13c65ce9 | 1405 | p = reserve_space(xdr, 8); |
6ae37339 | 1406 | *p++ = cpu_to_be32(share_access); |
34558513 | 1407 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
1da177e4 LT |
1408 | } |
1409 | ||
1410 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1411 | { | |
8687b63a | 1412 | __be32 *p; |
1da177e4 LT |
1413 | /* |
1414 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, | |
1415 | * owner 4 = 32 | |
1416 | */ | |
4ade9821 | 1417 | encode_nfs4_seqid(xdr, arg->seqid); |
6ae37339 | 1418 | encode_share_access(xdr, arg->share_access); |
95b72eb0 | 1419 | p = reserve_space(xdr, 36); |
b95be5a9 | 1420 | p = xdr_encode_hyper(p, arg->clientid); |
95b72eb0 | 1421 | *p++ = cpu_to_be32(24); |
93f0cf25 | 1422 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
d035c36c | 1423 | *p++ = cpu_to_be32(arg->server->s_dev); |
95b72eb0 TM |
1424 | *p++ = cpu_to_be32(arg->id.uniquifier); |
1425 | xdr_encode_hyper(p, arg->id.create_time); | |
1da177e4 LT |
1426 | } |
1427 | ||
1428 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1429 | { | |
8687b63a | 1430 | __be32 *p; |
1da177e4 | 1431 | |
13c65ce9 | 1432 | p = reserve_space(xdr, 4); |
549b19cc TM |
1433 | switch(arg->createmode) { |
1434 | case NFS4_CREATE_UNCHECKED: | |
34558513 | 1435 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
28cf22d0 TM |
1436 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
1437 | arg->server, arg->server->attr_bitmask); | |
05d564fe | 1438 | break; |
549b19cc TM |
1439 | case NFS4_CREATE_GUARDED: |
1440 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | |
28cf22d0 TM |
1441 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
1442 | arg->server, arg->server->attr_bitmask); | |
549b19cc TM |
1443 | break; |
1444 | case NFS4_CREATE_EXCLUSIVE: | |
1445 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | |
1446 | encode_nfs4_verifier(xdr, &arg->u.verifier); | |
1447 | break; | |
1448 | case NFS4_CREATE_EXCLUSIVE4_1: | |
1449 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | |
1450 | encode_nfs4_verifier(xdr, &arg->u.verifier); | |
28cf22d0 TM |
1451 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
1452 | arg->server, arg->server->exclcreat_bitmask); | |
1da177e4 LT |
1453 | } |
1454 | } | |
1455 | ||
1456 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1457 | { | |
8687b63a | 1458 | __be32 *p; |
1da177e4 | 1459 | |
13c65ce9 | 1460 | p = reserve_space(xdr, 4); |
1da177e4 | 1461 | switch (arg->open_flags & O_CREAT) { |
05d564fe | 1462 | case 0: |
34558513 | 1463 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
05d564fe AA |
1464 | break; |
1465 | default: | |
34558513 | 1466 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
05d564fe | 1467 | encode_createmode(xdr, arg); |
1da177e4 LT |
1468 | } |
1469 | } | |
1470 | ||
bd7bf9d5 | 1471 | static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type) |
1da177e4 | 1472 | { |
8687b63a | 1473 | __be32 *p; |
1da177e4 | 1474 | |
13c65ce9 | 1475 | p = reserve_space(xdr, 4); |
1da177e4 | 1476 | switch (delegation_type) { |
05d564fe | 1477 | case 0: |
34558513 | 1478 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
05d564fe AA |
1479 | break; |
1480 | case FMODE_READ: | |
34558513 | 1481 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
05d564fe AA |
1482 | break; |
1483 | case FMODE_WRITE|FMODE_READ: | |
34558513 | 1484 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
05d564fe AA |
1485 | break; |
1486 | default: | |
1487 | BUG(); | |
1da177e4 LT |
1488 | } |
1489 | } | |
1490 | ||
1491 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) | |
1492 | { | |
8687b63a | 1493 | __be32 *p; |
1da177e4 | 1494 | |
13c65ce9 | 1495 | p = reserve_space(xdr, 4); |
34558513 | 1496 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
1da177e4 LT |
1497 | encode_string(xdr, name->len, name->name); |
1498 | } | |
1499 | ||
bd7bf9d5 | 1500 | static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type) |
1da177e4 | 1501 | { |
8687b63a | 1502 | __be32 *p; |
1da177e4 | 1503 | |
13c65ce9 | 1504 | p = reserve_space(xdr, 4); |
34558513 | 1505 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
1da177e4 LT |
1506 | encode_delegation_type(xdr, type); |
1507 | } | |
1508 | ||
1509 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) | |
1510 | { | |
8687b63a | 1511 | __be32 *p; |
1da177e4 | 1512 | |
ea9d23f5 TM |
1513 | p = reserve_space(xdr, 4); |
1514 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); | |
1515 | encode_nfs4_stateid(xdr, stateid); | |
1da177e4 LT |
1516 | encode_string(xdr, name->len, name->name); |
1517 | } | |
1518 | ||
d9fc6619 TM |
1519 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
1520 | { | |
1521 | __be32 *p; | |
1522 | ||
1523 | p = reserve_space(xdr, 4); | |
1524 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); | |
1525 | } | |
1526 | ||
1527 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) | |
1528 | { | |
1529 | __be32 *p; | |
1530 | ||
1531 | p = reserve_space(xdr, 4); | |
1532 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); | |
1533 | encode_nfs4_stateid(xdr, stateid); | |
1534 | } | |
1535 | ||
cf8cdbe5 | 1536 | static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1537 | { |
ab19b481 | 1538 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
1da177e4 LT |
1539 | encode_openhdr(xdr, arg); |
1540 | encode_opentype(xdr, arg); | |
1541 | switch (arg->claim) { | |
05d564fe AA |
1542 | case NFS4_OPEN_CLAIM_NULL: |
1543 | encode_claim_null(xdr, arg->name); | |
1544 | break; | |
1545 | case NFS4_OPEN_CLAIM_PREVIOUS: | |
1546 | encode_claim_previous(xdr, arg->u.delegation_type); | |
1547 | break; | |
1548 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: | |
1549 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); | |
1550 | break; | |
d9fc6619 TM |
1551 | case NFS4_OPEN_CLAIM_FH: |
1552 | encode_claim_fh(xdr); | |
1553 | break; | |
1554 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: | |
1555 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); | |
1556 | break; | |
05d564fe AA |
1557 | default: |
1558 | BUG(); | |
1da177e4 | 1559 | } |
1da177e4 LT |
1560 | } |
1561 | ||
cf8cdbe5 | 1562 | static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1563 | { |
ab19b481 | 1564 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
ea9d23f5 | 1565 | encode_nfs4_stateid(xdr, arg->stateid); |
4ade9821 | 1566 | encode_nfs4_seqid(xdr, arg->seqid); |
1da177e4 LT |
1567 | } |
1568 | ||
cf8cdbe5 | 1569 | static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1570 | { |
ab19b481 | 1571 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
566fcec6 | 1572 | encode_nfs4_stateid(xdr, &arg->stateid); |
4ade9821 | 1573 | encode_nfs4_seqid(xdr, arg->seqid); |
6ae37339 | 1574 | encode_share_access(xdr, arg->share_access); |
1da177e4 LT |
1575 | } |
1576 | ||
cf8cdbe5 | 1577 | static void |
d017931c | 1578 | encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr) |
1da177e4 | 1579 | { |
ab19b481 | 1580 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
6fdfb0bc | 1581 | encode_string(xdr, fh->size, fh->data); |
1da177e4 LT |
1582 | } |
1583 | ||
cf8cdbe5 | 1584 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1585 | { |
ab19b481 | 1586 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
1da177e4 LT |
1587 | } |
1588 | ||
3c6b899c AS |
1589 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
1590 | struct compound_hdr *hdr) | |
1da177e4 | 1591 | { |
8687b63a | 1592 | __be32 *p; |
1da177e4 | 1593 | |
ab19b481 | 1594 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
9b206149 | 1595 | encode_nfs4_stateid(xdr, &args->stateid); |
1da177e4 | 1596 | |
13c65ce9 | 1597 | p = reserve_space(xdr, 12); |
b95be5a9 | 1598 | p = xdr_encode_hyper(p, args->offset); |
34558513 | 1599 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1600 | } |
1601 | ||
cf8cdbe5 | 1602 | static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr) |
1da177e4 | 1603 | { |
aa9c2669 | 1604 | uint32_t attrs[3] = { |
28331a46 TM |
1605 | FATTR4_WORD0_RDATTR_ERROR, |
1606 | FATTR4_WORD1_MOUNTED_ON_FILEID, | |
1607 | }; | |
c49c6894 TM |
1608 | uint32_t dircount = readdir->count; |
1609 | uint32_t maxcount = readdir->count; | |
cd93710e | 1610 | __be32 *p, verf[2]; |
d204c5d2 TM |
1611 | uint32_t attrlen = 0; |
1612 | unsigned int i; | |
1da177e4 | 1613 | |
82f2e547 BS |
1614 | if (readdir->plus) { |
1615 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| | |
28331a46 | 1616 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
82f2e547 BS |
1617 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
1618 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| | |
1619 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| | |
1620 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; | |
d204c5d2 | 1621 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
82f2e547 | 1622 | } |
28331a46 TM |
1623 | /* Use mounted_on_fileid only if the server supports it */ |
1624 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) | |
1625 | attrs[0] |= FATTR4_WORD0_FILEID; | |
d204c5d2 TM |
1626 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
1627 | attrs[i] &= readdir->bitmask[i]; | |
1628 | if (attrs[i] != 0) | |
1629 | attrlen = i+1; | |
1630 | } | |
82f2e547 | 1631 | |
475d4ba0 | 1632 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
ff2eb681 | 1633 | encode_uint64(xdr, readdir->cookie); |
cd93710e | 1634 | encode_nfs4_verifier(xdr, &readdir->verifier); |
d204c5d2 | 1635 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
6f7a35bd | 1636 | *p++ = cpu_to_be32(dircount); |
c49c6894 | 1637 | *p++ = cpu_to_be32(maxcount); |
d204c5d2 TM |
1638 | *p++ = cpu_to_be32(attrlen); |
1639 | for (i = 0; i < attrlen; i++) | |
1640 | *p++ = cpu_to_be32(attrs[i]); | |
cd93710e | 1641 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
aa9c2669 DQ |
1642 | |
1643 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", | |
44109241 | 1644 | __func__, |
eadf4598 | 1645 | (unsigned long long)readdir->cookie, |
cd93710e | 1646 | verf[0], verf[1], |
eadf4598 | 1647 | attrs[0] & readdir->bitmask[0], |
aa9c2669 DQ |
1648 | attrs[1] & readdir->bitmask[1], |
1649 | attrs[2] & readdir->bitmask[2]); | |
1da177e4 LT |
1650 | } |
1651 | ||
cf8cdbe5 | 1652 | static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr) |
1da177e4 | 1653 | { |
ab19b481 | 1654 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
1da177e4 LT |
1655 | } |
1656 | ||
cf8cdbe5 | 1657 | static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1658 | { |
ab19b481 | 1659 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
6fdfb0bc | 1660 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1661 | } |
1662 | ||
cf8cdbe5 | 1663 | static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr) |
1da177e4 | 1664 | { |
ab19b481 | 1665 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
811652bd BH |
1666 | encode_string(xdr, oldname->len, oldname->name); |
1667 | encode_string(xdr, newname->len, newname->name); | |
1da177e4 LT |
1668 | } |
1669 | ||
bb4dae5e CL |
1670 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
1671 | struct compound_hdr *hdr) | |
1da177e4 | 1672 | { |
475d4ba0 | 1673 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
ff2eb681 | 1674 | encode_uint64(xdr, clid); |
1da177e4 LT |
1675 | } |
1676 | ||
cf8cdbe5 | 1677 | static void |
d017931c | 1678 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
56ae19f3 | 1679 | { |
ab19b481 | 1680 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
56ae19f3 TM |
1681 | } |
1682 | ||
db145db0 | 1683 | static void nfs4_acltype_to_bitmap(enum nfs4_acl_type type, __u32 bitmap[2]) |
23ec6965 | 1684 | { |
db145db0 TM |
1685 | switch (type) { |
1686 | default: | |
1687 | bitmap[0] = FATTR4_WORD0_ACL; | |
1688 | bitmap[1] = 0; | |
1689 | break; | |
1690 | case NFS4ACL_DACL: | |
1691 | bitmap[0] = 0; | |
1692 | bitmap[1] = FATTR4_WORD1_DACL; | |
1693 | break; | |
1694 | case NFS4ACL_SACL: | |
1695 | bitmap[0] = 0; | |
1696 | bitmap[1] = FATTR4_WORD1_SACL; | |
1697 | } | |
1698 | } | |
1699 | ||
1700 | static void encode_setacl(struct xdr_stream *xdr, | |
1701 | const struct nfs_setaclargs *arg, | |
1702 | struct compound_hdr *hdr) | |
1703 | { | |
1704 | __u32 bitmap[2]; | |
1705 | ||
1706 | nfs4_acltype_to_bitmap(arg->acl_type, bitmap); | |
23ec6965 | 1707 | |
ab19b481 | 1708 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
ea9d23f5 | 1709 | encode_nfs4_stateid(xdr, &zero_stateid); |
db145db0 TM |
1710 | xdr_encode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap)); |
1711 | encode_uint32(xdr, arg->acl_len); | |
8fbcf237 | 1712 | xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len); |
23ec6965 BF |
1713 | } |
1714 | ||
cf8cdbe5 | 1715 | static void |
d017931c | 1716 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1717 | { |
ab19b481 | 1718 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
1da177e4 LT |
1719 | } |
1720 | ||
cf8cdbe5 | 1721 | static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr) |
1da177e4 | 1722 | { |
ab19b481 | 1723 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
ea9d23f5 | 1724 | encode_nfs4_stateid(xdr, &arg->stateid); |
28cf22d0 TM |
1725 | encode_attrs(xdr, arg->iap, arg->label, NULL, server, |
1726 | server->attr_bitmask); | |
1da177e4 LT |
1727 | } |
1728 | ||
cf8cdbe5 | 1729 | static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr) |
1da177e4 | 1730 | { |
8687b63a | 1731 | __be32 *p; |
1da177e4 | 1732 | |
70019514 | 1733 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
cd93710e | 1734 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
1da177e4 | 1735 | |
3a6bb738 JL |
1736 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), |
1737 | setclientid->sc_clnt->cl_owner_id); | |
13c65ce9 | 1738 | p = reserve_space(xdr, 4); |
34558513 | 1739 | *p = cpu_to_be32(setclientid->sc_prog); |
1da177e4 LT |
1740 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
1741 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); | |
13c65ce9 | 1742 | p = reserve_space(xdr, 4); |
3a6bb738 | 1743 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); |
1da177e4 LT |
1744 | } |
1745 | ||
bb8b27e5 | 1746 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) |
1da177e4 | 1747 | { |
475d4ba0 TM |
1748 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
1749 | decode_setclientid_confirm_maxsz, hdr); | |
ff2eb681 | 1750 | encode_uint64(xdr, arg->clientid); |
cd93710e | 1751 | encode_nfs4_verifier(xdr, &arg->confirm); |
1da177e4 LT |
1752 | } |
1753 | ||
3c6b899c AS |
1754 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
1755 | struct compound_hdr *hdr) | |
1da177e4 | 1756 | { |
8687b63a | 1757 | __be32 *p; |
1da177e4 | 1758 | |
ab19b481 | 1759 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
9b206149 | 1760 | encode_nfs4_stateid(xdr, &args->stateid); |
1da177e4 | 1761 | |
13c65ce9 | 1762 | p = reserve_space(xdr, 16); |
b95be5a9 | 1763 | p = xdr_encode_hyper(p, args->offset); |
e75bc1c8 | 1764 | *p++ = cpu_to_be32(args->stable); |
34558513 | 1765 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1766 | |
1767 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); | |
1da177e4 LT |
1768 | } |
1769 | ||
cf8cdbe5 | 1770 | static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr) |
1da177e4 | 1771 | { |
ab19b481 | 1772 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
ea9d23f5 | 1773 | encode_nfs4_stateid(xdr, stateid); |
1da177e4 | 1774 | } |
9b7b9fcc | 1775 | |
5a5ea0d4 BS |
1776 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1777 | { | |
ab19b481 | 1778 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
6fdfb0bc | 1779 | encode_string(xdr, name->len, name->name); |
5a5ea0d4 BS |
1780 | } |
1781 | ||
99fe60d0 | 1782 | #if defined(CONFIG_NFS_V4_1) |
9b7b9fcc | 1783 | /* NFSv4.1 operations */ |
7c44f1ae | 1784 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
fcc85819 | 1785 | const struct nfs41_bind_conn_to_session_args *args, |
7c44f1ae WAA |
1786 | struct compound_hdr *hdr) |
1787 | { | |
1788 | __be32 *p; | |
1789 | ||
1790 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, | |
1791 | decode_bind_conn_to_session_maxsz, hdr); | |
71a097c6 | 1792 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
7c44f1ae | 1793 | p = xdr_reserve_space(xdr, 8); |
71a097c6 TM |
1794 | *p++ = cpu_to_be32(args->dir); |
1795 | *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0); | |
7c44f1ae WAA |
1796 | } |
1797 | ||
fcc85819 | 1798 | static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map) |
2031cd1a WAA |
1799 | { |
1800 | unsigned int i; | |
1801 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); | |
1802 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) | |
1803 | encode_uint32(xdr, op_map->u.words[i]); | |
1804 | } | |
1805 | ||
99fe60d0 | 1806 | static void encode_exchange_id(struct xdr_stream *xdr, |
fcc85819 | 1807 | const struct nfs41_exchange_id_args *args, |
99fe60d0 BH |
1808 | struct compound_hdr *hdr) |
1809 | { | |
1810 | __be32 *p; | |
d751f748 | 1811 | char impl_name[IMPL_NAME_LIMIT]; |
db8ac8ba | 1812 | int len = 0; |
99fe60d0 | 1813 | |
70019514 | 1814 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
fd40559c | 1815 | encode_nfs4_verifier(xdr, &args->verifier); |
99fe60d0 | 1816 | |
3a6bb738 JL |
1817 | encode_string(xdr, strlen(args->client->cl_owner_id), |
1818 | args->client->cl_owner_id); | |
99fe60d0 | 1819 | |
2031cd1a WAA |
1820 | encode_uint32(xdr, args->flags); |
1821 | encode_uint32(xdr, args->state_protect.how); | |
1822 | ||
1823 | switch (args->state_protect.how) { | |
1824 | case SP4_NONE: | |
1825 | break; | |
1826 | case SP4_MACH_CRED: | |
1827 | encode_op_map(xdr, &args->state_protect.enforce); | |
1828 | encode_op_map(xdr, &args->state_protect.allow); | |
1829 | break; | |
1830 | default: | |
1831 | WARN_ON_ONCE(1); | |
1832 | break; | |
1833 | } | |
db8ac8ba WAA |
1834 | |
1835 | if (send_implementation_id && | |
1836 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && | |
1837 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) | |
d751f748 | 1838 | <= sizeof(impl_name) + 1) |
db8ac8ba WAA |
1839 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
1840 | utsname()->sysname, utsname()->release, | |
1841 | utsname()->version, utsname()->machine); | |
1842 | ||
1843 | if (len > 0) { | |
2031cd1a | 1844 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
db8ac8ba WAA |
1845 | |
1846 | encode_string(xdr, | |
1847 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, | |
1848 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); | |
1849 | encode_string(xdr, len, impl_name); | |
1850 | /* just send zeros for nii_date - the date is in nii_name */ | |
1851 | p = reserve_space(xdr, 12); | |
1852 | p = xdr_encode_hyper(p, 0); | |
1853 | *p = cpu_to_be32(0); | |
1854 | } else | |
2031cd1a | 1855 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
99fe60d0 | 1856 | } |
fc931582 AA |
1857 | |
1858 | static void encode_create_session(struct xdr_stream *xdr, | |
fcc85819 | 1859 | const struct nfs41_create_session_args *args, |
fc931582 AA |
1860 | struct compound_hdr *hdr) |
1861 | { | |
1862 | __be32 *p; | |
fc931582 | 1863 | struct nfs_client *clp = args->client; |
89f0ff38 | 1864 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
f092075d | 1865 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
8e0d46e1 MS |
1866 | u32 max_resp_sz_cached; |
1867 | ||
1868 | /* | |
1869 | * Assumes OPEN is the biggest non-idempotent compound. | |
1870 | * 2 is the verifier. | |
1871 | */ | |
35c036ef BF |
1872 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2) |
1873 | * XDR_UNIT + RPC_MAX_AUTH_SIZE; | |
fc931582 | 1874 | |
475d4ba0 | 1875 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
89f0ff38 | 1876 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
79969dd1 TM |
1877 | p = xdr_encode_hyper(p, args->clientid); |
1878 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ | |
e75bc1c8 | 1879 | *p++ = cpu_to_be32(args->flags); /*flags */ |
fc931582 | 1880 | |
fc931582 | 1881 | /* Fore Channel */ |
c9c30dd5 | 1882 | *p++ = cpu_to_be32(0); /* header padding size */ |
e75bc1c8 BH |
1883 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
1884 | *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ | |
8e0d46e1 | 1885 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
e75bc1c8 BH |
1886 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
1887 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ | |
1888 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ | |
fc931582 AA |
1889 | |
1890 | /* Back Channel */ | |
c9c30dd5 | 1891 | *p++ = cpu_to_be32(0); /* header padding size */ |
e75bc1c8 BH |
1892 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
1893 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ | |
1894 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ | |
1895 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ | |
1896 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ | |
1897 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ | |
fc931582 | 1898 | |
e75bc1c8 | 1899 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
e75bc1c8 | 1900 | *p++ = cpu_to_be32(1); |
e75bc1c8 | 1901 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
fc931582 AA |
1902 | |
1903 | /* authsys_parms rfc1831 */ | |
2f86e091 | 1904 | *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */ |
89f0ff38 | 1905 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
e75bc1c8 BH |
1906 | *p++ = cpu_to_be32(0); /* UID */ |
1907 | *p++ = cpu_to_be32(0); /* GID */ | |
34558513 | 1908 | *p = cpu_to_be32(0); /* No more gids */ |
fc931582 | 1909 | } |
0f3e66c6 AA |
1910 | |
1911 | static void encode_destroy_session(struct xdr_stream *xdr, | |
fcc85819 | 1912 | const struct nfs4_session *session, |
0f3e66c6 AA |
1913 | struct compound_hdr *hdr) |
1914 | { | |
475d4ba0 TM |
1915 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
1916 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | |
0f3e66c6 | 1917 | } |
18019753 | 1918 | |
66245539 TM |
1919 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
1920 | uint64_t clientid, | |
1921 | struct compound_hdr *hdr) | |
1922 | { | |
1923 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); | |
1924 | encode_uint64(xdr, clientid); | |
1925 | } | |
1926 | ||
18019753 | 1927 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
fcc85819 | 1928 | const struct nfs41_reclaim_complete_args *args, |
18019753 RL |
1929 | struct compound_hdr *hdr) |
1930 | { | |
475d4ba0 TM |
1931 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
1932 | encode_uint32(xdr, args->one_fs); | |
18019753 | 1933 | } |
99fe60d0 BH |
1934 | #endif /* CONFIG_NFS_V4_1 */ |
1935 | ||
9b7b9fcc AA |
1936 | static void encode_sequence(struct xdr_stream *xdr, |
1937 | const struct nfs4_sequence_args *args, | |
1938 | struct compound_hdr *hdr) | |
1939 | { | |
1940 | #if defined(CONFIG_NFS_V4_1) | |
2b2fa717 | 1941 | struct nfs4_session *session; |
fc01cea9 | 1942 | struct nfs4_slot_table *tp; |
2b2fa717 | 1943 | struct nfs4_slot *slot = args->sa_slot; |
fc01cea9 | 1944 | __be32 *p; |
9b7b9fcc | 1945 | |
2b2fa717 TM |
1946 | tp = slot->table; |
1947 | session = tp->session; | |
3bd2384a CL |
1948 | if (!session) |
1949 | return; | |
fc01cea9 | 1950 | |
475d4ba0 | 1951 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
fc01cea9 AA |
1952 | |
1953 | /* | |
1954 | * Sessionid + seqid + slotid + max slotid + cache_this | |
1955 | */ | |
1956 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " | |
1957 | "max_slotid=%d cache_this=%d\n", | |
1958 | __func__, | |
1959 | ((u32 *)session->sess_id.data)[0], | |
1960 | ((u32 *)session->sess_id.data)[1], | |
1961 | ((u32 *)session->sess_id.data)[2], | |
1962 | ((u32 *)session->sess_id.data)[3], | |
2b2fa717 | 1963 | slot->seq_nr, slot->slot_nr, |
fc01cea9 | 1964 | tp->highest_used_slotid, args->sa_cache_this); |
475d4ba0 | 1965 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
93f0cf25 | 1966 | p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
e75bc1c8 | 1967 | *p++ = cpu_to_be32(slot->seq_nr); |
2b2fa717 | 1968 | *p++ = cpu_to_be32(slot->slot_nr); |
e75bc1c8 | 1969 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
34558513 | 1970 | *p = cpu_to_be32(args->sa_cache_this); |
9b7b9fcc AA |
1971 | #endif /* CONFIG_NFS_V4_1 */ |
1972 | } | |
1973 | ||
b1f69b75 AA |
1974 | #ifdef CONFIG_NFS_V4_1 |
1975 | static void | |
1976 | encode_getdeviceinfo(struct xdr_stream *xdr, | |
1977 | const struct nfs4_getdeviceinfo_args *args, | |
1978 | struct compound_hdr *hdr) | |
1979 | { | |
1980 | __be32 *p; | |
1981 | ||
475d4ba0 | 1982 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
84c9dee3 | 1983 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
b1f69b75 AA |
1984 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
1985 | NFS4_DEVICEID4_SIZE); | |
1986 | *p++ = cpu_to_be32(args->pdev->layout_type); | |
f1c097be | 1987 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
84c9dee3 CH |
1988 | |
1989 | p = reserve_space(xdr, 4 + 4); | |
1990 | *p++ = cpu_to_be32(1); /* bitmap length */ | |
4e590803 | 1991 | *p++ = cpu_to_be32(args->notify_types); |
b1f69b75 AA |
1992 | } |
1993 | ||
1994 | static void | |
1995 | encode_layoutget(struct xdr_stream *xdr, | |
1996 | const struct nfs4_layoutget_args *args, | |
1997 | struct compound_hdr *hdr) | |
1998 | { | |
b1f69b75 AA |
1999 | __be32 *p; |
2000 | ||
475d4ba0 TM |
2001 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
2002 | p = reserve_space(xdr, 36); | |
b1f69b75 AA |
2003 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
2004 | *p++ = cpu_to_be32(args->type); | |
2005 | *p++ = cpu_to_be32(args->range.iomode); | |
2006 | p = xdr_encode_hyper(p, args->range.offset); | |
2007 | p = xdr_encode_hyper(p, args->range.length); | |
2008 | p = xdr_encode_hyper(p, args->minlength); | |
ea9d23f5 | 2009 | encode_nfs4_stateid(xdr, &args->stateid); |
475d4ba0 | 2010 | encode_uint32(xdr, args->maxcount); |
b1f69b75 AA |
2011 | |
2012 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", | |
2013 | __func__, | |
2014 | args->type, | |
2015 | args->range.iomode, | |
2016 | (unsigned long)args->range.offset, | |
2017 | (unsigned long)args->range.length, | |
2018 | args->maxcount); | |
b1f69b75 | 2019 | } |
863a3c6c AA |
2020 | |
2021 | static int | |
2022 | encode_layoutcommit(struct xdr_stream *xdr, | |
ac7db726 | 2023 | struct inode *inode, |
fcc85819 | 2024 | const struct nfs4_layoutcommit_args *args, |
863a3c6c AA |
2025 | struct compound_hdr *hdr) |
2026 | { | |
2027 | __be32 *p; | |
2028 | ||
2029 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, | |
2030 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); | |
2031 | ||
475d4ba0 TM |
2032 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
2033 | p = reserve_space(xdr, 20); | |
863a3c6c AA |
2034 | /* Only whole file layouts */ |
2035 | p = xdr_encode_hyper(p, 0); /* offset */ | |
3557c6c3 | 2036 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
ea9d23f5 TM |
2037 | *p = cpu_to_be32(0); /* reclaim */ |
2038 | encode_nfs4_stateid(xdr, &args->stateid); | |
2e18d4d8 TM |
2039 | if (args->lastbytewritten != U64_MAX) { |
2040 | p = reserve_space(xdr, 20); | |
2041 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ | |
2042 | p = xdr_encode_hyper(p, args->lastbytewritten); | |
2043 | } else { | |
2044 | p = reserve_space(xdr, 12); | |
2045 | *p++ = cpu_to_be32(0); /* newoffset = FALSE */ | |
2046 | } | |
863a3c6c AA |
2047 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
2048 | *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */ | |
ac7db726 | 2049 | |
73504740 TM |
2050 | encode_uint32(xdr, args->layoutupdate_len); |
2051 | if (args->layoutupdate_pages) | |
2052 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, | |
2053 | args->layoutupdate_len); | |
863a3c6c | 2054 | |
863a3c6c AA |
2055 | return 0; |
2056 | } | |
cbe82603 BH |
2057 | |
2058 | static void | |
2059 | encode_layoutreturn(struct xdr_stream *xdr, | |
2060 | const struct nfs4_layoutreturn_args *args, | |
2061 | struct compound_hdr *hdr) | |
2062 | { | |
2063 | __be32 *p; | |
2064 | ||
475d4ba0 TM |
2065 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
2066 | p = reserve_space(xdr, 16); | |
cbe82603 BH |
2067 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
2068 | *p++ = cpu_to_be32(args->layout_type); | |
15eb67c1 | 2069 | *p++ = cpu_to_be32(args->range.iomode); |
cbe82603 | 2070 | *p = cpu_to_be32(RETURN_FILE); |
ea9d23f5 | 2071 | p = reserve_space(xdr, 16); |
15eb67c1 PT |
2072 | p = xdr_encode_hyper(p, args->range.offset); |
2073 | p = xdr_encode_hyper(p, args->range.length); | |
cbe82603 | 2074 | spin_lock(&args->inode->i_lock); |
ea9d23f5 | 2075 | encode_nfs4_stateid(xdr, &args->stateid); |
cbe82603 | 2076 | spin_unlock(&args->inode->i_lock); |
4d796d75 TM |
2077 | if (args->ld_private->ops && args->ld_private->ops->encode) |
2078 | args->ld_private->ops->encode(xdr, args, args->ld_private); | |
94e5c571 | 2079 | else |
475d4ba0 | 2080 | encode_uint32(xdr, 0); |
cbe82603 | 2081 | } |
fca78d6d BS |
2082 | |
2083 | static int | |
2084 | encode_secinfo_no_name(struct xdr_stream *xdr, | |
2085 | const struct nfs41_secinfo_no_name_args *args, | |
2086 | struct compound_hdr *hdr) | |
2087 | { | |
475d4ba0 TM |
2088 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
2089 | encode_uint32(xdr, args->style); | |
fca78d6d BS |
2090 | return 0; |
2091 | } | |
7d974794 BS |
2092 | |
2093 | static void encode_test_stateid(struct xdr_stream *xdr, | |
fcc85819 | 2094 | const struct nfs41_test_stateid_args *args, |
7d974794 BS |
2095 | struct compound_hdr *hdr) |
2096 | { | |
475d4ba0 TM |
2097 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
2098 | encode_uint32(xdr, 1); | |
ea9d23f5 | 2099 | encode_nfs4_stateid(xdr, args->stateid); |
7d974794 | 2100 | } |
9aeda35f BS |
2101 | |
2102 | static void encode_free_stateid(struct xdr_stream *xdr, | |
fcc85819 | 2103 | const struct nfs41_free_stateid_args *args, |
9aeda35f BS |
2104 | struct compound_hdr *hdr) |
2105 | { | |
ab19b481 | 2106 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
7c1d5fae | 2107 | encode_nfs4_stateid(xdr, &args->stateid); |
9aeda35f | 2108 | } |
cf805165 TM |
2109 | #else |
2110 | static inline void | |
2111 | encode_layoutreturn(struct xdr_stream *xdr, | |
2112 | const struct nfs4_layoutreturn_args *args, | |
2113 | struct compound_hdr *hdr) | |
2114 | { | |
2115 | } | |
56f487f8 FI |
2116 | |
2117 | static void | |
2118 | encode_layoutget(struct xdr_stream *xdr, | |
2119 | const struct nfs4_layoutget_args *args, | |
2120 | struct compound_hdr *hdr) | |
2121 | { | |
2122 | } | |
b1f69b75 AA |
2123 | #endif /* CONFIG_NFS_V4_1 */ |
2124 | ||
1da177e4 LT |
2125 | /* |
2126 | * END OF "GENERIC" ENCODE ROUTINES. | |
2127 | */ | |
2128 | ||
66cc0429 BH |
2129 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
2130 | { | |
2131 | #if defined(CONFIG_NFS_V4_1) | |
3bd2384a CL |
2132 | struct nfs4_session *session = args->sa_slot->table->session; |
2133 | if (session) | |
2134 | return session->clp->cl_mvops->minor_version; | |
66cc0429 BH |
2135 | #endif /* CONFIG_NFS_V4_1 */ |
2136 | return 0; | |
2137 | } | |
2138 | ||
1da177e4 LT |
2139 | /* |
2140 | * Encode an ACCESS request | |
2141 | */ | |
9f06c719 | 2142 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2143 | const void *data) |
1da177e4 | 2144 | { |
fcc85819 | 2145 | const struct nfs4_accessargs *args = data; |
1da177e4 | 2146 | struct compound_hdr hdr = { |
66cc0429 | 2147 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2148 | }; |
1da177e4 | 2149 | |
9f06c719 CL |
2150 | encode_compound_hdr(xdr, req, &hdr); |
2151 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2152 | encode_putfh(xdr, args->fh, &hdr); | |
2153 | encode_access(xdr, args->access, &hdr); | |
8bcbe7d9 TM |
2154 | if (args->bitmask) |
2155 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2156 | encode_nops(&hdr); |
1da177e4 LT |
2157 | } |
2158 | ||
2159 | /* | |
2160 | * Encode LOOKUP request | |
2161 | */ | |
9f06c719 | 2162 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2163 | const void *data) |
1da177e4 | 2164 | { |
fcc85819 | 2165 | const struct nfs4_lookup_arg *args = data; |
1da177e4 | 2166 | struct compound_hdr hdr = { |
66cc0429 | 2167 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2168 | }; |
1da177e4 | 2169 | |
9f06c719 CL |
2170 | encode_compound_hdr(xdr, req, &hdr); |
2171 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2172 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2173 | encode_lookup(xdr, args->name, &hdr); | |
2174 | encode_getfh(xdr, &hdr); | |
2175 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2176 | encode_nops(&hdr); |
1da177e4 LT |
2177 | } |
2178 | ||
5b5faaf6 JL |
2179 | /* |
2180 | * Encode LOOKUPP request | |
2181 | */ | |
2182 | static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr, | |
2183 | const void *data) | |
2184 | { | |
2185 | const struct nfs4_lookupp_arg *args = data; | |
2186 | struct compound_hdr hdr = { | |
2187 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2188 | }; | |
2189 | ||
2190 | encode_compound_hdr(xdr, req, &hdr); | |
2191 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2192 | encode_putfh(xdr, args->fh, &hdr); | |
2193 | encode_lookupp(xdr, &hdr); | |
2194 | encode_getfh(xdr, &hdr); | |
2195 | encode_getfattr(xdr, args->bitmask, &hdr); | |
2196 | encode_nops(&hdr); | |
2197 | } | |
2198 | ||
1da177e4 LT |
2199 | /* |
2200 | * Encode LOOKUP_ROOT request | |
2201 | */ | |
9f06c719 CL |
2202 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
2203 | struct xdr_stream *xdr, | |
fcc85819 | 2204 | const void *data) |
1da177e4 | 2205 | { |
fcc85819 | 2206 | const struct nfs4_lookup_root_arg *args = data; |
1da177e4 | 2207 | struct compound_hdr hdr = { |
66cc0429 | 2208 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2209 | }; |
1da177e4 | 2210 | |
9f06c719 CL |
2211 | encode_compound_hdr(xdr, req, &hdr); |
2212 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2213 | encode_putrootfh(xdr, &hdr); | |
2214 | encode_getfh(xdr, &hdr); | |
2215 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2216 | encode_nops(&hdr); |
1da177e4 LT |
2217 | } |
2218 | ||
2219 | /* | |
2220 | * Encode REMOVE request | |
2221 | */ | |
9f06c719 | 2222 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2223 | const void *data) |
1da177e4 | 2224 | { |
fcc85819 | 2225 | const struct nfs_removeargs *args = data; |
1da177e4 | 2226 | struct compound_hdr hdr = { |
66cc0429 | 2227 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2228 | }; |
1da177e4 | 2229 | |
9f06c719 CL |
2230 | encode_compound_hdr(xdr, req, &hdr); |
2231 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2232 | encode_putfh(xdr, args->fh, &hdr); | |
2233 | encode_remove(xdr, &args->name, &hdr); | |
d017931c | 2234 | encode_nops(&hdr); |
1da177e4 LT |
2235 | } |
2236 | ||
2237 | /* | |
2238 | * Encode RENAME request | |
2239 | */ | |
9f06c719 | 2240 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2241 | const void *data) |
1da177e4 | 2242 | { |
fcc85819 | 2243 | const struct nfs_renameargs *args = data; |
1da177e4 | 2244 | struct compound_hdr hdr = { |
66cc0429 | 2245 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2246 | }; |
1da177e4 | 2247 | |
9f06c719 CL |
2248 | encode_compound_hdr(xdr, req, &hdr); |
2249 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2250 | encode_putfh(xdr, args->old_dir, &hdr); | |
2251 | encode_savefh(xdr, &hdr); | |
2252 | encode_putfh(xdr, args->new_dir, &hdr); | |
2253 | encode_rename(xdr, args->old_name, args->new_name, &hdr); | |
d017931c | 2254 | encode_nops(&hdr); |
1da177e4 LT |
2255 | } |
2256 | ||
2257 | /* | |
2258 | * Encode LINK request | |
2259 | */ | |
9f06c719 | 2260 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2261 | const void *data) |
1da177e4 | 2262 | { |
fcc85819 | 2263 | const struct nfs4_link_arg *args = data; |
1da177e4 | 2264 | struct compound_hdr hdr = { |
66cc0429 | 2265 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2266 | }; |
1da177e4 | 2267 | |
9f06c719 CL |
2268 | encode_compound_hdr(xdr, req, &hdr); |
2269 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2270 | encode_putfh(xdr, args->fh, &hdr); | |
2271 | encode_savefh(xdr, &hdr); | |
2272 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2273 | encode_link(xdr, args->name, &hdr); | |
9f06c719 CL |
2274 | encode_restorefh(xdr, &hdr); |
2275 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2276 | encode_nops(&hdr); |
1da177e4 LT |
2277 | } |
2278 | ||
2279 | /* | |
2280 | * Encode CREATE request | |
2281 | */ | |
9f06c719 | 2282 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2283 | const void *data) |
1da177e4 | 2284 | { |
fcc85819 | 2285 | const struct nfs4_create_arg *args = data; |
1da177e4 | 2286 | struct compound_hdr hdr = { |
66cc0429 | 2287 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2288 | }; |
1da177e4 | 2289 | |
9f06c719 CL |
2290 | encode_compound_hdr(xdr, req, &hdr); |
2291 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2292 | encode_putfh(xdr, args->dir_fh, &hdr); | |
9f06c719 CL |
2293 | encode_create(xdr, args, &hdr); |
2294 | encode_getfh(xdr, &hdr); | |
2295 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2296 | encode_nops(&hdr); |
1da177e4 LT |
2297 | } |
2298 | ||
2299 | /* | |
2300 | * Encode SYMLINK request | |
2301 | */ | |
9f06c719 | 2302 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2303 | const void *data) |
1da177e4 | 2304 | { |
fcc85819 CH |
2305 | const struct nfs4_create_arg *args = data; |
2306 | ||
9f06c719 | 2307 | nfs4_xdr_enc_create(req, xdr, args); |
1da177e4 LT |
2308 | } |
2309 | ||
2310 | /* | |
2311 | * Encode GETATTR request | |
2312 | */ | |
9f06c719 | 2313 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2314 | const void *data) |
1da177e4 | 2315 | { |
fcc85819 | 2316 | const struct nfs4_getattr_arg *args = data; |
1da177e4 | 2317 | struct compound_hdr hdr = { |
66cc0429 | 2318 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2319 | }; |
1da177e4 | 2320 | |
9f06c719 CL |
2321 | encode_compound_hdr(xdr, req, &hdr); |
2322 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2323 | encode_putfh(xdr, args->fh, &hdr); | |
2324 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2325 | encode_nops(&hdr); |
1da177e4 LT |
2326 | } |
2327 | ||
2328 | /* | |
2329 | * Encode a CLOSE request | |
2330 | */ | |
9f06c719 | 2331 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2332 | const void *data) |
1da177e4 | 2333 | { |
fcc85819 | 2334 | const struct nfs_closeargs *args = data; |
05d564fe | 2335 | struct compound_hdr hdr = { |
66cc0429 | 2336 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 2337 | }; |
05d564fe | 2338 | |
9f06c719 CL |
2339 | encode_compound_hdr(xdr, req, &hdr); |
2340 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2341 | encode_putfh(xdr, args->fh, &hdr); | |
cf805165 TM |
2342 | if (args->lr_args) |
2343 | encode_layoutreturn(xdr, args->lr_args, &hdr); | |
3ecefc92 TM |
2344 | if (args->bitmask != NULL) |
2345 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d8d84983 | 2346 | encode_close(xdr, args, &hdr); |
d017931c | 2347 | encode_nops(&hdr); |
1da177e4 LT |
2348 | } |
2349 | ||
2350 | /* | |
2351 | * Encode an OPEN request | |
2352 | */ | |
9f06c719 | 2353 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2354 | const void *data) |
1da177e4 | 2355 | { |
fcc85819 | 2356 | const struct nfs_openargs *args = data; |
1da177e4 | 2357 | struct compound_hdr hdr = { |
66cc0429 | 2358 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2359 | }; |
1da177e4 | 2360 | |
9f06c719 CL |
2361 | encode_compound_hdr(xdr, req, &hdr); |
2362 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2363 | encode_putfh(xdr, args->fh, &hdr); | |
9f06c719 CL |
2364 | encode_open(xdr, args, &hdr); |
2365 | encode_getfh(xdr, &hdr); | |
ae2bb032 WAA |
2366 | if (args->access) |
2367 | encode_access(xdr, args->access, &hdr); | |
1549210f | 2368 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
56f487f8 FI |
2369 | if (args->lg_args) { |
2370 | encode_layoutget(xdr, args->lg_args, &hdr); | |
cf500bac CL |
2371 | rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
2372 | args->lg_args->layout.pglen, | |
9ed5af26 | 2373 | hdr.replen - pagepad_maxsz); |
56f487f8 | 2374 | } |
d017931c | 2375 | encode_nops(&hdr); |
1da177e4 LT |
2376 | } |
2377 | ||
2378 | /* | |
2379 | * Encode an OPEN_CONFIRM request | |
2380 | */ | |
9f06c719 CL |
2381 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
2382 | struct xdr_stream *xdr, | |
fcc85819 | 2383 | const void *data) |
1da177e4 | 2384 | { |
fcc85819 | 2385 | const struct nfs_open_confirmargs *args = data; |
1da177e4 | 2386 | struct compound_hdr hdr = { |
d017931c | 2387 | .nops = 0, |
1da177e4 | 2388 | }; |
1da177e4 | 2389 | |
9f06c719 CL |
2390 | encode_compound_hdr(xdr, req, &hdr); |
2391 | encode_putfh(xdr, args->fh, &hdr); | |
2392 | encode_open_confirm(xdr, args, &hdr); | |
d017931c | 2393 | encode_nops(&hdr); |
1da177e4 LT |
2394 | } |
2395 | ||
2396 | /* | |
2397 | * Encode an OPEN request with no attributes. | |
2398 | */ | |
9f06c719 CL |
2399 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
2400 | struct xdr_stream *xdr, | |
fcc85819 | 2401 | const void *data) |
1da177e4 | 2402 | { |
fcc85819 | 2403 | const struct nfs_openargs *args = data; |
1da177e4 | 2404 | struct compound_hdr hdr = { |
66cc0429 | 2405 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2406 | }; |
1da177e4 | 2407 | |
9f06c719 CL |
2408 | encode_compound_hdr(xdr, req, &hdr); |
2409 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2410 | encode_putfh(xdr, args->fh, &hdr); | |
2411 | encode_open(xdr, args, &hdr); | |
ae2bb032 WAA |
2412 | if (args->access) |
2413 | encode_access(xdr, args->access, &hdr); | |
e23008ec | 2414 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
56f487f8 FI |
2415 | if (args->lg_args) { |
2416 | encode_layoutget(xdr, args->lg_args, &hdr); | |
cf500bac CL |
2417 | rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
2418 | args->lg_args->layout.pglen, | |
9ed5af26 | 2419 | hdr.replen - pagepad_maxsz); |
56f487f8 | 2420 | } |
d017931c | 2421 | encode_nops(&hdr); |
1da177e4 LT |
2422 | } |
2423 | ||
2424 | /* | |
2425 | * Encode an OPEN_DOWNGRADE request | |
2426 | */ | |
9f06c719 CL |
2427 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
2428 | struct xdr_stream *xdr, | |
fcc85819 | 2429 | const void *data) |
1da177e4 | 2430 | { |
fcc85819 | 2431 | const struct nfs_closeargs *args = data; |
1da177e4 | 2432 | struct compound_hdr hdr = { |
66cc0429 | 2433 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2434 | }; |
1da177e4 | 2435 | |
9f06c719 CL |
2436 | encode_compound_hdr(xdr, req, &hdr); |
2437 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2438 | encode_putfh(xdr, args->fh, &hdr); | |
b6808145 TM |
2439 | if (args->lr_args) |
2440 | encode_layoutreturn(xdr, args->lr_args, &hdr); | |
9f06c719 | 2441 | encode_open_downgrade(xdr, args, &hdr); |
d017931c | 2442 | encode_nops(&hdr); |
1da177e4 LT |
2443 | } |
2444 | ||
2445 | /* | |
2446 | * Encode a LOCK request | |
2447 | */ | |
9f06c719 | 2448 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2449 | const void *data) |
1da177e4 | 2450 | { |
fcc85819 | 2451 | const struct nfs_lock_args *args = data; |
1da177e4 | 2452 | struct compound_hdr hdr = { |
66cc0429 | 2453 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2454 | }; |
1da177e4 | 2455 | |
9f06c719 CL |
2456 | encode_compound_hdr(xdr, req, &hdr); |
2457 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2458 | encode_putfh(xdr, args->fh, &hdr); | |
2459 | encode_lock(xdr, args, &hdr); | |
d017931c | 2460 | encode_nops(&hdr); |
1da177e4 LT |
2461 | } |
2462 | ||
2463 | /* | |
2464 | * Encode a LOCKT request | |
2465 | */ | |
9f06c719 | 2466 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2467 | const void *data) |
1da177e4 | 2468 | { |
fcc85819 | 2469 | const struct nfs_lockt_args *args = data; |
1da177e4 | 2470 | struct compound_hdr hdr = { |
66cc0429 | 2471 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2472 | }; |
1da177e4 | 2473 | |
9f06c719 CL |
2474 | encode_compound_hdr(xdr, req, &hdr); |
2475 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2476 | encode_putfh(xdr, args->fh, &hdr); | |
2477 | encode_lockt(xdr, args, &hdr); | |
d017931c | 2478 | encode_nops(&hdr); |
1da177e4 LT |
2479 | } |
2480 | ||
2481 | /* | |
2482 | * Encode a LOCKU request | |
2483 | */ | |
9f06c719 | 2484 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2485 | const void *data) |
1da177e4 | 2486 | { |
fcc85819 | 2487 | const struct nfs_locku_args *args = data; |
1da177e4 | 2488 | struct compound_hdr hdr = { |
66cc0429 | 2489 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2490 | }; |
1da177e4 | 2491 | |
9f06c719 CL |
2492 | encode_compound_hdr(xdr, req, &hdr); |
2493 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2494 | encode_putfh(xdr, args->fh, &hdr); | |
2495 | encode_locku(xdr, args, &hdr); | |
d017931c | 2496 | encode_nops(&hdr); |
1da177e4 LT |
2497 | } |
2498 | ||
9f06c719 CL |
2499 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
2500 | struct xdr_stream *xdr, | |
fcc85819 | 2501 | const void *data) |
d3c7b7cc | 2502 | { |
fcc85819 | 2503 | const struct nfs_release_lockowner_args *args = data; |
d3c7b7cc TM |
2504 | struct compound_hdr hdr = { |
2505 | .minorversion = 0, | |
2506 | }; | |
2507 | ||
9f06c719 CL |
2508 | encode_compound_hdr(xdr, req, &hdr); |
2509 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); | |
d3c7b7cc | 2510 | encode_nops(&hdr); |
d3c7b7cc TM |
2511 | } |
2512 | ||
1da177e4 LT |
2513 | /* |
2514 | * Encode a READLINK request | |
2515 | */ | |
9f06c719 | 2516 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2517 | const void *data) |
1da177e4 | 2518 | { |
fcc85819 | 2519 | const struct nfs4_readlink *args = data; |
1da177e4 | 2520 | struct compound_hdr hdr = { |
66cc0429 | 2521 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2522 | }; |
1da177e4 | 2523 | |
9f06c719 CL |
2524 | encode_compound_hdr(xdr, req, &hdr); |
2525 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2526 | encode_putfh(xdr, args->fh, &hdr); | |
2527 | encode_readlink(xdr, args, req, &hdr); | |
e3a535e1 | 2528 | |
cf500bac | 2529 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
9ed5af26 | 2530 | args->pglen, hdr.replen - pagepad_maxsz); |
d017931c | 2531 | encode_nops(&hdr); |
1da177e4 LT |
2532 | } |
2533 | ||
2534 | /* | |
2535 | * Encode a READDIR request | |
2536 | */ | |
9f06c719 | 2537 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2538 | const void *data) |
1da177e4 | 2539 | { |
fcc85819 | 2540 | const struct nfs4_readdir_arg *args = data; |
1da177e4 | 2541 | struct compound_hdr hdr = { |
66cc0429 | 2542 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2543 | }; |
1da177e4 | 2544 | |
9f06c719 CL |
2545 | encode_compound_hdr(xdr, req, &hdr); |
2546 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2547 | encode_putfh(xdr, args->fh, &hdr); | |
2548 | encode_readdir(xdr, args, req, &hdr); | |
d6ac02df | 2549 | |
cf500bac | 2550 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
9ed5af26 | 2551 | args->count, hdr.replen - pagepad_maxsz); |
d017931c | 2552 | encode_nops(&hdr); |
1da177e4 LT |
2553 | } |
2554 | ||
2555 | /* | |
2556 | * Encode a READ request | |
2557 | */ | |
9f06c719 | 2558 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2559 | const void *data) |
1da177e4 | 2560 | { |
fcc85819 | 2561 | const struct nfs_pgio_args *args = data; |
1da177e4 | 2562 | struct compound_hdr hdr = { |
66cc0429 | 2563 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2564 | }; |
1da177e4 | 2565 | |
9f06c719 CL |
2566 | encode_compound_hdr(xdr, req, &hdr); |
2567 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2568 | encode_putfh(xdr, args->fh, &hdr); | |
2569 | encode_read(xdr, args, &hdr); | |
1da177e4 | 2570 | |
cf500bac | 2571 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
9ed5af26 | 2572 | args->count, hdr.replen - pagepad_maxsz); |
4f22ccc3 | 2573 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
d017931c | 2574 | encode_nops(&hdr); |
1da177e4 LT |
2575 | } |
2576 | ||
2577 | /* | |
2578 | * Encode an SETATTR request | |
2579 | */ | |
9f06c719 | 2580 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2581 | const void *data) |
1da177e4 | 2582 | { |
fcc85819 | 2583 | const struct nfs_setattrargs *args = data; |
05d564fe | 2584 | struct compound_hdr hdr = { |
66cc0429 | 2585 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 2586 | }; |
05d564fe | 2587 | |
9f06c719 CL |
2588 | encode_compound_hdr(xdr, req, &hdr); |
2589 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2590 | encode_putfh(xdr, args->fh, &hdr); | |
2591 | encode_setattr(xdr, args, args->server, &hdr); | |
2592 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2593 | encode_nops(&hdr); |
1da177e4 LT |
2594 | } |
2595 | ||
029d105e BF |
2596 | /* |
2597 | * Encode a GETACL request | |
2598 | */ | |
9f06c719 | 2599 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2600 | const void *data) |
029d105e | 2601 | { |
fcc85819 | 2602 | const struct nfs_getaclargs *args = data; |
029d105e | 2603 | struct compound_hdr hdr = { |
66cc0429 | 2604 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
029d105e | 2605 | }; |
db145db0 | 2606 | __u32 nfs4_acl_bitmap[2]; |
28f56694 | 2607 | uint32_t replen; |
029d105e | 2608 | |
db145db0 TM |
2609 | nfs4_acltype_to_bitmap(args->acl_type, nfs4_acl_bitmap); |
2610 | ||
9f06c719 CL |
2611 | encode_compound_hdr(xdr, req, &hdr); |
2612 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2613 | encode_putfh(xdr, args->fh, &hdr); | |
6682c14b | 2614 | replen = hdr.replen + op_decode_hdr_maxsz; |
37c88763 TM |
2615 | encode_getattr(xdr, nfs4_acl_bitmap, NULL, |
2616 | ARRAY_SIZE(nfs4_acl_bitmap), &hdr); | |
cf8cdbe5 | 2617 | |
cf500bac | 2618 | rpc_prepare_reply_pages(req, args->acl_pages, 0, |
9ed5af26 | 2619 | args->acl_len, replen); |
d017931c | 2620 | encode_nops(&hdr); |
029d105e BF |
2621 | } |
2622 | ||
1da177e4 LT |
2623 | /* |
2624 | * Encode a WRITE request | |
2625 | */ | |
9f06c719 | 2626 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2627 | const void *data) |
1da177e4 | 2628 | { |
fcc85819 | 2629 | const struct nfs_pgio_args *args = data; |
1da177e4 | 2630 | struct compound_hdr hdr = { |
66cc0429 | 2631 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2632 | }; |
1da177e4 | 2633 | |
9f06c719 CL |
2634 | encode_compound_hdr(xdr, req, &hdr); |
2635 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2636 | encode_putfh(xdr, args->fh, &hdr); | |
2637 | encode_write(xdr, args, &hdr); | |
4f22ccc3 | 2638 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
7ffd1064 FI |
2639 | if (args->bitmask) |
2640 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2641 | encode_nops(&hdr); |
1da177e4 LT |
2642 | } |
2643 | ||
2644 | /* | |
2645 | * a COMMIT request | |
2646 | */ | |
9f06c719 | 2647 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2648 | const void *data) |
1da177e4 | 2649 | { |
fcc85819 | 2650 | const struct nfs_commitargs *args = data; |
1da177e4 | 2651 | struct compound_hdr hdr = { |
66cc0429 | 2652 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2653 | }; |
1da177e4 | 2654 | |
9f06c719 CL |
2655 | encode_compound_hdr(xdr, req, &hdr); |
2656 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2657 | encode_putfh(xdr, args->fh, &hdr); | |
2658 | encode_commit(xdr, args, &hdr); | |
d017931c | 2659 | encode_nops(&hdr); |
1da177e4 LT |
2660 | } |
2661 | ||
2662 | /* | |
2663 | * FSINFO request | |
2664 | */ | |
9f06c719 | 2665 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2666 | const void *data) |
1da177e4 | 2667 | { |
fcc85819 | 2668 | const struct nfs4_fsinfo_arg *args = data; |
1da177e4 | 2669 | struct compound_hdr hdr = { |
66cc0429 | 2670 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2671 | }; |
1da177e4 | 2672 | |
9f06c719 CL |
2673 | encode_compound_hdr(xdr, req, &hdr); |
2674 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2675 | encode_putfh(xdr, args->fh, &hdr); | |
2676 | encode_fsinfo(xdr, args->bitmask, &hdr); | |
d017931c | 2677 | encode_nops(&hdr); |
1da177e4 LT |
2678 | } |
2679 | ||
2680 | /* | |
2681 | * a PATHCONF request | |
2682 | */ | |
9f06c719 | 2683 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2684 | const void *data) |
1da177e4 | 2685 | { |
fcc85819 | 2686 | const struct nfs4_pathconf_arg *args = data; |
1da177e4 | 2687 | struct compound_hdr hdr = { |
66cc0429 | 2688 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2689 | }; |
1da177e4 | 2690 | |
9f06c719 CL |
2691 | encode_compound_hdr(xdr, req, &hdr); |
2692 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2693 | encode_putfh(xdr, args->fh, &hdr); | |
37c88763 TM |
2694 | encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask, |
2695 | ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr); | |
d017931c | 2696 | encode_nops(&hdr); |
1da177e4 LT |
2697 | } |
2698 | ||
2699 | /* | |
2700 | * a STATFS request | |
2701 | */ | |
9f06c719 | 2702 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2703 | const void *data) |
1da177e4 | 2704 | { |
fcc85819 | 2705 | const struct nfs4_statfs_arg *args = data; |
1da177e4 | 2706 | struct compound_hdr hdr = { |
66cc0429 | 2707 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2708 | }; |
1da177e4 | 2709 | |
9f06c719 CL |
2710 | encode_compound_hdr(xdr, req, &hdr); |
2711 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2712 | encode_putfh(xdr, args->fh, &hdr); | |
37c88763 TM |
2713 | encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask, |
2714 | ARRAY_SIZE(nfs4_statfs_bitmap), &hdr); | |
d017931c | 2715 | encode_nops(&hdr); |
1da177e4 LT |
2716 | } |
2717 | ||
2718 | /* | |
2719 | * GETATTR_BITMAP request | |
2720 | */ | |
9f06c719 CL |
2721 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
2722 | struct xdr_stream *xdr, | |
fcc85819 | 2723 | const void *data) |
1da177e4 | 2724 | { |
fcc85819 | 2725 | const struct nfs4_server_caps_arg *args = data; |
8c61282f | 2726 | const u32 *bitmask = args->bitmask; |
1da177e4 | 2727 | struct compound_hdr hdr = { |
66cc0429 | 2728 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2729 | }; |
1da177e4 | 2730 | |
9f06c719 CL |
2731 | encode_compound_hdr(xdr, req, &hdr); |
2732 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2733 | encode_putfh(xdr, args->fhandle, &hdr); | |
37c88763 | 2734 | encode_getattr(xdr, bitmask, NULL, 3, &hdr); |
d017931c | 2735 | encode_nops(&hdr); |
1da177e4 LT |
2736 | } |
2737 | ||
2738 | /* | |
2739 | * a RENEW request | |
2740 | */ | |
9f06c719 | 2741 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 CH |
2742 | const void *data) |
2743 | ||
1da177e4 | 2744 | { |
fcc85819 | 2745 | const struct nfs_client *clp = data; |
1da177e4 | 2746 | struct compound_hdr hdr = { |
d017931c | 2747 | .nops = 0, |
1da177e4 LT |
2748 | }; |
2749 | ||
9f06c719 | 2750 | encode_compound_hdr(xdr, req, &hdr); |
bb4dae5e | 2751 | encode_renew(xdr, clp->cl_clientid, &hdr); |
d017931c | 2752 | encode_nops(&hdr); |
1da177e4 LT |
2753 | } |
2754 | ||
2755 | /* | |
2756 | * a SETCLIENTID request | |
2757 | */ | |
9f06c719 CL |
2758 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
2759 | struct xdr_stream *xdr, | |
fcc85819 | 2760 | const void *data) |
1da177e4 | 2761 | { |
fcc85819 | 2762 | const struct nfs4_setclientid *sc = data; |
1da177e4 | 2763 | struct compound_hdr hdr = { |
d017931c | 2764 | .nops = 0, |
1da177e4 LT |
2765 | }; |
2766 | ||
9f06c719 CL |
2767 | encode_compound_hdr(xdr, req, &hdr); |
2768 | encode_setclientid(xdr, sc, &hdr); | |
d017931c | 2769 | encode_nops(&hdr); |
1da177e4 LT |
2770 | } |
2771 | ||
2772 | /* | |
2773 | * a SETCLIENTID_CONFIRM request | |
2774 | */ | |
9f06c719 CL |
2775 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
2776 | struct xdr_stream *xdr, | |
fcc85819 | 2777 | const void *data) |
1da177e4 | 2778 | { |
fcc85819 | 2779 | const struct nfs4_setclientid_res *arg = data; |
1da177e4 | 2780 | struct compound_hdr hdr = { |
d017931c | 2781 | .nops = 0, |
1da177e4 | 2782 | }; |
1da177e4 | 2783 | |
9f06c719 CL |
2784 | encode_compound_hdr(xdr, req, &hdr); |
2785 | encode_setclientid_confirm(xdr, arg, &hdr); | |
d017931c | 2786 | encode_nops(&hdr); |
1da177e4 LT |
2787 | } |
2788 | ||
2789 | /* | |
2790 | * DELEGRETURN request | |
2791 | */ | |
9f06c719 CL |
2792 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
2793 | struct xdr_stream *xdr, | |
fcc85819 | 2794 | const void *data) |
1da177e4 | 2795 | { |
fcc85819 | 2796 | const struct nfs4_delegreturnargs *args = data; |
1da177e4 | 2797 | struct compound_hdr hdr = { |
66cc0429 | 2798 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2799 | }; |
1da177e4 | 2800 | |
9f06c719 CL |
2801 | encode_compound_hdr(xdr, req, &hdr); |
2802 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2803 | encode_putfh(xdr, args->fhandle, &hdr); | |
586f1c39 TM |
2804 | if (args->lr_args) |
2805 | encode_layoutreturn(xdr, args->lr_args, &hdr); | |
8ac2b422 TM |
2806 | if (args->bitmask) |
2807 | encode_getfattr(xdr, args->bitmask, &hdr); | |
e144cbcc | 2808 | encode_delegreturn(xdr, args->stateid, &hdr); |
d017931c | 2809 | encode_nops(&hdr); |
1da177e4 LT |
2810 | } |
2811 | ||
683b57b4 TM |
2812 | /* |
2813 | * Encode FS_LOCATIONS request | |
2814 | */ | |
9f06c719 CL |
2815 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
2816 | struct xdr_stream *xdr, | |
fcc85819 | 2817 | const void *data) |
683b57b4 | 2818 | { |
fcc85819 | 2819 | const struct nfs4_fs_locations_arg *args = data; |
683b57b4 | 2820 | struct compound_hdr hdr = { |
66cc0429 | 2821 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
683b57b4 | 2822 | }; |
28f56694 | 2823 | uint32_t replen; |
683b57b4 | 2824 | |
9f06c719 CL |
2825 | encode_compound_hdr(xdr, req, &hdr); |
2826 | encode_sequence(xdr, &args->seq_args, &hdr); | |
b03d735b CL |
2827 | if (args->migration) { |
2828 | encode_putfh(xdr, args->fh, &hdr); | |
2829 | replen = hdr.replen; | |
2830 | encode_fs_locations(xdr, args->bitmask, &hdr); | |
2831 | if (args->renew) | |
2832 | encode_renew(xdr, args->clientid, &hdr); | |
2833 | } else { | |
2834 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2835 | encode_lookup(xdr, args->name, &hdr); | |
2836 | replen = hdr.replen; | |
2837 | encode_fs_locations(xdr, args->bitmask, &hdr); | |
2838 | } | |
cf8cdbe5 | 2839 | |
cf500bac | 2840 | rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, |
9ed5af26 | 2841 | PAGE_SIZE, replen); |
d017931c | 2842 | encode_nops(&hdr); |
683b57b4 TM |
2843 | } |
2844 | ||
5a5ea0d4 BS |
2845 | /* |
2846 | * Encode SECINFO request | |
2847 | */ | |
2848 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, | |
2849 | struct xdr_stream *xdr, | |
fcc85819 | 2850 | const void *data) |
5a5ea0d4 | 2851 | { |
fcc85819 | 2852 | const struct nfs4_secinfo_arg *args = data; |
5a5ea0d4 BS |
2853 | struct compound_hdr hdr = { |
2854 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2855 | }; | |
2856 | ||
2857 | encode_compound_hdr(xdr, req, &hdr); | |
2858 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2859 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2860 | encode_secinfo(xdr, args->name, &hdr); | |
2861 | encode_nops(&hdr); | |
2862 | } | |
2863 | ||
44c99933 CL |
2864 | /* |
2865 | * Encode FSID_PRESENT request | |
2866 | */ | |
2867 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, | |
2868 | struct xdr_stream *xdr, | |
fcc85819 | 2869 | const void *data) |
44c99933 | 2870 | { |
fcc85819 | 2871 | const struct nfs4_fsid_present_arg *args = data; |
44c99933 CL |
2872 | struct compound_hdr hdr = { |
2873 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2874 | }; | |
2875 | ||
2876 | encode_compound_hdr(xdr, req, &hdr); | |
2877 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2878 | encode_putfh(xdr, args->fh, &hdr); | |
2879 | encode_getfh(xdr, &hdr); | |
2880 | if (args->renew) | |
2881 | encode_renew(xdr, args->clientid, &hdr); | |
2882 | encode_nops(&hdr); | |
2883 | } | |
2884 | ||
99fe60d0 | 2885 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
2886 | /* |
2887 | * BIND_CONN_TO_SESSION request | |
2888 | */ | |
2889 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, | |
2890 | struct xdr_stream *xdr, | |
fcc85819 | 2891 | const void *data) |
7c44f1ae | 2892 | { |
fcc85819 | 2893 | const struct nfs41_bind_conn_to_session_args *args = data; |
7c44f1ae | 2894 | struct compound_hdr hdr = { |
71a097c6 | 2895 | .minorversion = args->client->cl_mvops->minor_version, |
7c44f1ae WAA |
2896 | }; |
2897 | ||
2898 | encode_compound_hdr(xdr, req, &hdr); | |
71a097c6 | 2899 | encode_bind_conn_to_session(xdr, args, &hdr); |
7c44f1ae WAA |
2900 | encode_nops(&hdr); |
2901 | } | |
2902 | ||
99fe60d0 BH |
2903 | /* |
2904 | * EXCHANGE_ID request | |
2905 | */ | |
9f06c719 CL |
2906 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
2907 | struct xdr_stream *xdr, | |
fcc85819 | 2908 | const void *data) |
99fe60d0 | 2909 | { |
fcc85819 | 2910 | const struct nfs41_exchange_id_args *args = data; |
99fe60d0 | 2911 | struct compound_hdr hdr = { |
a4432345 | 2912 | .minorversion = args->client->cl_mvops->minor_version, |
99fe60d0 BH |
2913 | }; |
2914 | ||
9f06c719 CL |
2915 | encode_compound_hdr(xdr, req, &hdr); |
2916 | encode_exchange_id(xdr, args, &hdr); | |
99fe60d0 | 2917 | encode_nops(&hdr); |
99fe60d0 | 2918 | } |
2050f0cc | 2919 | |
fc931582 AA |
2920 | /* |
2921 | * a CREATE_SESSION request | |
2922 | */ | |
9f06c719 CL |
2923 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
2924 | struct xdr_stream *xdr, | |
fcc85819 | 2925 | const void *data) |
fc931582 | 2926 | { |
fcc85819 | 2927 | const struct nfs41_create_session_args *args = data; |
fc931582 | 2928 | struct compound_hdr hdr = { |
a4432345 | 2929 | .minorversion = args->client->cl_mvops->minor_version, |
fc931582 AA |
2930 | }; |
2931 | ||
9f06c719 CL |
2932 | encode_compound_hdr(xdr, req, &hdr); |
2933 | encode_create_session(xdr, args, &hdr); | |
fc931582 | 2934 | encode_nops(&hdr); |
fc931582 AA |
2935 | } |
2936 | ||
0f3e66c6 AA |
2937 | /* |
2938 | * a DESTROY_SESSION request | |
2939 | */ | |
9f06c719 CL |
2940 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
2941 | struct xdr_stream *xdr, | |
fcc85819 | 2942 | const void *data) |
0f3e66c6 | 2943 | { |
fcc85819 | 2944 | const struct nfs4_session *session = data; |
0f3e66c6 | 2945 | struct compound_hdr hdr = { |
a4432345 | 2946 | .minorversion = session->clp->cl_mvops->minor_version, |
0f3e66c6 AA |
2947 | }; |
2948 | ||
9f06c719 CL |
2949 | encode_compound_hdr(xdr, req, &hdr); |
2950 | encode_destroy_session(xdr, session, &hdr); | |
0f3e66c6 | 2951 | encode_nops(&hdr); |
0f3e66c6 AA |
2952 | } |
2953 | ||
66245539 TM |
2954 | /* |
2955 | * a DESTROY_CLIENTID request | |
2956 | */ | |
2957 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, | |
2958 | struct xdr_stream *xdr, | |
fcc85819 | 2959 | const void *data) |
66245539 | 2960 | { |
fcc85819 | 2961 | const struct nfs_client *clp = data; |
66245539 TM |
2962 | struct compound_hdr hdr = { |
2963 | .minorversion = clp->cl_mvops->minor_version, | |
2964 | }; | |
2965 | ||
2966 | encode_compound_hdr(xdr, req, &hdr); | |
2967 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); | |
2968 | encode_nops(&hdr); | |
2969 | } | |
2970 | ||
fc01cea9 AA |
2971 | /* |
2972 | * a SEQUENCE request | |
2973 | */ | |
9f06c719 | 2974 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 2975 | const void *data) |
fc01cea9 | 2976 | { |
fcc85819 | 2977 | const struct nfs4_sequence_args *args = data; |
fc01cea9 AA |
2978 | struct compound_hdr hdr = { |
2979 | .minorversion = nfs4_xdr_minorversion(args), | |
2980 | }; | |
2981 | ||
9f06c719 CL |
2982 | encode_compound_hdr(xdr, req, &hdr); |
2983 | encode_sequence(xdr, args, &hdr); | |
fc01cea9 | 2984 | encode_nops(&hdr); |
fc01cea9 AA |
2985 | } |
2986 | ||
0efb01b2 DB |
2987 | #endif |
2988 | ||
2050f0cc AA |
2989 | /* |
2990 | * a GET_LEASE_TIME request | |
2991 | */ | |
9f06c719 CL |
2992 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
2993 | struct xdr_stream *xdr, | |
fcc85819 | 2994 | const void *data) |
2050f0cc | 2995 | { |
fcc85819 | 2996 | const struct nfs4_get_lease_time_args *args = data; |
2050f0cc AA |
2997 | struct compound_hdr hdr = { |
2998 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), | |
2999 | }; | |
dae100c2 | 3000 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
2050f0cc | 3001 | |
9f06c719 CL |
3002 | encode_compound_hdr(xdr, req, &hdr); |
3003 | encode_sequence(xdr, &args->la_seq_args, &hdr); | |
3004 | encode_putrootfh(xdr, &hdr); | |
3005 | encode_fsinfo(xdr, lease_bitmap, &hdr); | |
2050f0cc | 3006 | encode_nops(&hdr); |
2050f0cc | 3007 | } |
18019753 | 3008 | |
0efb01b2 DB |
3009 | #ifdef CONFIG_NFS_V4_1 |
3010 | ||
18019753 RL |
3011 | /* |
3012 | * a RECLAIM_COMPLETE request | |
3013 | */ | |
9f06c719 CL |
3014 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
3015 | struct xdr_stream *xdr, | |
fcc85819 | 3016 | const void *data) |
18019753 | 3017 | { |
fcc85819 | 3018 | const struct nfs41_reclaim_complete_args *args = data; |
18019753 RL |
3019 | struct compound_hdr hdr = { |
3020 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | |
3021 | }; | |
3022 | ||
9f06c719 CL |
3023 | encode_compound_hdr(xdr, req, &hdr); |
3024 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3025 | encode_reclaim_complete(xdr, args, &hdr); | |
18019753 | 3026 | encode_nops(&hdr); |
18019753 RL |
3027 | } |
3028 | ||
b1f69b75 AA |
3029 | /* |
3030 | * Encode GETDEVICEINFO request | |
3031 | */ | |
9f06c719 CL |
3032 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
3033 | struct xdr_stream *xdr, | |
fcc85819 | 3034 | const void *data) |
b1f69b75 | 3035 | { |
fcc85819 | 3036 | const struct nfs4_getdeviceinfo_args *args = data; |
b1f69b75 AA |
3037 | struct compound_hdr hdr = { |
3038 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3039 | }; | |
046e5ccb | 3040 | uint32_t replen; |
b1f69b75 | 3041 | |
9f06c719 CL |
3042 | encode_compound_hdr(xdr, req, &hdr); |
3043 | encode_sequence(xdr, &args->seq_args, &hdr); | |
046e5ccb | 3044 | |
9ed5af26 | 3045 | replen = hdr.replen + op_decode_hdr_maxsz + 2; |
046e5ccb | 3046 | |
9f06c719 | 3047 | encode_getdeviceinfo(xdr, args, &hdr); |
b1f69b75 | 3048 | |
046e5ccb TM |
3049 | /* set up reply kvec. device_addr4 opaque data is read into the |
3050 | * pages */ | |
cf500bac | 3051 | rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase, |
9ed5af26 | 3052 | args->pdev->pglen, replen); |
b1f69b75 | 3053 | encode_nops(&hdr); |
b1f69b75 AA |
3054 | } |
3055 | ||
3056 | /* | |
3057 | * Encode LAYOUTGET request | |
3058 | */ | |
9f06c719 CL |
3059 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
3060 | struct xdr_stream *xdr, | |
fcc85819 | 3061 | const void *data) |
b1f69b75 | 3062 | { |
fcc85819 | 3063 | const struct nfs4_layoutget_args *args = data; |
b1f69b75 AA |
3064 | struct compound_hdr hdr = { |
3065 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3066 | }; | |
3067 | ||
9f06c719 CL |
3068 | encode_compound_hdr(xdr, req, &hdr); |
3069 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3070 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
3071 | encode_layoutget(xdr, args, &hdr); | |
35124a09 | 3072 | |
cf500bac | 3073 | rpc_prepare_reply_pages(req, args->layout.pages, 0, |
9ed5af26 | 3074 | args->layout.pglen, hdr.replen - pagepad_maxsz); |
b1f69b75 | 3075 | encode_nops(&hdr); |
b1f69b75 | 3076 | } |
863a3c6c AA |
3077 | |
3078 | /* | |
3079 | * Encode LAYOUTCOMMIT request | |
3080 | */ | |
cbe82603 BH |
3081 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
3082 | struct xdr_stream *xdr, | |
fcc85819 | 3083 | const void *priv) |
863a3c6c | 3084 | { |
fcc85819 | 3085 | const struct nfs4_layoutcommit_args *args = priv; |
ac7db726 BH |
3086 | struct nfs4_layoutcommit_data *data = |
3087 | container_of(args, struct nfs4_layoutcommit_data, args); | |
863a3c6c AA |
3088 | struct compound_hdr hdr = { |
3089 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3090 | }; | |
3091 | ||
3092 | encode_compound_hdr(xdr, req, &hdr); | |
3093 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3094 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
ac7db726 | 3095 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
863a3c6c | 3096 | encode_getfattr(xdr, args->bitmask, &hdr); |
b1f69b75 | 3097 | encode_nops(&hdr); |
cbe82603 BH |
3098 | } |
3099 | ||
3100 | /* | |
3101 | * Encode LAYOUTRETURN request | |
3102 | */ | |
3103 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, | |
3104 | struct xdr_stream *xdr, | |
fcc85819 | 3105 | const void *data) |
cbe82603 | 3106 | { |
fcc85819 | 3107 | const struct nfs4_layoutreturn_args *args = data; |
cbe82603 BH |
3108 | struct compound_hdr hdr = { |
3109 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3110 | }; | |
3111 | ||
3112 | encode_compound_hdr(xdr, req, &hdr); | |
3113 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3114 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
3115 | encode_layoutreturn(xdr, args, &hdr); | |
3116 | encode_nops(&hdr); | |
b1f69b75 | 3117 | } |
fca78d6d BS |
3118 | |
3119 | /* | |
3120 | * Encode SECINFO_NO_NAME request | |
3121 | */ | |
fcc85819 | 3122 | static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
fca78d6d | 3123 | struct xdr_stream *xdr, |
fcc85819 | 3124 | const void *data) |
fca78d6d | 3125 | { |
fcc85819 | 3126 | const struct nfs41_secinfo_no_name_args *args = data; |
fca78d6d BS |
3127 | struct compound_hdr hdr = { |
3128 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3129 | }; | |
3130 | ||
3131 | encode_compound_hdr(xdr, req, &hdr); | |
3132 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3133 | encode_putrootfh(xdr, &hdr); | |
3134 | encode_secinfo_no_name(xdr, args, &hdr); | |
3135 | encode_nops(&hdr); | |
fca78d6d | 3136 | } |
7d974794 BS |
3137 | |
3138 | /* | |
3139 | * Encode TEST_STATEID request | |
3140 | */ | |
3141 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, | |
3142 | struct xdr_stream *xdr, | |
fcc85819 | 3143 | const void *data) |
7d974794 | 3144 | { |
fcc85819 | 3145 | const struct nfs41_test_stateid_args *args = data; |
7d974794 BS |
3146 | struct compound_hdr hdr = { |
3147 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3148 | }; | |
3149 | ||
3150 | encode_compound_hdr(xdr, req, &hdr); | |
3151 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3152 | encode_test_stateid(xdr, args, &hdr); | |
3153 | encode_nops(&hdr); | |
3154 | } | |
9aeda35f BS |
3155 | |
3156 | /* | |
3157 | * Encode FREE_STATEID request | |
3158 | */ | |
3159 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, | |
3160 | struct xdr_stream *xdr, | |
fcc85819 | 3161 | const void *data) |
9aeda35f | 3162 | { |
fcc85819 | 3163 | const struct nfs41_free_stateid_args *args = data; |
9aeda35f BS |
3164 | struct compound_hdr hdr = { |
3165 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3166 | }; | |
3167 | ||
3168 | encode_compound_hdr(xdr, req, &hdr); | |
3169 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3170 | encode_free_stateid(xdr, args, &hdr); | |
3171 | encode_nops(&hdr); | |
3172 | } | |
99fe60d0 BH |
3173 | #endif /* CONFIG_NFS_V4_1 */ |
3174 | ||
683b57b4 | 3175 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
1da177e4 | 3176 | { |
6da59ce2 TM |
3177 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
3178 | NFS4_OPAQUE_LIMIT); | |
eb72f484 | 3179 | if (unlikely(ret < 0)) |
6da59ce2 | 3180 | return -EIO; |
6da59ce2 | 3181 | *len = ret; |
1da177e4 LT |
3182 | return 0; |
3183 | } | |
3184 | ||
3185 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) | |
3186 | { | |
6659db4c TM |
3187 | ssize_t ret; |
3188 | void *ptr; | |
3189 | u32 tmp; | |
1da177e4 | 3190 | |
6659db4c | 3191 | if (xdr_stream_decode_u32(xdr, &tmp) < 0) |
eb72f484 | 3192 | return -EIO; |
6659db4c | 3193 | hdr->status = tmp; |
6c0195a4 | 3194 | |
6659db4c TM |
3195 | ret = xdr_stream_decode_opaque_inline(xdr, &ptr, NFS4_OPAQUE_LIMIT); |
3196 | if (ret < 0) | |
3197 | return -EIO; | |
3198 | hdr->taglen = ret; | |
3199 | hdr->tag = ptr; | |
3200 | ||
3201 | if (xdr_stream_decode_u32(xdr, &tmp) < 0) | |
eb72f484 | 3202 | return -EIO; |
6659db4c | 3203 | hdr->nops = tmp; |
aadf6152 BH |
3204 | if (unlikely(hdr->nops < 1)) |
3205 | return nfs4_stat_to_errno(hdr->status); | |
1da177e4 LT |
3206 | return 0; |
3207 | } | |
3208 | ||
c7848f69 TM |
3209 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
3210 | int *nfs_retval) | |
1da177e4 | 3211 | { |
8687b63a | 3212 | __be32 *p; |
1da177e4 LT |
3213 | uint32_t opnum; |
3214 | int32_t nfserr; | |
3215 | ||
c0eae66e BH |
3216 | p = xdr_inline_decode(xdr, 8); |
3217 | if (unlikely(!p)) | |
3218 | goto out_overflow; | |
6f723f77 | 3219 | opnum = be32_to_cpup(p++); |
c7848f69 TM |
3220 | if (unlikely(opnum != expected)) |
3221 | goto out_bad_operation; | |
f23f6584 CL |
3222 | if (unlikely(*p != cpu_to_be32(NFS_OK))) |
3223 | goto out_status; | |
3224 | *nfs_retval = 0; | |
3225 | return true; | |
3226 | out_status: | |
cccddf4f | 3227 | nfserr = be32_to_cpup(p); |
62a92ba9 | 3228 | trace_nfs4_xdr_status(xdr, opnum, nfserr); |
f23f6584 | 3229 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
c7848f69 TM |
3230 | return true; |
3231 | out_bad_operation: | |
da934ae0 | 3232 | trace_nfs4_xdr_bad_operation(xdr, opnum, expected); |
c7848f69 TM |
3233 | *nfs_retval = -EREMOTEIO; |
3234 | return false; | |
c0eae66e | 3235 | out_overflow: |
c7848f69 TM |
3236 | *nfs_retval = -EIO; |
3237 | return false; | |
3238 | } | |
3239 | ||
3240 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | |
3241 | { | |
3242 | int retval; | |
3243 | ||
3244 | __decode_op_hdr(xdr, expected, &retval); | |
3245 | return retval; | |
1da177e4 LT |
3246 | } |
3247 | ||
3248 | /* Dummy routine */ | |
1bbe60ff | 3249 | static int decode_ace(struct xdr_stream *xdr, void *ace) |
1da177e4 | 3250 | { |
8687b63a | 3251 | __be32 *p; |
683b57b4 | 3252 | unsigned int strlen; |
1da177e4 LT |
3253 | char *str; |
3254 | ||
c0eae66e | 3255 | p = xdr_inline_decode(xdr, 12); |
eb72f484 CL |
3256 | if (unlikely(!p)) |
3257 | return -EIO; | |
3258 | return decode_opaque_inline(xdr, &strlen, &str); | |
1da177e4 LT |
3259 | } |
3260 | ||
37c88763 TM |
3261 | static ssize_t |
3262 | decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz) | |
1da177e4 | 3263 | { |
37c88763 | 3264 | ssize_t ret; |
1da177e4 | 3265 | |
37c88763 TM |
3266 | ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz); |
3267 | if (likely(ret >= 0)) | |
3268 | return ret; | |
eb72f484 CL |
3269 | if (ret != -EMSGSIZE) |
3270 | return -EIO; | |
3271 | return sz; | |
1da177e4 LT |
3272 | } |
3273 | ||
37c88763 TM |
3274 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
3275 | { | |
3276 | ssize_t ret; | |
3277 | ret = decode_bitmap4(xdr, bitmap, 3); | |
3278 | return ret < 0 ? ret : 0; | |
3279 | } | |
3280 | ||
256e48bb | 3281 | static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep) |
1da177e4 | 3282 | { |
8687b63a | 3283 | __be32 *p; |
1da177e4 | 3284 | |
c0eae66e BH |
3285 | p = xdr_inline_decode(xdr, 4); |
3286 | if (unlikely(!p)) | |
eb72f484 | 3287 | return -EIO; |
cccddf4f | 3288 | *attrlen = be32_to_cpup(p); |
256e48bb | 3289 | *savep = xdr_stream_pos(xdr); |
1da177e4 LT |
3290 | return 0; |
3291 | } | |
3292 | ||
3293 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) | |
3294 | { | |
3295 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { | |
3388bff5 RB |
3296 | int ret; |
3297 | ret = decode_attr_bitmap(xdr, bitmask); | |
3298 | if (unlikely(ret < 0)) | |
3299 | return ret; | |
1da177e4 LT |
3300 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
3301 | } else | |
dae100c2 FI |
3302 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
3303 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, | |
3304 | bitmask[0], bitmask[1], bitmask[2]); | |
1da177e4 LT |
3305 | return 0; |
3306 | } | |
3307 | ||
3308 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) | |
3309 | { | |
8687b63a | 3310 | __be32 *p; |
409924e4 | 3311 | int ret = 0; |
1da177e4 LT |
3312 | |
3313 | *type = 0; | |
3314 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) | |
3315 | return -EIO; | |
3316 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { | |
c0eae66e BH |
3317 | p = xdr_inline_decode(xdr, 4); |
3318 | if (unlikely(!p)) | |
eb72f484 | 3319 | return -EIO; |
cccddf4f | 3320 | *type = be32_to_cpup(p); |
1da177e4 | 3321 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
3110ff80 | 3322 | dprintk("%s: bad type %d\n", __func__, *type); |
1da177e4 LT |
3323 | return -EIO; |
3324 | } | |
3325 | bitmap[0] &= ~FATTR4_WORD0_TYPE; | |
409924e4 | 3326 | ret = NFS_ATTR_FATTR_TYPE; |
1da177e4 | 3327 | } |
bca79478 | 3328 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
409924e4 | 3329 | return ret; |
1da177e4 LT |
3330 | } |
3331 | ||
264e6351 CL |
3332 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
3333 | uint32_t *bitmap, uint32_t *type) | |
3334 | { | |
3335 | __be32 *p; | |
3336 | ||
3337 | *type = 0; | |
3338 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) | |
3339 | return -EIO; | |
3340 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { | |
3341 | p = xdr_inline_decode(xdr, 4); | |
3342 | if (unlikely(!p)) | |
eb72f484 | 3343 | return -EIO; |
264e6351 CL |
3344 | *type = be32_to_cpup(p); |
3345 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; | |
3346 | } | |
3347 | dprintk("%s: expire type=0x%x\n", __func__, *type); | |
3348 | return 0; | |
264e6351 CL |
3349 | } |
3350 | ||
1da177e4 LT |
3351 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
3352 | { | |
8687b63a | 3353 | __be32 *p; |
409924e4 | 3354 | int ret = 0; |
1da177e4 LT |
3355 | |
3356 | *change = 0; | |
3357 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) | |
3358 | return -EIO; | |
3359 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { | |
c0eae66e BH |
3360 | p = xdr_inline_decode(xdr, 8); |
3361 | if (unlikely(!p)) | |
eb72f484 | 3362 | return -EIO; |
cccddf4f | 3363 | xdr_decode_hyper(p, change); |
1da177e4 | 3364 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
409924e4 | 3365 | ret = NFS_ATTR_FATTR_CHANGE; |
1da177e4 | 3366 | } |
3110ff80 | 3367 | dprintk("%s: change attribute=%Lu\n", __func__, |
1da177e4 | 3368 | (unsigned long long)*change); |
409924e4 | 3369 | return ret; |
1da177e4 LT |
3370 | } |
3371 | ||
3372 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) | |
3373 | { | |
8687b63a | 3374 | __be32 *p; |
409924e4 | 3375 | int ret = 0; |
1da177e4 LT |
3376 | |
3377 | *size = 0; | |
3378 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) | |
3379 | return -EIO; | |
3380 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { | |
c0eae66e BH |
3381 | p = xdr_inline_decode(xdr, 8); |
3382 | if (unlikely(!p)) | |
eb72f484 | 3383 | return -EIO; |
cccddf4f | 3384 | xdr_decode_hyper(p, size); |
1da177e4 | 3385 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
409924e4 | 3386 | ret = NFS_ATTR_FATTR_SIZE; |
1da177e4 | 3387 | } |
3110ff80 | 3388 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
409924e4 | 3389 | return ret; |
1da177e4 LT |
3390 | } |
3391 | ||
3392 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3393 | { | |
8687b63a | 3394 | __be32 *p; |
1da177e4 LT |
3395 | |
3396 | *res = 0; | |
3397 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) | |
3398 | return -EIO; | |
3399 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { | |
c0eae66e BH |
3400 | p = xdr_inline_decode(xdr, 4); |
3401 | if (unlikely(!p)) | |
eb72f484 | 3402 | return -EIO; |
cccddf4f | 3403 | *res = be32_to_cpup(p); |
1da177e4 LT |
3404 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
3405 | } | |
3110ff80 | 3406 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
1da177e4 LT |
3407 | return 0; |
3408 | } | |
3409 | ||
3410 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3411 | { | |
8687b63a | 3412 | __be32 *p; |
1da177e4 LT |
3413 | |
3414 | *res = 0; | |
3415 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) | |
3416 | return -EIO; | |
3417 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { | |
c0eae66e BH |
3418 | p = xdr_inline_decode(xdr, 4); |
3419 | if (unlikely(!p)) | |
eb72f484 | 3420 | return -EIO; |
cccddf4f | 3421 | *res = be32_to_cpup(p); |
1da177e4 LT |
3422 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
3423 | } | |
3110ff80 | 3424 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
1da177e4 LT |
3425 | return 0; |
3426 | } | |
3427 | ||
8b4bdcf8 | 3428 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
1da177e4 | 3429 | { |
8687b63a | 3430 | __be32 *p; |
409924e4 | 3431 | int ret = 0; |
1da177e4 LT |
3432 | |
3433 | fsid->major = 0; | |
3434 | fsid->minor = 0; | |
3435 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) | |
3436 | return -EIO; | |
3437 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { | |
c0eae66e BH |
3438 | p = xdr_inline_decode(xdr, 16); |
3439 | if (unlikely(!p)) | |
eb72f484 | 3440 | return -EIO; |
3ceb4dbb | 3441 | p = xdr_decode_hyper(p, &fsid->major); |
cccddf4f | 3442 | xdr_decode_hyper(p, &fsid->minor); |
1da177e4 | 3443 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
409924e4 | 3444 | ret = NFS_ATTR_FATTR_FSID; |
1da177e4 | 3445 | } |
3110ff80 | 3446 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
1da177e4 LT |
3447 | (unsigned long long)fsid->major, |
3448 | (unsigned long long)fsid->minor); | |
409924e4 | 3449 | return ret; |
1da177e4 LT |
3450 | } |
3451 | ||
3452 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3453 | { | |
8687b63a | 3454 | __be32 *p; |
1da177e4 LT |
3455 | |
3456 | *res = 60; | |
3457 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) | |
3458 | return -EIO; | |
3459 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { | |
c0eae66e BH |
3460 | p = xdr_inline_decode(xdr, 4); |
3461 | if (unlikely(!p)) | |
eb72f484 | 3462 | return -EIO; |
cccddf4f | 3463 | *res = be32_to_cpup(p); |
1da177e4 LT |
3464 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
3465 | } | |
2eaf426d | 3466 | dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res); |
1da177e4 LT |
3467 | return 0; |
3468 | } | |
3469 | ||
ee7b75fc | 3470 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
ae42c70a BS |
3471 | { |
3472 | __be32 *p; | |
3473 | ||
3474 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) | |
3475 | return -EIO; | |
3476 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { | |
3477 | p = xdr_inline_decode(xdr, 4); | |
3478 | if (unlikely(!p)) | |
eb72f484 | 3479 | return -EIO; |
ae42c70a | 3480 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
ee7b75fc | 3481 | *res = -be32_to_cpup(p); |
ae42c70a BS |
3482 | } |
3483 | return 0; | |
ae42c70a BS |
3484 | } |
3485 | ||
8c61282f KM |
3486 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
3487 | uint32_t *bitmap, uint32_t *bitmask) | |
3488 | { | |
3489 | if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) { | |
3490 | int ret; | |
3491 | ret = decode_attr_bitmap(xdr, bitmask); | |
3492 | if (unlikely(ret < 0)) | |
3493 | return ret; | |
3494 | bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT; | |
3495 | } else | |
3496 | bitmask[0] = bitmask[1] = bitmask[2] = 0; | |
3497 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, | |
3498 | bitmask[0], bitmask[1], bitmask[2]); | |
3499 | return 0; | |
3500 | } | |
3501 | ||
ae42c70a BS |
3502 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
3503 | { | |
3504 | __be32 *p; | |
86bbd742 | 3505 | u32 len; |
ae42c70a | 3506 | |
7ad07353 TM |
3507 | if (fh != NULL) |
3508 | memset(fh, 0, sizeof(*fh)); | |
ae42c70a BS |
3509 | |
3510 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) | |
3511 | return -EIO; | |
3512 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { | |
3513 | p = xdr_inline_decode(xdr, 4); | |
3514 | if (unlikely(!p)) | |
eb72f484 | 3515 | return -EIO; |
ae42c70a | 3516 | len = be32_to_cpup(p); |
eb3d58c6 TM |
3517 | if (len > NFS4_FHSIZE || len == 0) { |
3518 | trace_nfs4_xdr_bad_filehandle(xdr, OP_READDIR, | |
3519 | NFS4ERR_BADHANDLE); | |
3520 | return -EREMOTEIO; | |
3521 | } | |
ae42c70a BS |
3522 | p = xdr_inline_decode(xdr, len); |
3523 | if (unlikely(!p)) | |
eb72f484 | 3524 | return -EIO; |
7ad07353 TM |
3525 | if (fh != NULL) { |
3526 | memcpy(fh->data, p, len); | |
3527 | fh->size = len; | |
3528 | } | |
ae42c70a BS |
3529 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
3530 | } | |
3531 | return 0; | |
ae42c70a BS |
3532 | } |
3533 | ||
1da177e4 LT |
3534 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
3535 | { | |
8687b63a | 3536 | __be32 *p; |
1da177e4 | 3537 | |
a1800aca | 3538 | *res = 0; |
1da177e4 LT |
3539 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
3540 | return -EIO; | |
3541 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { | |
c0eae66e BH |
3542 | p = xdr_inline_decode(xdr, 4); |
3543 | if (unlikely(!p)) | |
eb72f484 | 3544 | return -EIO; |
cccddf4f | 3545 | *res = be32_to_cpup(p); |
1da177e4 LT |
3546 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
3547 | } | |
3110ff80 | 3548 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
1da177e4 LT |
3549 | return 0; |
3550 | } | |
3551 | ||
1ab5be4a TM |
3552 | static int decode_attr_case_insensitive(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
3553 | { | |
3554 | __be32 *p; | |
3555 | ||
3556 | *res = 0; | |
3557 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_INSENSITIVE - 1U))) | |
3558 | return -EIO; | |
3559 | if (likely(bitmap[0] & FATTR4_WORD0_CASE_INSENSITIVE)) { | |
3560 | p = xdr_inline_decode(xdr, 4); | |
3561 | if (unlikely(!p)) | |
3562 | return -EIO; | |
3563 | *res = be32_to_cpup(p); | |
3564 | bitmap[0] &= ~FATTR4_WORD0_CASE_INSENSITIVE; | |
3565 | } | |
3566 | dprintk("%s: case_insensitive=%s\n", __func__, *res == 0 ? "false" : "true"); | |
3567 | return 0; | |
3568 | } | |
3569 | ||
3570 | static int decode_attr_case_preserving(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3571 | { | |
3572 | __be32 *p; | |
3573 | ||
3574 | *res = 0; | |
3575 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_PRESERVING - 1U))) | |
3576 | return -EIO; | |
3577 | if (likely(bitmap[0] & FATTR4_WORD0_CASE_PRESERVING)) { | |
3578 | p = xdr_inline_decode(xdr, 4); | |
3579 | if (unlikely(!p)) | |
3580 | return -EIO; | |
3581 | *res = be32_to_cpup(p); | |
3582 | bitmap[0] &= ~FATTR4_WORD0_CASE_PRESERVING; | |
3583 | } | |
3584 | dprintk("%s: case_preserving=%s\n", __func__, *res == 0 ? "false" : "true"); | |
3585 | return 0; | |
3586 | } | |
3587 | ||
1da177e4 LT |
3588 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
3589 | { | |
8687b63a | 3590 | __be32 *p; |
409924e4 | 3591 | int ret = 0; |
1da177e4 LT |
3592 | |
3593 | *fileid = 0; | |
3594 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) | |
3595 | return -EIO; | |
3596 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { | |
c0eae66e BH |
3597 | p = xdr_inline_decode(xdr, 8); |
3598 | if (unlikely(!p)) | |
eb72f484 | 3599 | return -EIO; |
cccddf4f | 3600 | xdr_decode_hyper(p, fileid); |
1da177e4 | 3601 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
409924e4 | 3602 | ret = NFS_ATTR_FATTR_FILEID; |
1da177e4 | 3603 | } |
3110ff80 | 3604 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
409924e4 | 3605 | return ret; |
1da177e4 LT |
3606 | } |
3607 | ||
99baf625 MN |
3608 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
3609 | { | |
8687b63a | 3610 | __be32 *p; |
409924e4 | 3611 | int ret = 0; |
99baf625 MN |
3612 | |
3613 | *fileid = 0; | |
3614 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) | |
3615 | return -EIO; | |
3616 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { | |
c0eae66e BH |
3617 | p = xdr_inline_decode(xdr, 8); |
3618 | if (unlikely(!p)) | |
eb72f484 | 3619 | return -EIO; |
cccddf4f | 3620 | xdr_decode_hyper(p, fileid); |
99baf625 | 3621 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
28331a46 | 3622 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
99baf625 | 3623 | } |
3110ff80 | 3624 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
409924e4 | 3625 | return ret; |
99baf625 MN |
3626 | } |
3627 | ||
1da177e4 LT |
3628 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
3629 | { | |
8687b63a | 3630 | __be32 *p; |
1da177e4 LT |
3631 | int status = 0; |
3632 | ||
3633 | *res = 0; | |
3634 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) | |
3635 | return -EIO; | |
3636 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { | |
c0eae66e BH |
3637 | p = xdr_inline_decode(xdr, 8); |
3638 | if (unlikely(!p)) | |
eb72f484 | 3639 | return -EIO; |
cccddf4f | 3640 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3641 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
3642 | } | |
3110ff80 | 3643 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
3644 | return status; |
3645 | } | |
3646 | ||
3647 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3648 | { | |
8687b63a | 3649 | __be32 *p; |
1da177e4 LT |
3650 | int status = 0; |
3651 | ||
3652 | *res = 0; | |
3653 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) | |
3654 | return -EIO; | |
3655 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { | |
c0eae66e BH |
3656 | p = xdr_inline_decode(xdr, 8); |
3657 | if (unlikely(!p)) | |
eb72f484 | 3658 | return -EIO; |
cccddf4f | 3659 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3660 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
3661 | } | |
3110ff80 | 3662 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
3663 | return status; |
3664 | } | |
3665 | ||
3666 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3667 | { | |
8687b63a | 3668 | __be32 *p; |
1da177e4 LT |
3669 | int status = 0; |
3670 | ||
3671 | *res = 0; | |
3672 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) | |
3673 | return -EIO; | |
3674 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { | |
c0eae66e BH |
3675 | p = xdr_inline_decode(xdr, 8); |
3676 | if (unlikely(!p)) | |
eb72f484 | 3677 | return -EIO; |
cccddf4f | 3678 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3679 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
3680 | } | |
3110ff80 | 3681 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
3682 | return status; |
3683 | } | |
3684 | ||
7aaa0b3b MN |
3685 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
3686 | { | |
464ad6b1 | 3687 | u32 n; |
8687b63a | 3688 | __be32 *p; |
7aaa0b3b MN |
3689 | int status = 0; |
3690 | ||
c0eae66e BH |
3691 | p = xdr_inline_decode(xdr, 4); |
3692 | if (unlikely(!p)) | |
eb72f484 | 3693 | return -EIO; |
cccddf4f | 3694 | n = be32_to_cpup(p); |
33a43f28 AA |
3695 | if (n == 0) |
3696 | goto root_path; | |
02a2976c | 3697 | dprintk("pathname4: "); |
809b426c TM |
3698 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
3699 | dprintk("cannot parse %d components in path\n", n); | |
3700 | goto out_eio; | |
3701 | } | |
3702 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { | |
7aaa0b3b MN |
3703 | struct nfs4_string *component = &path->components[path->ncomponents]; |
3704 | status = decode_opaque_inline(xdr, &component->len, &component->data); | |
3705 | if (unlikely(status != 0)) | |
3706 | goto out_eio; | |
95a13f7b | 3707 | ifdebug (XDR) |
02a2976c CL |
3708 | pr_cont("%s%.*s ", |
3709 | (path->ncomponents != n ? "/ " : ""), | |
3710 | component->len, component->data); | |
7aaa0b3b MN |
3711 | } |
3712 | out: | |
7aaa0b3b | 3713 | return status; |
33a43f28 AA |
3714 | root_path: |
3715 | /* a root pathname is sent as a zero component4 */ | |
3716 | path->ncomponents = 1; | |
3717 | path->components[0].len=0; | |
3718 | path->components[0].data=NULL; | |
02a2976c | 3719 | dprintk("pathname4: /\n"); |
33a43f28 | 3720 | goto out; |
7aaa0b3b MN |
3721 | out_eio: |
3722 | dprintk(" status %d", status); | |
3723 | status = -EIO; | |
3724 | goto out; | |
3725 | } | |
3726 | ||
3727 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) | |
683b57b4 TM |
3728 | { |
3729 | int n; | |
8687b63a | 3730 | __be32 *p; |
683b57b4 TM |
3731 | int status = -EIO; |
3732 | ||
3733 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) | |
3734 | goto out; | |
3735 | status = 0; | |
3736 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) | |
3737 | goto out; | |
f54423a1 | 3738 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; |
8b7e3f49 TM |
3739 | status = -EIO; |
3740 | /* Ignore borken servers that return unrequested attrs */ | |
3741 | if (unlikely(res == NULL)) | |
3742 | goto out; | |
02a2976c | 3743 | dprintk("%s: fsroot:\n", __func__); |
7aaa0b3b | 3744 | status = decode_pathname(xdr, &res->fs_path); |
683b57b4 TM |
3745 | if (unlikely(status != 0)) |
3746 | goto out; | |
c0eae66e BH |
3747 | p = xdr_inline_decode(xdr, 4); |
3748 | if (unlikely(!p)) | |
eb72f484 | 3749 | goto out_eio; |
cccddf4f | 3750 | n = be32_to_cpup(p); |
809b426c | 3751 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
464ad6b1 | 3752 | u32 m; |
809b426c | 3753 | struct nfs4_fs_location *loc; |
683b57b4 | 3754 | |
809b426c TM |
3755 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
3756 | break; | |
3757 | loc = &res->locations[res->nlocations]; | |
c0eae66e BH |
3758 | p = xdr_inline_decode(xdr, 4); |
3759 | if (unlikely(!p)) | |
eb72f484 | 3760 | goto out_eio; |
cccddf4f | 3761 | m = be32_to_cpup(p); |
7aaa0b3b | 3762 | |
02a2976c | 3763 | dprintk("%s: servers:\n", __func__); |
809b426c TM |
3764 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
3765 | struct nfs4_string *server; | |
3766 | ||
3767 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { | |
464ad6b1 CL |
3768 | unsigned int i; |
3769 | dprintk("%s: using first %u of %u servers " | |
3770 | "returned for location %u\n", | |
3110ff80 | 3771 | __func__, |
464ad6b1 CL |
3772 | NFS4_FS_LOCATION_MAXSERVERS, |
3773 | m, res->nlocations); | |
7aaa0b3b | 3774 | for (i = loc->nservers; i < m; i++) { |
2e42c3e2 | 3775 | unsigned int len; |
7aaa0b3b MN |
3776 | char *data; |
3777 | status = decode_opaque_inline(xdr, &len, &data); | |
3778 | if (unlikely(status != 0)) | |
3779 | goto out_eio; | |
3780 | } | |
809b426c | 3781 | break; |
7aaa0b3b | 3782 | } |
809b426c TM |
3783 | server = &loc->servers[loc->nservers]; |
3784 | status = decode_opaque_inline(xdr, &server->len, &server->data); | |
3785 | if (unlikely(status != 0)) | |
3786 | goto out_eio; | |
3787 | dprintk("%s ", server->data); | |
7aaa0b3b MN |
3788 | } |
3789 | status = decode_pathname(xdr, &loc->rootpath); | |
683b57b4 TM |
3790 | if (unlikely(status != 0)) |
3791 | goto out_eio; | |
683b57b4 | 3792 | } |
409924e4 | 3793 | if (res->nlocations != 0) |
81934ddb | 3794 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
683b57b4 | 3795 | out: |
3110ff80 | 3796 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
683b57b4 TM |
3797 | return status; |
3798 | out_eio: | |
3799 | status = -EIO; | |
3800 | goto out; | |
3801 | } | |
3802 | ||
1da177e4 LT |
3803 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
3804 | { | |
8687b63a | 3805 | __be32 *p; |
1da177e4 LT |
3806 | int status = 0; |
3807 | ||
3808 | *res = 0; | |
3809 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) | |
3810 | return -EIO; | |
3811 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { | |
c0eae66e BH |
3812 | p = xdr_inline_decode(xdr, 8); |
3813 | if (unlikely(!p)) | |
eb72f484 | 3814 | return -EIO; |
cccddf4f | 3815 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3816 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
3817 | } | |
3110ff80 | 3818 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
3819 | return status; |
3820 | } | |
3821 | ||
3822 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) | |
3823 | { | |
8687b63a | 3824 | __be32 *p; |
1da177e4 LT |
3825 | int status = 0; |
3826 | ||
3827 | *maxlink = 1; | |
3828 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) | |
3829 | return -EIO; | |
3830 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { | |
c0eae66e BH |
3831 | p = xdr_inline_decode(xdr, 4); |
3832 | if (unlikely(!p)) | |
eb72f484 | 3833 | return -EIO; |
cccddf4f | 3834 | *maxlink = be32_to_cpup(p); |
1da177e4 LT |
3835 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
3836 | } | |
3110ff80 | 3837 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
1da177e4 LT |
3838 | return status; |
3839 | } | |
3840 | ||
3841 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) | |
3842 | { | |
8687b63a | 3843 | __be32 *p; |
1da177e4 LT |
3844 | int status = 0; |
3845 | ||
3846 | *maxname = 1024; | |
3847 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) | |
3848 | return -EIO; | |
3849 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { | |
c0eae66e BH |
3850 | p = xdr_inline_decode(xdr, 4); |
3851 | if (unlikely(!p)) | |
eb72f484 | 3852 | return -EIO; |
cccddf4f | 3853 | *maxname = be32_to_cpup(p); |
1da177e4 LT |
3854 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
3855 | } | |
3110ff80 | 3856 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
1da177e4 LT |
3857 | return status; |
3858 | } | |
3859 | ||
3860 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3861 | { | |
8687b63a | 3862 | __be32 *p; |
1da177e4 LT |
3863 | int status = 0; |
3864 | ||
3865 | *res = 1024; | |
3866 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) | |
3867 | return -EIO; | |
3868 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { | |
3869 | uint64_t maxread; | |
c0eae66e BH |
3870 | p = xdr_inline_decode(xdr, 8); |
3871 | if (unlikely(!p)) | |
eb72f484 | 3872 | return -EIO; |
cccddf4f | 3873 | xdr_decode_hyper(p, &maxread); |
1da177e4 LT |
3874 | if (maxread > 0x7FFFFFFF) |
3875 | maxread = 0x7FFFFFFF; | |
3876 | *res = (uint32_t)maxread; | |
3877 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; | |
3878 | } | |
3110ff80 | 3879 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
1da177e4 LT |
3880 | return status; |
3881 | } | |
3882 | ||
3883 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3884 | { | |
8687b63a | 3885 | __be32 *p; |
1da177e4 LT |
3886 | int status = 0; |
3887 | ||
3888 | *res = 1024; | |
3889 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) | |
3890 | return -EIO; | |
3891 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { | |
3892 | uint64_t maxwrite; | |
c0eae66e BH |
3893 | p = xdr_inline_decode(xdr, 8); |
3894 | if (unlikely(!p)) | |
eb72f484 | 3895 | return -EIO; |
cccddf4f | 3896 | xdr_decode_hyper(p, &maxwrite); |
1da177e4 LT |
3897 | if (maxwrite > 0x7FFFFFFF) |
3898 | maxwrite = 0x7FFFFFFF; | |
3899 | *res = (uint32_t)maxwrite; | |
3900 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; | |
3901 | } | |
3110ff80 | 3902 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
1da177e4 LT |
3903 | return status; |
3904 | } | |
3905 | ||
bca79478 | 3906 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) |
1da177e4 | 3907 | { |
bca79478 | 3908 | uint32_t tmp; |
8687b63a | 3909 | __be32 *p; |
409924e4 | 3910 | int ret = 0; |
1da177e4 LT |
3911 | |
3912 | *mode = 0; | |
3913 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) | |
3914 | return -EIO; | |
3915 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { | |
c0eae66e BH |
3916 | p = xdr_inline_decode(xdr, 4); |
3917 | if (unlikely(!p)) | |
eb72f484 | 3918 | return -EIO; |
cccddf4f | 3919 | tmp = be32_to_cpup(p); |
bca79478 | 3920 | *mode = tmp & ~S_IFMT; |
1da177e4 | 3921 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
409924e4 | 3922 | ret = NFS_ATTR_FATTR_MODE; |
1da177e4 | 3923 | } |
3110ff80 | 3924 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
409924e4 | 3925 | return ret; |
1da177e4 LT |
3926 | } |
3927 | ||
3928 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) | |
3929 | { | |
8687b63a | 3930 | __be32 *p; |
409924e4 | 3931 | int ret = 0; |
1da177e4 LT |
3932 | |
3933 | *nlink = 1; | |
3934 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) | |
3935 | return -EIO; | |
3936 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { | |
c0eae66e BH |
3937 | p = xdr_inline_decode(xdr, 4); |
3938 | if (unlikely(!p)) | |
eb72f484 | 3939 | return -EIO; |
cccddf4f | 3940 | *nlink = be32_to_cpup(p); |
1da177e4 | 3941 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
409924e4 | 3942 | ret = NFS_ATTR_FATTR_NLINK; |
1da177e4 | 3943 | } |
3110ff80 | 3944 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
409924e4 | 3945 | return ret; |
1da177e4 LT |
3946 | } |
3947 | ||
686a816a TM |
3948 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
3949 | struct nfs4_string *name, gfp_t gfp_flags) | |
3950 | { | |
3951 | ssize_t ret; | |
3952 | ||
3953 | ret = xdr_stream_decode_string_dup(xdr, &name->data, | |
3954 | XDR_MAX_NETOBJ, gfp_flags); | |
3955 | name->len = 0; | |
3956 | if (ret > 0) | |
3957 | name->len = ret; | |
3958 | return ret; | |
3959 | } | |
3960 | ||
80e52ace | 3961 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
e5782076 | 3962 | const struct nfs_server *server, kuid_t *uid, |
6926afd1 | 3963 | struct nfs4_string *owner_name) |
1da177e4 | 3964 | { |
686a816a TM |
3965 | ssize_t len; |
3966 | char *p; | |
1da177e4 | 3967 | |
e5782076 | 3968 | *uid = make_kuid(&init_user_ns, -2); |
1da177e4 LT |
3969 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
3970 | return -EIO; | |
686a816a TM |
3971 | if (!(bitmap[1] & FATTR4_WORD1_OWNER)) |
3972 | return 0; | |
3973 | bitmap[1] &= ~FATTR4_WORD1_OWNER; | |
3974 | ||
3975 | if (owner_name != NULL) { | |
e8d8aa46 | 3976 | len = decode_nfs4_string(xdr, owner_name, GFP_NOIO); |
686a816a TM |
3977 | if (len <= 0) |
3978 | goto out; | |
3979 | dprintk("%s: name=%s\n", __func__, owner_name->data); | |
3980 | return NFS_ATTR_FATTR_OWNER_NAME; | |
3981 | } else { | |
3982 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, | |
3983 | XDR_MAX_NETOBJ); | |
3984 | if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0) | |
3985 | goto out; | |
3986 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); | |
3987 | return NFS_ATTR_FATTR_OWNER; | |
1da177e4 | 3988 | } |
686a816a | 3989 | out: |
eb72f484 CL |
3990 | if (len == -EBADMSG) |
3991 | return -EIO; | |
3992 | return 0; | |
1da177e4 LT |
3993 | } |
3994 | ||
80e52ace | 3995 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
e5782076 | 3996 | const struct nfs_server *server, kgid_t *gid, |
6926afd1 | 3997 | struct nfs4_string *group_name) |
1da177e4 | 3998 | { |
686a816a TM |
3999 | ssize_t len; |
4000 | char *p; | |
1da177e4 | 4001 | |
e5782076 | 4002 | *gid = make_kgid(&init_user_ns, -2); |
1da177e4 LT |
4003 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
4004 | return -EIO; | |
686a816a TM |
4005 | if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) |
4006 | return 0; | |
4007 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; | |
4008 | ||
4009 | if (group_name != NULL) { | |
e8d8aa46 | 4010 | len = decode_nfs4_string(xdr, group_name, GFP_NOIO); |
686a816a TM |
4011 | if (len <= 0) |
4012 | goto out; | |
4013 | dprintk("%s: name=%s\n", __func__, group_name->data); | |
6f1f6220 | 4014 | return NFS_ATTR_FATTR_GROUP_NAME; |
686a816a TM |
4015 | } else { |
4016 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, | |
4017 | XDR_MAX_NETOBJ); | |
4018 | if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0) | |
4019 | goto out; | |
4020 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); | |
4021 | return NFS_ATTR_FATTR_GROUP; | |
1da177e4 | 4022 | } |
686a816a | 4023 | out: |
eb72f484 CL |
4024 | if (len == -EBADMSG) |
4025 | return -EIO; | |
4026 | return 0; | |
1da177e4 LT |
4027 | } |
4028 | ||
4029 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) | |
4030 | { | |
8687b63a AV |
4031 | uint32_t major = 0, minor = 0; |
4032 | __be32 *p; | |
409924e4 | 4033 | int ret = 0; |
1da177e4 LT |
4034 | |
4035 | *rdev = MKDEV(0,0); | |
4036 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) | |
4037 | return -EIO; | |
4038 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { | |
4039 | dev_t tmp; | |
4040 | ||
c0eae66e BH |
4041 | p = xdr_inline_decode(xdr, 8); |
4042 | if (unlikely(!p)) | |
eb72f484 | 4043 | return -EIO; |
6f723f77 | 4044 | major = be32_to_cpup(p++); |
cccddf4f | 4045 | minor = be32_to_cpup(p); |
1da177e4 LT |
4046 | tmp = MKDEV(major, minor); |
4047 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) | |
4048 | *rdev = tmp; | |
4049 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; | |
409924e4 | 4050 | ret = NFS_ATTR_FATTR_RDEV; |
1da177e4 | 4051 | } |
3110ff80 | 4052 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
409924e4 | 4053 | return ret; |
1da177e4 LT |
4054 | } |
4055 | ||
4056 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
4057 | { | |
8687b63a | 4058 | __be32 *p; |
1da177e4 LT |
4059 | int status = 0; |
4060 | ||
4061 | *res = 0; | |
4062 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) | |
4063 | return -EIO; | |
4064 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { | |
c0eae66e BH |
4065 | p = xdr_inline_decode(xdr, 8); |
4066 | if (unlikely(!p)) | |
eb72f484 | 4067 | return -EIO; |
cccddf4f | 4068 | xdr_decode_hyper(p, res); |
1da177e4 LT |
4069 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
4070 | } | |
3110ff80 | 4071 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
4072 | return status; |
4073 | } | |
4074 | ||
4075 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
4076 | { | |
8687b63a | 4077 | __be32 *p; |
1da177e4 LT |
4078 | int status = 0; |
4079 | ||
4080 | *res = 0; | |
4081 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) | |
4082 | return -EIO; | |
4083 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { | |
c0eae66e BH |
4084 | p = xdr_inline_decode(xdr, 8); |
4085 | if (unlikely(!p)) | |
eb72f484 | 4086 | return -EIO; |
cccddf4f | 4087 | xdr_decode_hyper(p, res); |
1da177e4 LT |
4088 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
4089 | } | |
3110ff80 | 4090 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
4091 | return status; |
4092 | } | |
4093 | ||
4094 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
4095 | { | |
8687b63a | 4096 | __be32 *p; |
1da177e4 LT |
4097 | int status = 0; |
4098 | ||
4099 | *res = 0; | |
4100 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) | |
4101 | return -EIO; | |
4102 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { | |
c0eae66e BH |
4103 | p = xdr_inline_decode(xdr, 8); |
4104 | if (unlikely(!p)) | |
eb72f484 | 4105 | return -EIO; |
cccddf4f | 4106 | xdr_decode_hyper(p, res); |
1da177e4 LT |
4107 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
4108 | } | |
3110ff80 | 4109 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 LT |
4110 | return status; |
4111 | } | |
4112 | ||
4113 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) | |
4114 | { | |
8687b63a | 4115 | __be32 *p; |
409924e4 | 4116 | int ret = 0; |
1da177e4 LT |
4117 | |
4118 | *used = 0; | |
4119 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) | |
4120 | return -EIO; | |
4121 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { | |
c0eae66e BH |
4122 | p = xdr_inline_decode(xdr, 8); |
4123 | if (unlikely(!p)) | |
eb72f484 | 4124 | return -EIO; |
cccddf4f | 4125 | xdr_decode_hyper(p, used); |
1da177e4 | 4126 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
409924e4 | 4127 | ret = NFS_ATTR_FATTR_SPACE_USED; |
1da177e4 | 4128 | } |
3110ff80 | 4129 | dprintk("%s: space used=%Lu\n", __func__, |
1da177e4 | 4130 | (unsigned long long)*used); |
409924e4 | 4131 | return ret; |
1da177e4 LT |
4132 | } |
4133 | ||
36b3743f | 4134 | static __be32 * |
e86d5a02 | 4135 | xdr_decode_nfstime4(__be32 *p, struct timespec64 *t) |
36b3743f TM |
4136 | { |
4137 | __u64 sec; | |
4138 | ||
4139 | p = xdr_decode_hyper(p, &sec); | |
e86d5a02 | 4140 | t-> tv_sec = sec; |
36b3743f TM |
4141 | t->tv_nsec = be32_to_cpup(p++); |
4142 | return p; | |
4143 | } | |
4144 | ||
e86d5a02 | 4145 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec64 *time) |
1da177e4 | 4146 | { |
8687b63a | 4147 | __be32 *p; |
1da177e4 | 4148 | |
36b3743f | 4149 | p = xdr_inline_decode(xdr, nfstime4_maxsz << 2); |
c0eae66e | 4150 | if (unlikely(!p)) |
eb72f484 | 4151 | return -EIO; |
36b3743f | 4152 | xdr_decode_nfstime4(p, time); |
1da177e4 LT |
4153 | return 0; |
4154 | } | |
4155 | ||
e86d5a02 | 4156 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
1da177e4 LT |
4157 | { |
4158 | int status = 0; | |
4159 | ||
4160 | time->tv_sec = 0; | |
4161 | time->tv_nsec = 0; | |
4162 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) | |
4163 | return -EIO; | |
4164 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { | |
4165 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4166 | if (status == 0) |
4167 | status = NFS_ATTR_FATTR_ATIME; | |
1da177e4 LT |
4168 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
4169 | } | |
ae08483c | 4170 | dprintk("%s: atime=%lld\n", __func__, time->tv_sec); |
1da177e4 LT |
4171 | return status; |
4172 | } | |
4173 | ||
e86d5a02 | 4174 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
1da177e4 LT |
4175 | { |
4176 | int status = 0; | |
4177 | ||
4178 | time->tv_sec = 0; | |
4179 | time->tv_nsec = 0; | |
4180 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) | |
4181 | return -EIO; | |
4182 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { | |
4183 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4184 | if (status == 0) |
4185 | status = NFS_ATTR_FATTR_CTIME; | |
1da177e4 LT |
4186 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
4187 | } | |
ae08483c | 4188 | dprintk("%s: ctime=%lld\n", __func__, time->tv_sec); |
1da177e4 LT |
4189 | return status; |
4190 | } | |
4191 | ||
55b6e774 | 4192 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
e86d5a02 | 4193 | struct timespec64 *time) |
55b6e774 RL |
4194 | { |
4195 | int status = 0; | |
4196 | ||
4197 | time->tv_sec = 0; | |
4198 | time->tv_nsec = 0; | |
4199 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) | |
4200 | return -EIO; | |
4201 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { | |
4202 | status = decode_attr_time(xdr, time); | |
4203 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; | |
4204 | } | |
ae08483c AB |
4205 | dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec, |
4206 | time->tv_nsec); | |
55b6e774 RL |
4207 | return status; |
4208 | } | |
4209 | ||
aa9c2669 DQ |
4210 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
4211 | struct nfs4_label *label) | |
4212 | { | |
4213 | uint32_t pi = 0; | |
4214 | uint32_t lfs = 0; | |
4215 | __u32 len; | |
4216 | __be32 *p; | |
4217 | int status = 0; | |
4218 | ||
4219 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) | |
4220 | return -EIO; | |
4221 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { | |
4222 | p = xdr_inline_decode(xdr, 4); | |
4223 | if (unlikely(!p)) | |
eb72f484 | 4224 | return -EIO; |
aa9c2669 DQ |
4225 | lfs = be32_to_cpup(p++); |
4226 | p = xdr_inline_decode(xdr, 4); | |
4227 | if (unlikely(!p)) | |
eb72f484 | 4228 | return -EIO; |
aa9c2669 DQ |
4229 | pi = be32_to_cpup(p++); |
4230 | p = xdr_inline_decode(xdr, 4); | |
4231 | if (unlikely(!p)) | |
eb72f484 | 4232 | return -EIO; |
aa9c2669 DQ |
4233 | len = be32_to_cpup(p++); |
4234 | p = xdr_inline_decode(xdr, len); | |
4235 | if (unlikely(!p)) | |
eb72f484 | 4236 | return -EIO; |
eef7314c | 4237 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
aa9c2669 | 4238 | if (len < NFS4_MAXLABELLEN) { |
43c1031f TM |
4239 | if (label && label->len) { |
4240 | if (label->len < len) | |
4241 | return -ERANGE; | |
4242 | memcpy(label->label, p, len); | |
aa9c2669 DQ |
4243 | label->len = len; |
4244 | label->pi = pi; | |
4245 | label->lfs = lfs; | |
4246 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; | |
4247 | } | |
aa9c2669 DQ |
4248 | } else |
4249 | printk(KERN_WARNING "%s: label too long (%u)!\n", | |
4250 | __func__, len); | |
2c52c837 OK |
4251 | if (label && label->label) |
4252 | dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n", | |
4253 | __func__, label->len, (char *)label->label, | |
4254 | label->len, label->pi, label->lfs); | |
aa9c2669 | 4255 | } |
aa9c2669 | 4256 | return status; |
aa9c2669 DQ |
4257 | } |
4258 | ||
e86d5a02 | 4259 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
1da177e4 LT |
4260 | { |
4261 | int status = 0; | |
4262 | ||
4263 | time->tv_sec = 0; | |
4264 | time->tv_nsec = 0; | |
4265 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) | |
4266 | return -EIO; | |
4267 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { | |
4268 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4269 | if (status == 0) |
4270 | status = NFS_ATTR_FATTR_MTIME; | |
1da177e4 LT |
4271 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
4272 | } | |
ae08483c | 4273 | dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); |
1da177e4 LT |
4274 | return status; |
4275 | } | |
4276 | ||
b78ef845 FL |
4277 | static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, |
4278 | uint32_t *res) | |
4279 | { | |
4280 | __be32 *p; | |
4281 | ||
4282 | *res = 0; | |
4283 | if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U))) | |
4284 | return -EIO; | |
4285 | if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) { | |
4286 | p = xdr_inline_decode(xdr, 4); | |
4287 | if (unlikely(!p)) | |
4288 | return -EIO; | |
4289 | *res = be32_to_cpup(p); | |
4290 | bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT; | |
4291 | } | |
4292 | dprintk("%s: XATTR support=%s\n", __func__, | |
4293 | *res == 0 ? "false" : "true"); | |
4294 | return 0; | |
4295 | } | |
4296 | ||
256e48bb | 4297 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) |
1da177e4 LT |
4298 | { |
4299 | unsigned int attrwords = XDR_QUADLEN(attrlen); | |
256e48bb | 4300 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
1da177e4 LT |
4301 | |
4302 | if (unlikely(attrwords != nwords)) { | |
fe82a183 CL |
4303 | dprintk("%s: server returned incorrect attribute length: " |
4304 | "%u %c %u\n", | |
3110ff80 | 4305 | __func__, |
1da177e4 LT |
4306 | attrwords << 2, |
4307 | (attrwords < nwords) ? '<' : '>', | |
4308 | nwords << 2); | |
4309 | return -EIO; | |
4310 | } | |
4311 | return 0; | |
4312 | } | |
4313 | ||
4314 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
4315 | { | |
8687b63a | 4316 | __be32 *p; |
1da177e4 | 4317 | |
c0eae66e BH |
4318 | p = xdr_inline_decode(xdr, 20); |
4319 | if (unlikely(!p)) | |
eb72f484 | 4320 | return -EIO; |
6f723f77 | 4321 | cinfo->atomic = be32_to_cpup(p++); |
3ceb4dbb | 4322 | p = xdr_decode_hyper(p, &cinfo->before); |
cccddf4f | 4323 | xdr_decode_hyper(p, &cinfo->after); |
1da177e4 LT |
4324 | return 0; |
4325 | } | |
4326 | ||
6168f62c | 4327 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
1da177e4 | 4328 | { |
8687b63a | 4329 | __be32 *p; |
1da177e4 LT |
4330 | uint32_t supp, acc; |
4331 | int status; | |
4332 | ||
4333 | status = decode_op_hdr(xdr, OP_ACCESS); | |
4334 | if (status) | |
4335 | return status; | |
c0eae66e BH |
4336 | p = xdr_inline_decode(xdr, 8); |
4337 | if (unlikely(!p)) | |
eb72f484 | 4338 | return -EIO; |
6f723f77 | 4339 | supp = be32_to_cpup(p++); |
cccddf4f | 4340 | acc = be32_to_cpup(p); |
6168f62c WAA |
4341 | *supported = supp; |
4342 | *access = acc; | |
1da177e4 LT |
4343 | return 0; |
4344 | } | |
4345 | ||
07d30434 | 4346 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
1da177e4 | 4347 | { |
ab6e9aaf | 4348 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
eb72f484 | 4349 | if (unlikely(ret < 0)) |
ab6e9aaf | 4350 | return -EIO; |
ab6e9aaf | 4351 | return 0; |
07d30434 BH |
4352 | } |
4353 | ||
4354 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | |
4355 | { | |
2d2f24ad | 4356 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
07d30434 BH |
4357 | } |
4358 | ||
93b717fd TM |
4359 | static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
4360 | { | |
4361 | stateid->type = NFS4_OPEN_STATEID_TYPE; | |
4362 | return decode_stateid(xdr, stateid); | |
4363 | } | |
4364 | ||
4365 | static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | |
4366 | { | |
4367 | stateid->type = NFS4_LOCK_STATEID_TYPE; | |
4368 | return decode_stateid(xdr, stateid); | |
4369 | } | |
4370 | ||
4371 | static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | |
4372 | { | |
4373 | stateid->type = NFS4_DELEGATION_STATEID_TYPE; | |
4374 | return decode_stateid(xdr, stateid); | |
4375 | } | |
4376 | ||
fcd8843c TM |
4377 | static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
4378 | { | |
4379 | nfs4_stateid dummy; | |
4380 | ||
4381 | nfs4_stateid_copy(stateid, &invalid_stateid); | |
4382 | return decode_stateid(xdr, &dummy); | |
4383 | } | |
4384 | ||
07d30434 BH |
4385 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
4386 | { | |
1da177e4 LT |
4387 | int status; |
4388 | ||
4389 | status = decode_op_hdr(xdr, OP_CLOSE); | |
c1d51931 TM |
4390 | if (status != -EIO) |
4391 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 | 4392 | if (!status) |
fcd8843c | 4393 | status = decode_invalid_stateid(xdr, &res->stateid); |
07d30434 | 4394 | return status; |
1da177e4 LT |
4395 | } |
4396 | ||
db942bbd BH |
4397 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
4398 | { | |
cd93710e | 4399 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
1da177e4 LT |
4400 | } |
4401 | ||
2f2c63bc TM |
4402 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
4403 | { | |
4404 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); | |
4405 | } | |
4406 | ||
0b7c0153 | 4407 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
1da177e4 | 4408 | { |
221203ce | 4409 | struct nfs_writeverf *verf = res->verf; |
1da177e4 LT |
4410 | int status; |
4411 | ||
4412 | status = decode_op_hdr(xdr, OP_COMMIT); | |
db942bbd | 4413 | if (!status) |
221203ce TM |
4414 | status = decode_write_verifier(xdr, &verf->verifier); |
4415 | if (!status) | |
4416 | verf->committed = NFS_FILE_SYNC; | |
db942bbd | 4417 | return status; |
1da177e4 LT |
4418 | } |
4419 | ||
4420 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
4421 | { | |
8687b63a | 4422 | __be32 *p; |
1da177e4 LT |
4423 | uint32_t bmlen; |
4424 | int status; | |
4425 | ||
4426 | status = decode_op_hdr(xdr, OP_CREATE); | |
4427 | if (status) | |
4428 | return status; | |
4429 | if ((status = decode_change_info(xdr, cinfo))) | |
4430 | return status; | |
c0eae66e BH |
4431 | p = xdr_inline_decode(xdr, 4); |
4432 | if (unlikely(!p)) | |
eb72f484 | 4433 | return -EIO; |
cccddf4f | 4434 | bmlen = be32_to_cpup(p); |
c0eae66e BH |
4435 | p = xdr_inline_decode(xdr, bmlen << 2); |
4436 | if (likely(p)) | |
4437 | return 0; | |
c0eae66e | 4438 | return -EIO; |
1da177e4 LT |
4439 | } |
4440 | ||
4441 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) | |
4442 | { | |
256e48bb | 4443 | unsigned int savep; |
dae100c2 | 4444 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 LT |
4445 | int status; |
4446 | ||
4447 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | |
4448 | goto xdr_error; | |
4449 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4450 | goto xdr_error; | |
4451 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4452 | goto xdr_error; | |
4453 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) | |
4454 | goto xdr_error; | |
264e6351 CL |
4455 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
4456 | &res->fh_expire_type)) != 0) | |
4457 | goto xdr_error; | |
1da177e4 LT |
4458 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
4459 | goto xdr_error; | |
4460 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) | |
4461 | goto xdr_error; | |
4462 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) | |
4463 | goto xdr_error; | |
1ab5be4a TM |
4464 | if ((status = decode_attr_case_insensitive(xdr, bitmap, &res->case_insensitive)) != 0) |
4465 | goto xdr_error; | |
4466 | if ((status = decode_attr_case_preserving(xdr, bitmap, &res->case_preserving)) != 0) | |
4467 | goto xdr_error; | |
8c61282f KM |
4468 | if ((status = decode_attr_exclcreat_supported(xdr, bitmap, |
4469 | res->exclcreat_bitmask)) != 0) | |
4470 | goto xdr_error; | |
1da177e4 LT |
4471 | status = verify_attr_len(xdr, savep, attrlen); |
4472 | xdr_error: | |
3110ff80 | 4473 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4474 | return status; |
4475 | } | |
6c0195a4 | 4476 | |
1da177e4 LT |
4477 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
4478 | { | |
256e48bb | 4479 | unsigned int savep; |
dae100c2 | 4480 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 | 4481 | int status; |
6c0195a4 | 4482 | |
1da177e4 LT |
4483 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
4484 | goto xdr_error; | |
4485 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4486 | goto xdr_error; | |
4487 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4488 | goto xdr_error; | |
4489 | ||
4490 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) | |
4491 | goto xdr_error; | |
4492 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) | |
4493 | goto xdr_error; | |
4494 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) | |
4495 | goto xdr_error; | |
1ca843a2 AG |
4496 | |
4497 | status = -EIO; | |
4498 | if (unlikely(bitmap[0])) | |
4499 | goto xdr_error; | |
4500 | ||
1da177e4 LT |
4501 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
4502 | goto xdr_error; | |
4503 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) | |
4504 | goto xdr_error; | |
4505 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) | |
4506 | goto xdr_error; | |
4507 | ||
4508 | status = verify_attr_len(xdr, savep, attrlen); | |
4509 | xdr_error: | |
3110ff80 | 4510 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4511 | return status; |
4512 | } | |
4513 | ||
4514 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) | |
4515 | { | |
256e48bb | 4516 | unsigned int savep; |
dae100c2 | 4517 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 | 4518 | int status; |
6c0195a4 | 4519 | |
1da177e4 LT |
4520 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
4521 | goto xdr_error; | |
4522 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4523 | goto xdr_error; | |
4524 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4525 | goto xdr_error; | |
4526 | ||
4527 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) | |
4528 | goto xdr_error; | |
4529 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) | |
4530 | goto xdr_error; | |
4531 | ||
4532 | status = verify_attr_len(xdr, savep, attrlen); | |
4533 | xdr_error: | |
3110ff80 | 4534 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4535 | return status; |
4536 | } | |
4537 | ||
88034c3d AA |
4538 | static int decode_threshold_hint(struct xdr_stream *xdr, |
4539 | uint32_t *bitmap, | |
4540 | uint64_t *res, | |
4541 | uint32_t hint_bit) | |
4542 | { | |
4543 | __be32 *p; | |
4544 | ||
4545 | *res = 0; | |
4546 | if (likely(bitmap[0] & hint_bit)) { | |
4547 | p = xdr_inline_decode(xdr, 8); | |
4548 | if (unlikely(!p)) | |
eb72f484 | 4549 | return -EIO; |
88034c3d AA |
4550 | xdr_decode_hyper(p, res); |
4551 | } | |
4552 | return 0; | |
88034c3d AA |
4553 | } |
4554 | ||
4555 | static int decode_first_threshold_item4(struct xdr_stream *xdr, | |
4556 | struct nfs4_threshold *res) | |
4557 | { | |
256e48bb TM |
4558 | __be32 *p; |
4559 | unsigned int savep; | |
88034c3d AA |
4560 | uint32_t bitmap[3] = {0,}, attrlen; |
4561 | int status; | |
4562 | ||
4563 | /* layout type */ | |
4564 | p = xdr_inline_decode(xdr, 4); | |
eb72f484 | 4565 | if (unlikely(!p)) |
88034c3d | 4566 | return -EIO; |
88034c3d AA |
4567 | res->l_type = be32_to_cpup(p); |
4568 | ||
4569 | /* thi_hintset bitmap */ | |
4570 | status = decode_attr_bitmap(xdr, bitmap); | |
4571 | if (status < 0) | |
4572 | goto xdr_error; | |
4573 | ||
4574 | /* thi_hintlist length */ | |
4575 | status = decode_attr_length(xdr, &attrlen, &savep); | |
4576 | if (status < 0) | |
4577 | goto xdr_error; | |
4578 | /* thi_hintlist */ | |
4579 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); | |
4580 | if (status < 0) | |
4581 | goto xdr_error; | |
4582 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); | |
4583 | if (status < 0) | |
4584 | goto xdr_error; | |
4585 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, | |
4586 | THRESHOLD_RD_IO); | |
4587 | if (status < 0) | |
4588 | goto xdr_error; | |
4589 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, | |
4590 | THRESHOLD_WR_IO); | |
4591 | if (status < 0) | |
4592 | goto xdr_error; | |
4593 | ||
4594 | status = verify_attr_len(xdr, savep, attrlen); | |
4595 | res->bm = bitmap[0]; | |
4596 | ||
4597 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", | |
4598 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, | |
4599 | res->wr_io_sz); | |
4600 | xdr_error: | |
4601 | dprintk("%s ret=%d!\n", __func__, status); | |
4602 | return status; | |
4603 | } | |
4604 | ||
4605 | /* | |
4606 | * Thresholds on pNFS direct I/O vrs MDS I/O | |
4607 | */ | |
4608 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, | |
4609 | uint32_t *bitmap, | |
4610 | struct nfs4_threshold *res) | |
4611 | { | |
4612 | __be32 *p; | |
4613 | int status = 0; | |
4614 | uint32_t num; | |
4615 | ||
4616 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) | |
4617 | return -EIO; | |
029c5347 | 4618 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
1549210f TM |
4619 | /* Did the server return an unrequested attribute? */ |
4620 | if (unlikely(res == NULL)) | |
4621 | return -EREMOTEIO; | |
88034c3d AA |
4622 | p = xdr_inline_decode(xdr, 4); |
4623 | if (unlikely(!p)) | |
eb72f484 | 4624 | return -EIO; |
88034c3d AA |
4625 | num = be32_to_cpup(p); |
4626 | if (num == 0) | |
4627 | return 0; | |
4628 | if (num > 1) | |
4629 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " | |
4630 | "drivers per filesystem not supported\n", | |
4631 | __func__); | |
4632 | ||
4633 | status = decode_first_threshold_item4(xdr, res); | |
029c5347 | 4634 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
88034c3d AA |
4635 | } |
4636 | return status; | |
88034c3d AA |
4637 | } |
4638 | ||
ae42c70a BS |
4639 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
4640 | struct nfs_fattr *fattr, struct nfs_fh *fh, | |
1e2f67da | 4641 | struct nfs4_fs_locations *fs_loc, const struct nfs_server *server) |
1da177e4 | 4642 | { |
bca79478 TM |
4643 | int status; |
4644 | umode_t fmode = 0; | |
ae42c70a | 4645 | uint32_t type; |
ee7b75fc | 4646 | int32_t err; |
1da177e4 | 4647 | |
f26c7a78 TM |
4648 | status = decode_attr_type(xdr, bitmap, &type); |
4649 | if (status < 0) | |
1da177e4 | 4650 | goto xdr_error; |
409924e4 TM |
4651 | fattr->mode = 0; |
4652 | if (status != 0) { | |
4653 | fattr->mode |= nfs_type2fmt[type]; | |
4654 | fattr->valid |= status; | |
4655 | } | |
1da177e4 | 4656 | |
f26c7a78 TM |
4657 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
4658 | if (status < 0) | |
1da177e4 | 4659 | goto xdr_error; |
409924e4 | 4660 | fattr->valid |= status; |
f26c7a78 TM |
4661 | |
4662 | status = decode_attr_size(xdr, bitmap, &fattr->size); | |
4663 | if (status < 0) | |
1da177e4 | 4664 | goto xdr_error; |
409924e4 | 4665 | fattr->valid |= status; |
f26c7a78 TM |
4666 | |
4667 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); | |
4668 | if (status < 0) | |
1da177e4 | 4669 | goto xdr_error; |
409924e4 | 4670 | fattr->valid |= status; |
f26c7a78 | 4671 | |
ee7b75fc TM |
4672 | err = 0; |
4673 | status = decode_attr_error(xdr, bitmap, &err); | |
ae42c70a BS |
4674 | if (status < 0) |
4675 | goto xdr_error; | |
4676 | ||
4677 | status = decode_attr_filehandle(xdr, bitmap, fh); | |
4678 | if (status < 0) | |
4679 | goto xdr_error; | |
4680 | ||
f26c7a78 TM |
4681 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
4682 | if (status < 0) | |
1da177e4 | 4683 | goto xdr_error; |
409924e4 | 4684 | fattr->valid |= status; |
f26c7a78 | 4685 | |
8b7e3f49 | 4686 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
f26c7a78 | 4687 | if (status < 0) |
683b57b4 | 4688 | goto xdr_error; |
409924e4 | 4689 | fattr->valid |= status; |
f26c7a78 | 4690 | |
1ca843a2 AG |
4691 | status = -EIO; |
4692 | if (unlikely(bitmap[0])) | |
4693 | goto xdr_error; | |
4694 | ||
f26c7a78 TM |
4695 | status = decode_attr_mode(xdr, bitmap, &fmode); |
4696 | if (status < 0) | |
1da177e4 | 4697 | goto xdr_error; |
409924e4 TM |
4698 | if (status != 0) { |
4699 | fattr->mode |= fmode; | |
4700 | fattr->valid |= status; | |
4701 | } | |
f26c7a78 TM |
4702 | |
4703 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); | |
4704 | if (status < 0) | |
1da177e4 | 4705 | goto xdr_error; |
409924e4 | 4706 | fattr->valid |= status; |
f26c7a78 | 4707 | |
6926afd1 | 4708 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
f26c7a78 | 4709 | if (status < 0) |
1da177e4 | 4710 | goto xdr_error; |
409924e4 | 4711 | fattr->valid |= status; |
f26c7a78 | 4712 | |
6926afd1 | 4713 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
f26c7a78 | 4714 | if (status < 0) |
1da177e4 | 4715 | goto xdr_error; |
409924e4 | 4716 | fattr->valid |= status; |
f26c7a78 TM |
4717 | |
4718 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); | |
4719 | if (status < 0) | |
1da177e4 | 4720 | goto xdr_error; |
409924e4 | 4721 | fattr->valid |= status; |
f26c7a78 TM |
4722 | |
4723 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); | |
4724 | if (status < 0) | |
1da177e4 | 4725 | goto xdr_error; |
409924e4 | 4726 | fattr->valid |= status; |
f26c7a78 TM |
4727 | |
4728 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); | |
4729 | if (status < 0) | |
1da177e4 | 4730 | goto xdr_error; |
409924e4 | 4731 | fattr->valid |= status; |
f26c7a78 TM |
4732 | |
4733 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); | |
4734 | if (status < 0) | |
1da177e4 | 4735 | goto xdr_error; |
409924e4 | 4736 | fattr->valid |= status; |
f26c7a78 TM |
4737 | |
4738 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); | |
4739 | if (status < 0) | |
1da177e4 | 4740 | goto xdr_error; |
409924e4 | 4741 | fattr->valid |= status; |
f26c7a78 | 4742 | |
28331a46 | 4743 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
f26c7a78 | 4744 | if (status < 0) |
99baf625 | 4745 | goto xdr_error; |
28331a46 | 4746 | fattr->valid |= status; |
f26c7a78 | 4747 | |
1ca843a2 AG |
4748 | status = -EIO; |
4749 | if (unlikely(bitmap[1])) | |
4750 | goto xdr_error; | |
4751 | ||
88034c3d AA |
4752 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
4753 | if (status < 0) | |
4754 | goto xdr_error; | |
4755 | ||
c8a62f44 TM |
4756 | status = decode_attr_security_label(xdr, bitmap, fattr->label); |
4757 | if (status < 0) | |
4758 | goto xdr_error; | |
4759 | fattr->valid |= status; | |
aa9c2669 | 4760 | |
ae42c70a BS |
4761 | xdr_error: |
4762 | dprintk("%s: xdr returned %d\n", __func__, -status); | |
4763 | return status; | |
4764 | } | |
4765 | ||
4766 | static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr, | |
8b7e3f49 | 4767 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
1e2f67da | 4768 | const struct nfs_server *server) |
ae42c70a | 4769 | { |
256e48bb | 4770 | unsigned int savep; |
ae42c70a | 4771 | uint32_t attrlen, |
dae100c2 | 4772 | bitmap[3] = {0}; |
ae42c70a BS |
4773 | int status; |
4774 | ||
4775 | status = decode_op_hdr(xdr, OP_GETATTR); | |
4776 | if (status < 0) | |
4777 | goto xdr_error; | |
4778 | ||
4779 | status = decode_attr_bitmap(xdr, bitmap); | |
4780 | if (status < 0) | |
4781 | goto xdr_error; | |
4782 | ||
4783 | status = decode_attr_length(xdr, &attrlen, &savep); | |
4784 | if (status < 0) | |
4785 | goto xdr_error; | |
4786 | ||
1e2f67da | 4787 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
ae42c70a BS |
4788 | if (status < 0) |
4789 | goto xdr_error; | |
4790 | ||
f26c7a78 | 4791 | status = verify_attr_len(xdr, savep, attrlen); |
1da177e4 | 4792 | xdr_error: |
3110ff80 | 4793 | dprintk("%s: xdr returned %d\n", __func__, -status); |
1da177e4 LT |
4794 | return status; |
4795 | } | |
4796 | ||
ae42c70a | 4797 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
6926afd1 | 4798 | const struct nfs_server *server) |
ae42c70a | 4799 | { |
1e2f67da | 4800 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
ae42c70a | 4801 | } |
1da177e4 | 4802 | |
504913fb | 4803 | /* |
3132e49e | 4804 | * Decode potentially multiple layout types. |
504913fb | 4805 | */ |
3132e49e | 4806 | static int decode_pnfs_layout_types(struct xdr_stream *xdr, |
ca440c38 | 4807 | struct nfs_fsinfo *fsinfo) |
504913fb | 4808 | { |
b8a8a0dd | 4809 | __be32 *p; |
ca440c38 | 4810 | uint32_t i; |
504913fb AA |
4811 | |
4812 | p = xdr_inline_decode(xdr, 4); | |
4813 | if (unlikely(!p)) | |
eb72f484 | 4814 | return -EIO; |
ca440c38 | 4815 | fsinfo->nlayouttypes = be32_to_cpup(p); |
504913fb AA |
4816 | |
4817 | /* pNFS is not supported by the underlying file system */ | |
ca440c38 | 4818 | if (fsinfo->nlayouttypes == 0) |
504913fb | 4819 | return 0; |
504913fb AA |
4820 | |
4821 | /* Decode and set first layout type, move xdr->p past unused types */ | |
ca440c38 | 4822 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
504913fb | 4823 | if (unlikely(!p)) |
eb72f484 | 4824 | return -EIO; |
ca440c38 JL |
4825 | |
4826 | /* If we get too many, then just cap it at the max */ | |
4827 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { | |
4828 | printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n", | |
4829 | __func__, fsinfo->nlayouttypes); | |
4830 | fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES; | |
4831 | } | |
4832 | ||
4833 | for(i = 0; i < fsinfo->nlayouttypes; ++i) | |
4834 | fsinfo->layouttype[i] = be32_to_cpup(p++); | |
504913fb | 4835 | return 0; |
504913fb AA |
4836 | } |
4837 | ||
4838 | /* | |
4839 | * The type of file system exported. | |
4840 | * Note we must ensure that layouttype is set in any non-error case. | |
4841 | */ | |
4842 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, | |
ca440c38 | 4843 | struct nfs_fsinfo *fsinfo) |
504913fb AA |
4844 | { |
4845 | int status = 0; | |
4846 | ||
4847 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); | |
4848 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) | |
4849 | return -EIO; | |
4850 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { | |
ca440c38 | 4851 | status = decode_pnfs_layout_types(xdr, fsinfo); |
504913fb | 4852 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
3132e49e | 4853 | } |
504913fb AA |
4854 | return status; |
4855 | } | |
4856 | ||
dae100c2 FI |
4857 | /* |
4858 | * The prefered block size for layout directed io | |
4859 | */ | |
4860 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, | |
4861 | uint32_t *res) | |
4862 | { | |
4863 | __be32 *p; | |
4864 | ||
4865 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | |
4866 | *res = 0; | |
4867 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { | |
4868 | p = xdr_inline_decode(xdr, 4); | |
eb72f484 | 4869 | if (unlikely(!p)) |
dae100c2 | 4870 | return -EIO; |
dae100c2 FI |
4871 | *res = be32_to_cpup(p); |
4872 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; | |
4873 | } | |
4874 | return 0; | |
4875 | } | |
4876 | ||
2a92ee92 PT |
4877 | /* |
4878 | * The granularity of a CLONE operation. | |
4879 | */ | |
4880 | static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, | |
4881 | uint32_t *res) | |
4882 | { | |
4883 | __be32 *p; | |
4884 | ||
4885 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | |
4886 | *res = 0; | |
4887 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { | |
4888 | p = xdr_inline_decode(xdr, 4); | |
eb72f484 | 4889 | if (unlikely(!p)) |
2a92ee92 | 4890 | return -EIO; |
2a92ee92 PT |
4891 | *res = be32_to_cpup(p); |
4892 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; | |
4893 | } | |
4894 | return 0; | |
4895 | } | |
4896 | ||
7f08a335 TM |
4897 | static int decode_attr_change_attr_type(struct xdr_stream *xdr, |
4898 | uint32_t *bitmap, | |
4899 | enum nfs4_change_attr_type *res) | |
4900 | { | |
4901 | u32 tmp = NFS4_CHANGE_TYPE_IS_UNDEFINED; | |
4902 | ||
4903 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | |
4904 | if (bitmap[2] & FATTR4_WORD2_CHANGE_ATTR_TYPE) { | |
4905 | if (xdr_stream_decode_u32(xdr, &tmp)) | |
4906 | return -EIO; | |
4907 | bitmap[2] &= ~FATTR4_WORD2_CHANGE_ATTR_TYPE; | |
4908 | } | |
4909 | ||
4910 | switch(tmp) { | |
4911 | case NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR: | |
4912 | case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER: | |
4913 | case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS: | |
4914 | case NFS4_CHANGE_TYPE_IS_TIME_METADATA: | |
4915 | *res = tmp; | |
4916 | break; | |
4917 | default: | |
4918 | *res = NFS4_CHANGE_TYPE_IS_UNDEFINED; | |
4919 | } | |
4920 | return 0; | |
4921 | } | |
4922 | ||
1da177e4 LT |
4923 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
4924 | { | |
256e48bb | 4925 | unsigned int savep; |
dae100c2 | 4926 | uint32_t attrlen, bitmap[3]; |
1da177e4 LT |
4927 | int status; |
4928 | ||
4929 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | |
4930 | goto xdr_error; | |
4931 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4932 | goto xdr_error; | |
4933 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4934 | goto xdr_error; | |
4935 | ||
4936 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ | |
4937 | ||
4938 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) | |
4939 | goto xdr_error; | |
4940 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) | |
4941 | goto xdr_error; | |
4942 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) | |
4943 | goto xdr_error; | |
4944 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; | |
4945 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) | |
4946 | goto xdr_error; | |
4947 | fsinfo->wtpref = fsinfo->wtmax; | |
1ca843a2 AG |
4948 | |
4949 | status = -EIO; | |
4950 | if (unlikely(bitmap[0])) | |
4951 | goto xdr_error; | |
4952 | ||
55b6e774 | 4953 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
504913fb AA |
4954 | if (status != 0) |
4955 | goto xdr_error; | |
ca440c38 | 4956 | status = decode_attr_pnfstype(xdr, bitmap, fsinfo); |
55b6e774 RL |
4957 | if (status != 0) |
4958 | goto xdr_error; | |
1ca843a2 AG |
4959 | |
4960 | status = -EIO; | |
4961 | if (unlikely(bitmap[1])) | |
4962 | goto xdr_error; | |
4963 | ||
dae100c2 | 4964 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
2a92ee92 PT |
4965 | if (status) |
4966 | goto xdr_error; | |
4967 | status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize); | |
dae100c2 FI |
4968 | if (status) |
4969 | goto xdr_error; | |
1da177e4 | 4970 | |
7f08a335 TM |
4971 | status = decode_attr_change_attr_type(xdr, bitmap, |
4972 | &fsinfo->change_attr_type); | |
4973 | if (status) | |
4974 | goto xdr_error; | |
4975 | ||
b78ef845 FL |
4976 | status = decode_attr_xattrsupport(xdr, bitmap, |
4977 | &fsinfo->xattr_support); | |
4978 | if (status) | |
4979 | goto xdr_error; | |
4980 | ||
1da177e4 LT |
4981 | status = verify_attr_len(xdr, savep, attrlen); |
4982 | xdr_error: | |
3110ff80 | 4983 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4984 | return status; |
4985 | } | |
4986 | ||
4987 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) | |
4988 | { | |
8687b63a | 4989 | __be32 *p; |
1da177e4 LT |
4990 | uint32_t len; |
4991 | int status; | |
4992 | ||
9936781d TM |
4993 | /* Zero handle first to allow comparisons */ |
4994 | memset(fh, 0, sizeof(*fh)); | |
4995 | ||
1da177e4 LT |
4996 | status = decode_op_hdr(xdr, OP_GETFH); |
4997 | if (status) | |
4998 | return status; | |
1da177e4 | 4999 | |
c0eae66e BH |
5000 | p = xdr_inline_decode(xdr, 4); |
5001 | if (unlikely(!p)) | |
eb72f484 | 5002 | return -EIO; |
cccddf4f | 5003 | len = be32_to_cpup(p); |
eb3d58c6 TM |
5004 | if (len > NFS4_FHSIZE || len == 0) { |
5005 | trace_nfs4_xdr_bad_filehandle(xdr, OP_GETFH, NFS4ERR_BADHANDLE); | |
5006 | return -EREMOTEIO; | |
5007 | } | |
1da177e4 | 5008 | fh->size = len; |
c0eae66e BH |
5009 | p = xdr_inline_decode(xdr, len); |
5010 | if (unlikely(!p)) | |
eb72f484 | 5011 | return -EIO; |
99398d06 | 5012 | memcpy(fh->data, p, len); |
1da177e4 LT |
5013 | return 0; |
5014 | } | |
5015 | ||
5016 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
5017 | { | |
5018 | int status; | |
6c0195a4 | 5019 | |
1da177e4 LT |
5020 | status = decode_op_hdr(xdr, OP_LINK); |
5021 | if (status) | |
5022 | return status; | |
5023 | return decode_change_info(xdr, cinfo); | |
5024 | } | |
5025 | ||
5026 | /* | |
5027 | * We create the owner, so we know a proper owner.id length is 4. | |
5028 | */ | |
911d1aaf | 5029 | static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) |
1da177e4 | 5030 | { |
911d1aaf | 5031 | uint64_t offset, length, clientid; |
8687b63a | 5032 | __be32 *p; |
911d1aaf | 5033 | uint32_t namelen, type; |
1da177e4 | 5034 | |
babddc72 | 5035 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
c0eae66e | 5036 | if (unlikely(!p)) |
eb72f484 | 5037 | return -EIO; |
babddc72 | 5038 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
3ceb4dbb | 5039 | p = xdr_decode_hyper(p, &length); |
babddc72 BS |
5040 | type = be32_to_cpup(p++); /* 4 byte read */ |
5041 | if (fl != NULL) { /* manipulate file lock */ | |
911d1aaf TM |
5042 | fl->fl_start = (loff_t)offset; |
5043 | fl->fl_end = fl->fl_start + (loff_t)length - 1; | |
5044 | if (length == ~(uint64_t)0) | |
5045 | fl->fl_end = OFFSET_MAX; | |
5046 | fl->fl_type = F_WRLCK; | |
5047 | if (type & 1) | |
5048 | fl->fl_type = F_RDLCK; | |
5049 | fl->fl_pid = 0; | |
5050 | } | |
babddc72 BS |
5051 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
5052 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ | |
5053 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ | |
eb72f484 CL |
5054 | if (likely(!p)) |
5055 | return -EIO; | |
5056 | return -NFS4ERR_DENIED; | |
1da177e4 LT |
5057 | } |
5058 | ||
911d1aaf | 5059 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
1da177e4 | 5060 | { |
1da177e4 LT |
5061 | int status; |
5062 | ||
5063 | status = decode_op_hdr(xdr, OP_LOCK); | |
c1d51931 TM |
5064 | if (status == -EIO) |
5065 | goto out; | |
1da177e4 | 5066 | if (status == 0) { |
93b717fd | 5067 | status = decode_lock_stateid(xdr, &res->stateid); |
07d30434 BH |
5068 | if (unlikely(status)) |
5069 | goto out; | |
1da177e4 | 5070 | } else if (status == -NFS4ERR_DENIED) |
c1d51931 TM |
5071 | status = decode_lock_denied(xdr, NULL); |
5072 | if (res->open_seqid != NULL) | |
5073 | nfs_increment_open_seqid(status, res->open_seqid); | |
5074 | nfs_increment_lock_seqid(status, res->lock_seqid); | |
5075 | out: | |
1da177e4 LT |
5076 | return status; |
5077 | } | |
5078 | ||
911d1aaf | 5079 | static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res) |
1da177e4 LT |
5080 | { |
5081 | int status; | |
5082 | status = decode_op_hdr(xdr, OP_LOCKT); | |
5083 | if (status == -NFS4ERR_DENIED) | |
911d1aaf | 5084 | return decode_lock_denied(xdr, res->denied); |
1da177e4 LT |
5085 | return status; |
5086 | } | |
5087 | ||
911d1aaf | 5088 | static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) |
1da177e4 | 5089 | { |
1da177e4 LT |
5090 | int status; |
5091 | ||
5092 | status = decode_op_hdr(xdr, OP_LOCKU); | |
c1d51931 TM |
5093 | if (status != -EIO) |
5094 | nfs_increment_lock_seqid(status, res->seqid); | |
07d30434 | 5095 | if (status == 0) |
93b717fd | 5096 | status = decode_lock_stateid(xdr, &res->stateid); |
1da177e4 LT |
5097 | return status; |
5098 | } | |
5099 | ||
d3c7b7cc TM |
5100 | static int decode_release_lockowner(struct xdr_stream *xdr) |
5101 | { | |
5102 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); | |
5103 | } | |
5104 | ||
1da177e4 LT |
5105 | static int decode_lookup(struct xdr_stream *xdr) |
5106 | { | |
5107 | return decode_op_hdr(xdr, OP_LOOKUP); | |
5108 | } | |
5109 | ||
5b5faaf6 JL |
5110 | static int decode_lookupp(struct xdr_stream *xdr) |
5111 | { | |
5112 | return decode_op_hdr(xdr, OP_LOOKUPP); | |
5113 | } | |
5114 | ||
1da177e4 | 5115 | /* This is too sick! */ |
7d160a6c TM |
5116 | static int decode_space_limit(struct xdr_stream *xdr, |
5117 | unsigned long *pagemod_limit) | |
1da177e4 | 5118 | { |
05d564fe | 5119 | __be32 *p; |
1da177e4 | 5120 | uint32_t limit_type, nblocks, blocksize; |
7d160a6c | 5121 | u64 maxsize = 0; |
1da177e4 | 5122 | |
c0eae66e BH |
5123 | p = xdr_inline_decode(xdr, 12); |
5124 | if (unlikely(!p)) | |
eb72f484 | 5125 | return -EIO; |
6f723f77 | 5126 | limit_type = be32_to_cpup(p++); |
1da177e4 | 5127 | switch (limit_type) { |
7d160a6c TM |
5128 | case NFS4_LIMIT_SIZE: |
5129 | xdr_decode_hyper(p, &maxsize); | |
05d564fe | 5130 | break; |
7d160a6c | 5131 | case NFS4_LIMIT_BLOCKS: |
6f723f77 | 5132 | nblocks = be32_to_cpup(p++); |
cccddf4f | 5133 | blocksize = be32_to_cpup(p); |
7d160a6c | 5134 | maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
1da177e4 | 5135 | } |
09cbfeaf | 5136 | maxsize >>= PAGE_SHIFT; |
7d160a6c | 5137 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
1da177e4 LT |
5138 | return 0; |
5139 | } | |
5140 | ||
6ae37339 TM |
5141 | static int decode_rw_delegation(struct xdr_stream *xdr, |
5142 | uint32_t delegation_type, | |
5143 | struct nfs_openres *res) | |
1da177e4 | 5144 | { |
05d564fe | 5145 | __be32 *p; |
07d30434 | 5146 | int status; |
1da177e4 | 5147 | |
93b717fd | 5148 | status = decode_delegation_stateid(xdr, &res->delegation); |
07d30434 BH |
5149 | if (unlikely(status)) |
5150 | return status; | |
c0eae66e BH |
5151 | p = xdr_inline_decode(xdr, 4); |
5152 | if (unlikely(!p)) | |
eb72f484 | 5153 | return -EIO; |
cccddf4f | 5154 | res->do_recall = be32_to_cpup(p); |
05d564fe | 5155 | |
1da177e4 | 5156 | switch (delegation_type) { |
05d564fe AA |
5157 | case NFS4_OPEN_DELEGATE_READ: |
5158 | res->delegation_type = FMODE_READ; | |
5159 | break; | |
5160 | case NFS4_OPEN_DELEGATE_WRITE: | |
5161 | res->delegation_type = FMODE_WRITE|FMODE_READ; | |
7d160a6c | 5162 | if (decode_space_limit(xdr, &res->pagemod_limit) < 0) |
1da177e4 LT |
5163 | return -EIO; |
5164 | } | |
1bbe60ff | 5165 | return decode_ace(xdr, NULL); |
1da177e4 LT |
5166 | } |
5167 | ||
6ae37339 TM |
5168 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
5169 | { | |
5170 | __be32 *p; | |
5171 | uint32_t why_no_delegation; | |
5172 | ||
5173 | p = xdr_inline_decode(xdr, 4); | |
5174 | if (unlikely(!p)) | |
eb72f484 | 5175 | return -EIO; |
6ae37339 TM |
5176 | why_no_delegation = be32_to_cpup(p); |
5177 | switch (why_no_delegation) { | |
5178 | case WND4_CONTENTION: | |
5179 | case WND4_RESOURCE: | |
5180 | xdr_inline_decode(xdr, 4); | |
5181 | /* Ignore for now */ | |
5182 | } | |
5183 | return 0; | |
6ae37339 TM |
5184 | } |
5185 | ||
5186 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) | |
5187 | { | |
5188 | __be32 *p; | |
5189 | uint32_t delegation_type; | |
5190 | ||
5191 | p = xdr_inline_decode(xdr, 4); | |
5192 | if (unlikely(!p)) | |
eb72f484 | 5193 | return -EIO; |
6ae37339 TM |
5194 | delegation_type = be32_to_cpup(p); |
5195 | res->delegation_type = 0; | |
5196 | switch (delegation_type) { | |
5197 | case NFS4_OPEN_DELEGATE_NONE: | |
5198 | return 0; | |
5199 | case NFS4_OPEN_DELEGATE_READ: | |
5200 | case NFS4_OPEN_DELEGATE_WRITE: | |
5201 | return decode_rw_delegation(xdr, delegation_type, res); | |
5202 | case NFS4_OPEN_DELEGATE_NONE_EXT: | |
5203 | return decode_no_delegation(xdr, res); | |
5204 | } | |
5205 | return -EIO; | |
6ae37339 TM |
5206 | } |
5207 | ||
1da177e4 LT |
5208 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
5209 | { | |
05d564fe | 5210 | __be32 *p; |
aa53ed54 | 5211 | uint32_t savewords, bmlen, i; |
05d564fe | 5212 | int status; |
1da177e4 | 5213 | |
c7848f69 TM |
5214 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
5215 | return status; | |
5216 | nfs_increment_open_seqid(status, res->seqid); | |
5217 | if (status) | |
5218 | return status; | |
93b717fd | 5219 | status = decode_open_stateid(xdr, &res->stateid); |
07d30434 | 5220 | if (unlikely(status)) |
05d564fe | 5221 | return status; |
1da177e4 | 5222 | |
05d564fe | 5223 | decode_change_info(xdr, &res->cinfo); |
1da177e4 | 5224 | |
c0eae66e BH |
5225 | p = xdr_inline_decode(xdr, 8); |
5226 | if (unlikely(!p)) | |
eb72f484 | 5227 | return -EIO; |
6f723f77 | 5228 | res->rflags = be32_to_cpup(p++); |
cccddf4f | 5229 | bmlen = be32_to_cpup(p); |
05d564fe AA |
5230 | if (bmlen > 10) |
5231 | goto xdr_error; | |
1da177e4 | 5232 | |
c0eae66e BH |
5233 | p = xdr_inline_decode(xdr, bmlen << 2); |
5234 | if (unlikely(!p)) | |
eb72f484 | 5235 | return -EIO; |
aa53ed54 JL |
5236 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
5237 | for (i = 0; i < savewords; ++i) | |
6f723f77 | 5238 | res->attrset[i] = be32_to_cpup(p++); |
aa53ed54 JL |
5239 | for (; i < NFS4_BITMAP_SIZE; i++) |
5240 | res->attrset[i] = 0; | |
5241 | ||
1da177e4 LT |
5242 | return decode_delegation(xdr, res); |
5243 | xdr_error: | |
3110ff80 | 5244 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
1da177e4 LT |
5245 | return -EIO; |
5246 | } | |
5247 | ||
5248 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) | |
5249 | { | |
1da177e4 LT |
5250 | int status; |
5251 | ||
05d564fe | 5252 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
c1d51931 TM |
5253 | if (status != -EIO) |
5254 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 | 5255 | if (!status) |
93b717fd | 5256 | status = decode_open_stateid(xdr, &res->stateid); |
07d30434 | 5257 | return status; |
1da177e4 LT |
5258 | } |
5259 | ||
5260 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) | |
5261 | { | |
1da177e4 LT |
5262 | int status; |
5263 | ||
5264 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); | |
c1d51931 TM |
5265 | if (status != -EIO) |
5266 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 | 5267 | if (!status) |
93b717fd | 5268 | status = decode_open_stateid(xdr, &res->stateid); |
07d30434 | 5269 | return status; |
1da177e4 LT |
5270 | } |
5271 | ||
5272 | static int decode_putfh(struct xdr_stream *xdr) | |
5273 | { | |
5274 | return decode_op_hdr(xdr, OP_PUTFH); | |
5275 | } | |
5276 | ||
5277 | static int decode_putrootfh(struct xdr_stream *xdr) | |
5278 | { | |
5279 | return decode_op_hdr(xdr, OP_PUTROOTFH); | |
5280 | } | |
5281 | ||
9137bdf3 AS |
5282 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
5283 | struct nfs_pgio_res *res) | |
1da177e4 | 5284 | { |
8687b63a | 5285 | __be32 *p; |
64bd577e | 5286 | uint32_t count, eof, recvd; |
1da177e4 LT |
5287 | int status; |
5288 | ||
5289 | status = decode_op_hdr(xdr, OP_READ); | |
5290 | if (status) | |
5291 | return status; | |
c0eae66e BH |
5292 | p = xdr_inline_decode(xdr, 8); |
5293 | if (unlikely(!p)) | |
eb72f484 | 5294 | return -EIO; |
6f723f77 | 5295 | eof = be32_to_cpup(p++); |
cccddf4f | 5296 | count = be32_to_cpup(p); |
64bd577e | 5297 | recvd = xdr_read_pages(xdr, count); |
1da177e4 | 5298 | if (count > recvd) { |
fe82a183 | 5299 | dprintk("NFS: server cheating in read reply: " |
1da177e4 LT |
5300 | "count %u > recvd %u\n", count, recvd); |
5301 | count = recvd; | |
5302 | eof = 0; | |
5303 | } | |
1da177e4 LT |
5304 | res->eof = eof; |
5305 | res->count = count; | |
5306 | return 0; | |
5307 | } | |
5308 | ||
5309 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) | |
5310 | { | |
bcecff77 | 5311 | int status; |
cd93710e | 5312 | __be32 verf[2]; |
1da177e4 LT |
5313 | |
5314 | status = decode_op_hdr(xdr, OP_READDIR); | |
db942bbd BH |
5315 | if (!status) |
5316 | status = decode_verifier(xdr, readdir->verifier.data); | |
5317 | if (unlikely(status)) | |
1da177e4 | 5318 | return status; |
cd93710e | 5319 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
44109241 | 5320 | dprintk("%s: verifier = %08x:%08x\n", |
cd93710e | 5321 | __func__, verf[0], verf[1]); |
64bd577e | 5322 | return xdr_read_pages(xdr, xdr->buf->page_len); |
1da177e4 LT |
5323 | } |
5324 | ||
5325 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | |
5326 | { | |
5327 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; | |
bcecff77 | 5328 | u32 len, recvd; |
8687b63a | 5329 | __be32 *p; |
1da177e4 LT |
5330 | int status; |
5331 | ||
5332 | status = decode_op_hdr(xdr, OP_READLINK); | |
5333 | if (status) | |
5334 | return status; | |
5335 | ||
5336 | /* Convert length of symlink */ | |
c0eae66e BH |
5337 | p = xdr_inline_decode(xdr, 4); |
5338 | if (unlikely(!p)) | |
eb72f484 | 5339 | return -EIO; |
cccddf4f | 5340 | len = be32_to_cpup(p); |
1da177e4 | 5341 | if (len >= rcvbuf->page_len || len <= 0) { |
fe82a183 | 5342 | dprintk("nfs: server returned giant symlink!\n"); |
1da177e4 LT |
5343 | return -ENAMETOOLONG; |
5344 | } | |
64bd577e | 5345 | recvd = xdr_read_pages(xdr, len); |
1da177e4 | 5346 | if (recvd < len) { |
fe82a183 | 5347 | dprintk("NFS: server cheating in readlink reply: " |
1da177e4 LT |
5348 | "count %u > recvd %u\n", len, recvd); |
5349 | return -EIO; | |
5350 | } | |
1da177e4 LT |
5351 | /* |
5352 | * The XDR encode routine has set things up so that | |
5353 | * the link text will be copied directly into the | |
5354 | * buffer. We just have to do overflow-checking, | |
a5032910 | 5355 | * and null-terminate the text (the VFS expects |
1da177e4 LT |
5356 | * null-termination). |
5357 | */ | |
b4687da7 | 5358 | xdr_terminate_string(rcvbuf, len); |
1da177e4 LT |
5359 | return 0; |
5360 | } | |
5361 | ||
5362 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
5363 | { | |
5364 | int status; | |
5365 | ||
5366 | status = decode_op_hdr(xdr, OP_REMOVE); | |
5367 | if (status) | |
5368 | goto out; | |
5369 | status = decode_change_info(xdr, cinfo); | |
5370 | out: | |
5371 | return status; | |
5372 | } | |
5373 | ||
5374 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, | |
5375 | struct nfs4_change_info *new_cinfo) | |
5376 | { | |
5377 | int status; | |
5378 | ||
5379 | status = decode_op_hdr(xdr, OP_RENAME); | |
5380 | if (status) | |
5381 | goto out; | |
5382 | if ((status = decode_change_info(xdr, old_cinfo))) | |
5383 | goto out; | |
5384 | status = decode_change_info(xdr, new_cinfo); | |
5385 | out: | |
5386 | return status; | |
5387 | } | |
5388 | ||
5389 | static int decode_renew(struct xdr_stream *xdr) | |
5390 | { | |
5391 | return decode_op_hdr(xdr, OP_RENEW); | |
5392 | } | |
5393 | ||
56ae19f3 TM |
5394 | static int |
5395 | decode_restorefh(struct xdr_stream *xdr) | |
5396 | { | |
5397 | return decode_op_hdr(xdr, OP_RESTOREFH); | |
5398 | } | |
5399 | ||
029d105e | 5400 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
db145db0 | 5401 | struct nfs_getaclres *res, enum nfs4_acl_type type) |
029d105e | 5402 | { |
256e48bb | 5403 | unsigned int savep; |
029d105e | 5404 | uint32_t attrlen, |
dae100c2 | 5405 | bitmap[3] = {0}; |
029d105e BF |
5406 | int status; |
5407 | ||
bf118a34 | 5408 | res->acl_len = 0; |
029d105e BF |
5409 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
5410 | goto out; | |
5a006899 | 5411 | |
519d3959 TM |
5412 | xdr_enter_page(xdr, xdr->buf->page_len); |
5413 | ||
029d105e BF |
5414 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
5415 | goto out; | |
5416 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
5417 | goto out; | |
5418 | ||
db145db0 TM |
5419 | switch (type) { |
5420 | default: | |
5421 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) | |
5422 | return -EIO; | |
5423 | if (!(bitmap[0] & FATTR4_WORD0_ACL)) | |
5424 | return -EOPNOTSUPP; | |
5425 | break; | |
5426 | case NFS4ACL_DACL: | |
5427 | if (unlikely(bitmap[0] || bitmap[1] & (FATTR4_WORD1_DACL - 1U))) | |
5428 | return -EIO; | |
5429 | if (!(bitmap[1] & FATTR4_WORD1_DACL)) | |
5430 | return -EOPNOTSUPP; | |
5431 | break; | |
5432 | case NFS4ACL_SACL: | |
5433 | if (unlikely(bitmap[0] || bitmap[1] & (FATTR4_WORD1_SACL - 1U))) | |
5434 | return -EIO; | |
5435 | if (!(bitmap[1] & FATTR4_WORD1_SACL)) | |
5436 | return -EOPNOTSUPP; | |
5437 | } | |
029d105e | 5438 | |
db145db0 TM |
5439 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
5440 | * are stored with the acl data to handle the problem of | |
5441 | * variable length bitmaps.*/ | |
5442 | res->acl_data_offset = xdr_page_pos(xdr); | |
5443 | res->acl_len = attrlen; | |
5444 | ||
5445 | /* Check for receive buffer overflow */ | |
5446 | if (res->acl_len > xdr_stream_remaining(xdr) || | |
5447 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { | |
5448 | res->acl_flags |= NFS4_ACL_TRUNC; | |
5449 | dprintk("NFS: acl reply: attrlen %u > page_len %zu\n", | |
5450 | attrlen, xdr_stream_remaining(xdr)); | |
5451 | } | |
029d105e BF |
5452 | out: |
5453 | return status; | |
5454 | } | |
5455 | ||
1da177e4 LT |
5456 | static int |
5457 | decode_savefh(struct xdr_stream *xdr) | |
5458 | { | |
5459 | return decode_op_hdr(xdr, OP_SAVEFH); | |
5460 | } | |
5461 | ||
9e9ecc03 | 5462 | static int decode_setattr(struct xdr_stream *xdr) |
1da177e4 | 5463 | { |
1da177e4 LT |
5464 | int status; |
5465 | ||
1da177e4 LT |
5466 | status = decode_op_hdr(xdr, OP_SETATTR); |
5467 | if (status) | |
5468 | return status; | |
37c88763 | 5469 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
c0eae66e | 5470 | return 0; |
c0eae66e | 5471 | return -EIO; |
1da177e4 LT |
5472 | } |
5473 | ||
bb8b27e5 | 5474 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) |
1da177e4 | 5475 | { |
8687b63a | 5476 | __be32 *p; |
1da177e4 LT |
5477 | uint32_t opnum; |
5478 | int32_t nfserr; | |
5479 | ||
c0eae66e BH |
5480 | p = xdr_inline_decode(xdr, 8); |
5481 | if (unlikely(!p)) | |
eb72f484 | 5482 | return -EIO; |
6f723f77 | 5483 | opnum = be32_to_cpup(p++); |
1da177e4 | 5484 | if (opnum != OP_SETCLIENTID) { |
fe82a183 | 5485 | dprintk("nfs: decode_setclientid: Server returned operation" |
6c0195a4 | 5486 | " %d\n", opnum); |
1da177e4 LT |
5487 | return -EIO; |
5488 | } | |
cccddf4f | 5489 | nfserr = be32_to_cpup(p); |
1da177e4 | 5490 | if (nfserr == NFS_OK) { |
c0eae66e BH |
5491 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
5492 | if (unlikely(!p)) | |
eb72f484 | 5493 | return -EIO; |
bb8b27e5 TM |
5494 | p = xdr_decode_hyper(p, &res->clientid); |
5495 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); | |
1da177e4 LT |
5496 | } else if (nfserr == NFSERR_CLID_INUSE) { |
5497 | uint32_t len; | |
5498 | ||
5499 | /* skip netid string */ | |
c0eae66e BH |
5500 | p = xdr_inline_decode(xdr, 4); |
5501 | if (unlikely(!p)) | |
eb72f484 | 5502 | return -EIO; |
cccddf4f | 5503 | len = be32_to_cpup(p); |
c0eae66e BH |
5504 | p = xdr_inline_decode(xdr, len); |
5505 | if (unlikely(!p)) | |
eb72f484 | 5506 | return -EIO; |
1da177e4 LT |
5507 | |
5508 | /* skip uaddr string */ | |
c0eae66e BH |
5509 | p = xdr_inline_decode(xdr, 4); |
5510 | if (unlikely(!p)) | |
eb72f484 | 5511 | return -EIO; |
cccddf4f | 5512 | len = be32_to_cpup(p); |
c0eae66e BH |
5513 | p = xdr_inline_decode(xdr, len); |
5514 | if (unlikely(!p)) | |
eb72f484 | 5515 | return -EIO; |
1da177e4 LT |
5516 | return -NFSERR_CLID_INUSE; |
5517 | } else | |
856dff3d | 5518 | return nfs4_stat_to_errno(nfserr); |
1da177e4 LT |
5519 | |
5520 | return 0; | |
5521 | } | |
5522 | ||
5523 | static int decode_setclientid_confirm(struct xdr_stream *xdr) | |
5524 | { | |
5525 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); | |
5526 | } | |
5527 | ||
9137bdf3 | 5528 | static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) |
1da177e4 | 5529 | { |
8687b63a | 5530 | __be32 *p; |
1da177e4 LT |
5531 | int status; |
5532 | ||
5533 | status = decode_op_hdr(xdr, OP_WRITE); | |
5534 | if (status) | |
5535 | return status; | |
5536 | ||
2f2c63bc | 5537 | p = xdr_inline_decode(xdr, 8); |
c0eae66e | 5538 | if (unlikely(!p)) |
eb72f484 | 5539 | return -EIO; |
6f723f77 BH |
5540 | res->count = be32_to_cpup(p++); |
5541 | res->verf->committed = be32_to_cpup(p++); | |
2f2c63bc | 5542 | return decode_write_verifier(xdr, &res->verf->verifier); |
1da177e4 LT |
5543 | } |
5544 | ||
5545 | static int decode_delegreturn(struct xdr_stream *xdr) | |
5546 | { | |
5547 | return decode_op_hdr(xdr, OP_DELEGRETURN); | |
5548 | } | |
5549 | ||
fb15b26f CL |
5550 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
5551 | struct nfs4_secinfo4 *flavor) | |
5a5ea0d4 | 5552 | { |
fb15b26f | 5553 | u32 oid_len; |
5a5ea0d4 BS |
5554 | __be32 *p; |
5555 | ||
5556 | p = xdr_inline_decode(xdr, 4); | |
5557 | if (unlikely(!p)) | |
eb72f484 | 5558 | return -EIO; |
fb15b26f CL |
5559 | oid_len = be32_to_cpup(p); |
5560 | if (oid_len > GSS_OID_MAX_LEN) | |
eb72f484 | 5561 | return -EINVAL; |
5a5ea0d4 | 5562 | |
fb15b26f | 5563 | p = xdr_inline_decode(xdr, oid_len); |
5a5ea0d4 | 5564 | if (unlikely(!p)) |
eb72f484 | 5565 | return -EIO; |
fb15b26f CL |
5566 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
5567 | flavor->flavor_info.oid.len = oid_len; | |
5a5ea0d4 BS |
5568 | |
5569 | p = xdr_inline_decode(xdr, 8); | |
5570 | if (unlikely(!p)) | |
eb72f484 | 5571 | return -EIO; |
fb15b26f CL |
5572 | flavor->flavor_info.qop = be32_to_cpup(p++); |
5573 | flavor->flavor_info.service = be32_to_cpup(p); | |
5a5ea0d4 BS |
5574 | |
5575 | return 0; | |
5a5ea0d4 BS |
5576 | } |
5577 | ||
31e4dda4 | 5578 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5a5ea0d4 | 5579 | { |
fb15b26f CL |
5580 | struct nfs4_secinfo4 *sec_flavor; |
5581 | unsigned int i, num_flavors; | |
5a5ea0d4 BS |
5582 | int status; |
5583 | __be32 *p; | |
5a5ea0d4 | 5584 | |
5a5ea0d4 BS |
5585 | p = xdr_inline_decode(xdr, 4); |
5586 | if (unlikely(!p)) | |
eb72f484 | 5587 | return -EIO; |
5a5ea0d4 | 5588 | |
c3dfc280 BS |
5589 | res->flavors->num_flavors = 0; |
5590 | num_flavors = be32_to_cpup(p); | |
5591 | ||
5592 | for (i = 0; i < num_flavors; i++) { | |
5a5ea0d4 | 5593 | sec_flavor = &res->flavors->flavors[i]; |
c3dfc280 | 5594 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
5a5ea0d4 BS |
5595 | break; |
5596 | ||
5597 | p = xdr_inline_decode(xdr, 4); | |
5598 | if (unlikely(!p)) | |
eb72f484 | 5599 | return -EIO; |
5a5ea0d4 BS |
5600 | sec_flavor->flavor = be32_to_cpup(p); |
5601 | ||
5602 | if (sec_flavor->flavor == RPC_AUTH_GSS) { | |
613e901e BS |
5603 | status = decode_secinfo_gss(xdr, sec_flavor); |
5604 | if (status) | |
5605 | goto out; | |
5a5ea0d4 | 5606 | } |
c3dfc280 | 5607 | res->flavors->num_flavors++; |
5a5ea0d4 BS |
5608 | } |
5609 | ||
31e4dda4 | 5610 | status = 0; |
613e901e BS |
5611 | out: |
5612 | return status; | |
5a5ea0d4 BS |
5613 | } |
5614 | ||
31e4dda4 BS |
5615 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5616 | { | |
5617 | int status = decode_op_hdr(xdr, OP_SECINFO); | |
5618 | if (status) | |
5619 | return status; | |
5620 | return decode_secinfo_common(xdr, res); | |
5621 | } | |
5622 | ||
99fe60d0 | 5623 | #if defined(CONFIG_NFS_V4_1) |
31e4dda4 BS |
5624 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5625 | { | |
5626 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); | |
5627 | if (status) | |
5628 | return status; | |
5629 | return decode_secinfo_common(xdr, res); | |
5630 | } | |
5631 | ||
2031cd1a WAA |
5632 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
5633 | { | |
f114759c TM |
5634 | if (xdr_stream_decode_uint32_array(xdr, op_map->u.words, |
5635 | ARRAY_SIZE(op_map->u.words)) < 0) | |
2031cd1a | 5636 | return -EIO; |
2031cd1a WAA |
5637 | return 0; |
5638 | } | |
5639 | ||
99fe60d0 BH |
5640 | static int decode_exchange_id(struct xdr_stream *xdr, |
5641 | struct nfs41_exchange_id_res *res) | |
5642 | { | |
5643 | __be32 *p; | |
5644 | uint32_t dummy; | |
2460ba57 | 5645 | char *dummy_str; |
99fe60d0 | 5646 | int status; |
7d2ed9ac | 5647 | uint32_t impl_id_count; |
99fe60d0 BH |
5648 | |
5649 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); | |
5650 | if (status) | |
5651 | return status; | |
5652 | ||
c0eae66e BH |
5653 | p = xdr_inline_decode(xdr, 8); |
5654 | if (unlikely(!p)) | |
eb72f484 | 5655 | return -EIO; |
32b01310 | 5656 | xdr_decode_hyper(p, &res->clientid); |
c0eae66e BH |
5657 | p = xdr_inline_decode(xdr, 12); |
5658 | if (unlikely(!p)) | |
eb72f484 | 5659 | return -EIO; |
32b01310 TM |
5660 | res->seqid = be32_to_cpup(p++); |
5661 | res->flags = be32_to_cpup(p++); | |
99fe60d0 | 5662 | |
2031cd1a WAA |
5663 | res->state_protect.how = be32_to_cpup(p); |
5664 | switch (res->state_protect.how) { | |
5665 | case SP4_NONE: | |
5666 | break; | |
5667 | case SP4_MACH_CRED: | |
5668 | status = decode_op_map(xdr, &res->state_protect.enforce); | |
5669 | if (status) | |
5670 | return status; | |
5671 | status = decode_op_map(xdr, &res->state_protect.allow); | |
5672 | if (status) | |
5673 | return status; | |
5674 | break; | |
5675 | default: | |
5676 | WARN_ON_ONCE(1); | |
99fe60d0 | 5677 | return -EIO; |
2031cd1a | 5678 | } |
99fe60d0 | 5679 | |
acdeb69d | 5680 | /* server_owner4.so_minor_id */ |
c0eae66e BH |
5681 | p = xdr_inline_decode(xdr, 8); |
5682 | if (unlikely(!p)) | |
eb72f484 | 5683 | return -EIO; |
acdeb69d | 5684 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
99fe60d0 | 5685 | |
acdeb69d | 5686 | /* server_owner4.so_major_id */ |
2460ba57 BH |
5687 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
5688 | if (unlikely(status)) | |
5689 | return status; | |
acdeb69d CL |
5690 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
5691 | res->server_owner->major_id_sz = dummy; | |
99fe60d0 | 5692 | |
acdeb69d | 5693 | /* server_scope4 */ |
2460ba57 BH |
5694 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
5695 | if (unlikely(status)) | |
5696 | return status; | |
78fe0f41 WAA |
5697 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
5698 | res->server_scope->server_scope_sz = dummy; | |
5699 | ||
7d2ed9ac WAA |
5700 | /* Implementation Id */ |
5701 | p = xdr_inline_decode(xdr, 4); | |
5702 | if (unlikely(!p)) | |
eb72f484 | 5703 | return -EIO; |
7d2ed9ac | 5704 | impl_id_count = be32_to_cpup(p++); |
99fe60d0 | 5705 | |
7d2ed9ac WAA |
5706 | if (impl_id_count) { |
5707 | /* nii_domain */ | |
5708 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | |
5709 | if (unlikely(status)) | |
5710 | return status; | |
7d2ed9ac WAA |
5711 | memcpy(res->impl_id->domain, dummy_str, dummy); |
5712 | ||
5713 | /* nii_name */ | |
5714 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | |
5715 | if (unlikely(status)) | |
5716 | return status; | |
7d2ed9ac WAA |
5717 | memcpy(res->impl_id->name, dummy_str, dummy); |
5718 | ||
5719 | /* nii_date */ | |
5720 | p = xdr_inline_decode(xdr, 12); | |
5721 | if (unlikely(!p)) | |
eb72f484 | 5722 | return -EIO; |
7d2ed9ac WAA |
5723 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
5724 | res->impl_id->date.nseconds = be32_to_cpup(p); | |
5725 | ||
5726 | /* if there's more than one entry, ignore the rest */ | |
5727 | } | |
99fe60d0 BH |
5728 | return 0; |
5729 | } | |
fc931582 AA |
5730 | |
5731 | static int decode_chan_attrs(struct xdr_stream *xdr, | |
5732 | struct nfs4_channel_attrs *attrs) | |
5733 | { | |
5734 | __be32 *p; | |
c9c30dd5 | 5735 | u32 nr_attrs, val; |
fc931582 | 5736 | |
c0eae66e BH |
5737 | p = xdr_inline_decode(xdr, 28); |
5738 | if (unlikely(!p)) | |
eb72f484 | 5739 | return -EIO; |
c9c30dd5 BH |
5740 | val = be32_to_cpup(p++); /* headerpadsz */ |
5741 | if (val) | |
5742 | return -EINVAL; /* no support for header padding yet */ | |
6f723f77 BH |
5743 | attrs->max_rqst_sz = be32_to_cpup(p++); |
5744 | attrs->max_resp_sz = be32_to_cpup(p++); | |
5745 | attrs->max_resp_sz_cached = be32_to_cpup(p++); | |
5746 | attrs->max_ops = be32_to_cpup(p++); | |
5747 | attrs->max_reqs = be32_to_cpup(p++); | |
cccddf4f | 5748 | nr_attrs = be32_to_cpup(p); |
fc931582 | 5749 | if (unlikely(nr_attrs > 1)) { |
a030889a WAA |
5750 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
5751 | "count %u\n", __func__, nr_attrs); | |
fc931582 AA |
5752 | return -EINVAL; |
5753 | } | |
c0eae66e BH |
5754 | if (nr_attrs == 1) { |
5755 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ | |
5756 | if (unlikely(!p)) | |
eb72f484 | 5757 | return -EIO; |
c0eae66e | 5758 | } |
fc931582 AA |
5759 | return 0; |
5760 | } | |
5761 | ||
e78291e4 BH |
5762 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
5763 | { | |
5764 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); | |
fc931582 AA |
5765 | } |
5766 | ||
7c44f1ae WAA |
5767 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
5768 | struct nfs41_bind_conn_to_session_res *res) | |
5769 | { | |
5770 | __be32 *p; | |
5771 | int status; | |
5772 | ||
5773 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); | |
5774 | if (!status) | |
71a097c6 | 5775 | status = decode_sessionid(xdr, &res->sessionid); |
7c44f1ae WAA |
5776 | if (unlikely(status)) |
5777 | return status; | |
5778 | ||
5779 | /* dir flags, rdma mode bool */ | |
5780 | p = xdr_inline_decode(xdr, 8); | |
5781 | if (unlikely(!p)) | |
eb72f484 | 5782 | return -EIO; |
7c44f1ae WAA |
5783 | |
5784 | res->dir = be32_to_cpup(p++); | |
5785 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) | |
5786 | return -EIO; | |
5787 | if (be32_to_cpup(p) == 0) | |
5788 | res->use_conn_in_rdma_mode = false; | |
5789 | else | |
5790 | res->use_conn_in_rdma_mode = true; | |
5791 | ||
5792 | return 0; | |
7c44f1ae WAA |
5793 | } |
5794 | ||
fc931582 AA |
5795 | static int decode_create_session(struct xdr_stream *xdr, |
5796 | struct nfs41_create_session_res *res) | |
5797 | { | |
5798 | __be32 *p; | |
5799 | int status; | |
fc931582 AA |
5800 | |
5801 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); | |
e78291e4 | 5802 | if (!status) |
79969dd1 | 5803 | status = decode_sessionid(xdr, &res->sessionid); |
e78291e4 | 5804 | if (unlikely(status)) |
fc931582 AA |
5805 | return status; |
5806 | ||
fc931582 | 5807 | /* seqid, flags */ |
c0eae66e BH |
5808 | p = xdr_inline_decode(xdr, 8); |
5809 | if (unlikely(!p)) | |
eb72f484 | 5810 | return -EIO; |
79969dd1 TM |
5811 | res->seqid = be32_to_cpup(p++); |
5812 | res->flags = be32_to_cpup(p); | |
fc931582 AA |
5813 | |
5814 | /* Channel attributes */ | |
79969dd1 | 5815 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
fc931582 | 5816 | if (!status) |
79969dd1 | 5817 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
fc931582 AA |
5818 | return status; |
5819 | } | |
0f3e66c6 AA |
5820 | |
5821 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | |
5822 | { | |
5823 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | |
5824 | } | |
18019753 | 5825 | |
66245539 TM |
5826 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
5827 | { | |
5828 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); | |
5829 | } | |
5830 | ||
18019753 RL |
5831 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
5832 | { | |
5833 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); | |
5834 | } | |
99fe60d0 BH |
5835 | #endif /* CONFIG_NFS_V4_1 */ |
5836 | ||
9b7b9fcc AA |
5837 | static int decode_sequence(struct xdr_stream *xdr, |
5838 | struct nfs4_sequence_res *res, | |
5839 | struct rpc_rqst *rqstp) | |
5840 | { | |
5841 | #if defined(CONFIG_NFS_V4_1) | |
e3725ec0 | 5842 | struct nfs4_session *session; |
fc01cea9 AA |
5843 | struct nfs4_sessionid id; |
5844 | u32 dummy; | |
5845 | int status; | |
5846 | __be32 *p; | |
5847 | ||
e3725ec0 | 5848 | if (res->sr_slot == NULL) |
9b7b9fcc | 5849 | return 0; |
3bd2384a CL |
5850 | if (!res->sr_slot->table->session) |
5851 | return 0; | |
9b7b9fcc | 5852 | |
fc01cea9 | 5853 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
e78291e4 BH |
5854 | if (!status) |
5855 | status = decode_sessionid(xdr, &id); | |
5856 | if (unlikely(status)) | |
fc01cea9 | 5857 | goto out_err; |
9b7b9fcc | 5858 | |
fc01cea9 AA |
5859 | /* |
5860 | * If the server returns different values for sessionID, slotID or | |
5861 | * sequence number, the server is looney tunes. | |
5862 | */ | |
fdcb4577 | 5863 | status = -EREMOTEIO; |
e3725ec0 | 5864 | session = res->sr_slot->table->session; |
fc01cea9 | 5865 | |
e3725ec0 | 5866 | if (memcmp(id.data, session->sess_id.data, |
fc01cea9 AA |
5867 | NFS4_MAX_SESSIONID_LEN)) { |
5868 | dprintk("%s Invalid session id\n", __func__); | |
5869 | goto out_err; | |
5870 | } | |
e78291e4 | 5871 | |
c0eae66e BH |
5872 | p = xdr_inline_decode(xdr, 20); |
5873 | if (unlikely(!p)) | |
5874 | goto out_overflow; | |
e78291e4 | 5875 | |
fc01cea9 | 5876 | /* seqid */ |
6f723f77 | 5877 | dummy = be32_to_cpup(p++); |
dfb4f309 | 5878 | if (dummy != res->sr_slot->seq_nr) { |
fc01cea9 AA |
5879 | dprintk("%s Invalid sequence number\n", __func__); |
5880 | goto out_err; | |
5881 | } | |
5882 | /* slot id */ | |
6f723f77 | 5883 | dummy = be32_to_cpup(p++); |
df2fabff | 5884 | if (dummy != res->sr_slot->slot_nr) { |
fc01cea9 AA |
5885 | dprintk("%s Invalid slot id\n", __func__); |
5886 | goto out_err; | |
5887 | } | |
da0507b7 TM |
5888 | /* highest slot id */ |
5889 | res->sr_highest_slotid = be32_to_cpup(p++); | |
464ee9f9 TM |
5890 | /* target highest slot id */ |
5891 | res->sr_target_highest_slotid = be32_to_cpup(p++); | |
0629e370 AB |
5892 | /* result flags */ |
5893 | res->sr_status_flags = be32_to_cpup(p); | |
fc01cea9 AA |
5894 | status = 0; |
5895 | out_err: | |
5896 | res->sr_status = status; | |
5897 | return status; | |
c0eae66e | 5898 | out_overflow: |
c0eae66e BH |
5899 | status = -EIO; |
5900 | goto out_err; | |
fc01cea9 | 5901 | #else /* CONFIG_NFS_V4_1 */ |
9b7b9fcc | 5902 | return 0; |
fc01cea9 | 5903 | #endif /* CONFIG_NFS_V4_1 */ |
9b7b9fcc AA |
5904 | } |
5905 | ||
b1f69b75 | 5906 | #if defined(CONFIG_NFS_V4_1) |
93b717fd TM |
5907 | static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
5908 | { | |
5909 | stateid->type = NFS4_LAYOUT_STATEID_TYPE; | |
5910 | return decode_stateid(xdr, stateid); | |
5911 | } | |
5912 | ||
b1f69b75 | 5913 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
4e590803 | 5914 | struct nfs4_getdeviceinfo_res *res) |
b1f69b75 | 5915 | { |
4e590803 | 5916 | struct pnfs_device *pdev = res->pdev; |
b1f69b75 AA |
5917 | __be32 *p; |
5918 | uint32_t len, type; | |
5919 | int status; | |
5920 | ||
5921 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); | |
5922 | if (status) { | |
5923 | if (status == -ETOOSMALL) { | |
5924 | p = xdr_inline_decode(xdr, 4); | |
5925 | if (unlikely(!p)) | |
eb72f484 | 5926 | return -EIO; |
b1f69b75 AA |
5927 | pdev->mincount = be32_to_cpup(p); |
5928 | dprintk("%s: Min count too small. mincnt = %u\n", | |
5929 | __func__, pdev->mincount); | |
5930 | } | |
5931 | return status; | |
5932 | } | |
5933 | ||
5934 | p = xdr_inline_decode(xdr, 8); | |
5935 | if (unlikely(!p)) | |
eb72f484 | 5936 | return -EIO; |
b1f69b75 AA |
5937 | type = be32_to_cpup(p++); |
5938 | if (type != pdev->layout_type) { | |
5939 | dprintk("%s: layout mismatch req: %u pdev: %u\n", | |
5940 | __func__, pdev->layout_type, type); | |
5941 | return -EINVAL; | |
5942 | } | |
5943 | /* | |
5944 | * Get the length of the opaque device_addr4. xdr_read_pages places | |
5945 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) | |
5946 | * and places the remaining xdr data in xdr_buf->tail | |
5947 | */ | |
5948 | pdev->mincount = be32_to_cpup(p); | |
13fe4ba1 | 5949 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
eb72f484 | 5950 | return -EIO; |
b1f69b75 AA |
5951 | |
5952 | /* Parse notification bitmap, verifying that it is zero. */ | |
5953 | p = xdr_inline_decode(xdr, 4); | |
5954 | if (unlikely(!p)) | |
eb72f484 | 5955 | return -EIO; |
b1f69b75 AA |
5956 | len = be32_to_cpup(p); |
5957 | if (len) { | |
ead00597 | 5958 | uint32_t i; |
b1f69b75 AA |
5959 | |
5960 | p = xdr_inline_decode(xdr, 4 * len); | |
5961 | if (unlikely(!p)) | |
eb72f484 | 5962 | return -EIO; |
84c9dee3 | 5963 | |
4e590803 | 5964 | res->notification = be32_to_cpup(p++); |
84c9dee3 CH |
5965 | for (i = 1; i < len; i++) { |
5966 | if (be32_to_cpup(p++)) { | |
5967 | dprintk("%s: unsupported notification\n", | |
b1f69b75 AA |
5968 | __func__); |
5969 | return -EIO; | |
5970 | } | |
5971 | } | |
5972 | } | |
5973 | return 0; | |
b1f69b75 AA |
5974 | } |
5975 | ||
5976 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | |
5977 | struct nfs4_layoutget_res *res) | |
5978 | { | |
5979 | __be32 *p; | |
5980 | int status; | |
5981 | u32 layout_count; | |
64bd577e | 5982 | u32 recvd; |
b1f69b75 AA |
5983 | |
5984 | status = decode_op_hdr(xdr, OP_LAYOUTGET); | |
5985 | if (status) | |
808ba32a | 5986 | goto out; |
ea9d23f5 TM |
5987 | p = xdr_inline_decode(xdr, 4); |
5988 | if (unlikely(!p)) | |
5989 | goto out_overflow; | |
5990 | res->return_on_close = be32_to_cpup(p); | |
93b717fd | 5991 | decode_layout_stateid(xdr, &res->stateid); |
ea9d23f5 | 5992 | p = xdr_inline_decode(xdr, 4); |
b1f69b75 AA |
5993 | if (unlikely(!p)) |
5994 | goto out_overflow; | |
b1f69b75 AA |
5995 | layout_count = be32_to_cpup(p); |
5996 | if (!layout_count) { | |
5997 | dprintk("%s: server responded with empty layout array\n", | |
5998 | __func__); | |
808ba32a FI |
5999 | status = -EINVAL; |
6000 | goto out; | |
b1f69b75 AA |
6001 | } |
6002 | ||
35124a09 | 6003 | p = xdr_inline_decode(xdr, 28); |
b1f69b75 AA |
6004 | if (unlikely(!p)) |
6005 | goto out_overflow; | |
6006 | p = xdr_decode_hyper(p, &res->range.offset); | |
6007 | p = xdr_decode_hyper(p, &res->range.length); | |
6008 | res->range.iomode = be32_to_cpup(p++); | |
6009 | res->type = be32_to_cpup(p++); | |
35124a09 | 6010 | res->layoutp->len = be32_to_cpup(p); |
b1f69b75 AA |
6011 | |
6012 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", | |
6013 | __func__, | |
6014 | (unsigned long)res->range.offset, | |
6015 | (unsigned long)res->range.length, | |
6016 | res->range.iomode, | |
6017 | res->type, | |
35124a09 WAA |
6018 | res->layoutp->len); |
6019 | ||
64bd577e | 6020 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
35124a09 WAA |
6021 | if (res->layoutp->len > recvd) { |
6022 | dprintk("NFS: server cheating in layoutget reply: " | |
6023 | "layout len %u > recvd %u\n", | |
6024 | res->layoutp->len, recvd); | |
808ba32a FI |
6025 | status = -EINVAL; |
6026 | goto out; | |
35124a09 | 6027 | } |
b1f69b75 | 6028 | |
b1f69b75 AA |
6029 | if (layout_count > 1) { |
6030 | /* We only handle a length one array at the moment. Any | |
6031 | * further entries are just ignored. Note that this means | |
6032 | * the client may see a response that is less than the | |
6033 | * minimum it requested. | |
6034 | */ | |
6035 | dprintk("%s: server responded with %d layouts, dropping tail\n", | |
6036 | __func__, layout_count); | |
6037 | } | |
6038 | ||
808ba32a FI |
6039 | out: |
6040 | res->status = status; | |
6041 | return status; | |
b1f69b75 | 6042 | out_overflow: |
808ba32a FI |
6043 | status = -EIO; |
6044 | goto out; | |
b1f69b75 | 6045 | } |
863a3c6c | 6046 | |
cbe82603 BH |
6047 | static int decode_layoutreturn(struct xdr_stream *xdr, |
6048 | struct nfs4_layoutreturn_res *res) | |
6049 | { | |
6050 | __be32 *p; | |
6051 | int status; | |
6052 | ||
6053 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); | |
6054 | if (status) | |
6055 | return status; | |
6056 | p = xdr_inline_decode(xdr, 4); | |
6057 | if (unlikely(!p)) | |
eb72f484 | 6058 | return -EIO; |
cbe82603 BH |
6059 | res->lrs_present = be32_to_cpup(p); |
6060 | if (res->lrs_present) | |
93b717fd | 6061 | status = decode_layout_stateid(xdr, &res->stateid); |
fcd8843c TM |
6062 | else |
6063 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); | |
cbe82603 | 6064 | return status; |
cbe82603 BH |
6065 | } |
6066 | ||
863a3c6c AA |
6067 | static int decode_layoutcommit(struct xdr_stream *xdr, |
6068 | struct rpc_rqst *req, | |
6069 | struct nfs4_layoutcommit_res *res) | |
6070 | { | |
6071 | __be32 *p; | |
6072 | __u32 sizechanged; | |
6073 | int status; | |
6074 | ||
6075 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); | |
db29c089 | 6076 | res->status = status; |
863a3c6c AA |
6077 | if (status) |
6078 | return status; | |
6079 | ||
6080 | p = xdr_inline_decode(xdr, 4); | |
6081 | if (unlikely(!p)) | |
eb72f484 | 6082 | return -EIO; |
863a3c6c AA |
6083 | sizechanged = be32_to_cpup(p); |
6084 | ||
6085 | if (sizechanged) { | |
6086 | /* throw away new size */ | |
6087 | p = xdr_inline_decode(xdr, 8); | |
6088 | if (unlikely(!p)) | |
eb72f484 | 6089 | return -EIO; |
863a3c6c AA |
6090 | } |
6091 | return 0; | |
863a3c6c | 6092 | } |
7d974794 BS |
6093 | |
6094 | static int decode_test_stateid(struct xdr_stream *xdr, | |
6095 | struct nfs41_test_stateid_res *res) | |
6096 | { | |
6097 | __be32 *p; | |
6098 | int status; | |
6099 | int num_res; | |
6100 | ||
6101 | status = decode_op_hdr(xdr, OP_TEST_STATEID); | |
6102 | if (status) | |
6103 | return status; | |
6104 | ||
6105 | p = xdr_inline_decode(xdr, 4); | |
6106 | if (unlikely(!p)) | |
eb72f484 | 6107 | return -EIO; |
7d974794 BS |
6108 | num_res = be32_to_cpup(p++); |
6109 | if (num_res != 1) | |
eb72f484 | 6110 | return -EIO; |
7d974794 BS |
6111 | |
6112 | p = xdr_inline_decode(xdr, 4); | |
6113 | if (unlikely(!p)) | |
eb72f484 | 6114 | return -EIO; |
7d974794 | 6115 | res->status = be32_to_cpup(p++); |
1cab0652 BS |
6116 | |
6117 | return status; | |
7d974794 | 6118 | } |
9aeda35f BS |
6119 | |
6120 | static int decode_free_stateid(struct xdr_stream *xdr, | |
6121 | struct nfs41_free_stateid_res *res) | |
6122 | { | |
9f79fb48 | 6123 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
9aeda35f | 6124 | return res->status; |
9aeda35f | 6125 | } |
cf805165 TM |
6126 | #else |
6127 | static inline | |
6128 | int decode_layoutreturn(struct xdr_stream *xdr, | |
6129 | struct nfs4_layoutreturn_res *res) | |
6130 | { | |
6131 | return 0; | |
6132 | } | |
56f487f8 FI |
6133 | |
6134 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | |
6135 | struct nfs4_layoutget_res *res) | |
6136 | { | |
6137 | return 0; | |
6138 | } | |
6139 | ||
b1f69b75 AA |
6140 | #endif /* CONFIG_NFS_V4_1 */ |
6141 | ||
49c2559e BH |
6142 | /* |
6143 | * END OF "GENERIC" DECODE ROUTINES. | |
6144 | */ | |
6145 | ||
1da177e4 LT |
6146 | /* |
6147 | * Decode OPEN_DOWNGRADE response | |
6148 | */ | |
bf269551 CL |
6149 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
6150 | struct xdr_stream *xdr, | |
fc016483 | 6151 | void *data) |
1da177e4 | 6152 | { |
fc016483 | 6153 | struct nfs_closeres *res = data; |
05d564fe AA |
6154 | struct compound_hdr hdr; |
6155 | int status; | |
6156 | ||
bf269551 | 6157 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6158 | if (status) |
6159 | goto out; | |
bf269551 | 6160 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6161 | if (status) |
6162 | goto out; | |
bf269551 | 6163 | status = decode_putfh(xdr); |
05d564fe AA |
6164 | if (status) |
6165 | goto out; | |
b6808145 TM |
6166 | if (res->lr_res) { |
6167 | status = decode_layoutreturn(xdr, res->lr_res); | |
6168 | res->lr_ret = status; | |
6169 | if (status) | |
6170 | goto out; | |
6171 | } | |
bf269551 | 6172 | status = decode_open_downgrade(xdr, res); |
1da177e4 | 6173 | out: |
05d564fe | 6174 | return status; |
1da177e4 LT |
6175 | } |
6176 | ||
1da177e4 LT |
6177 | /* |
6178 | * Decode ACCESS response | |
6179 | */ | |
bf269551 | 6180 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6181 | void *data) |
1da177e4 | 6182 | { |
fc016483 | 6183 | struct nfs4_accessres *res = data; |
1da177e4 LT |
6184 | struct compound_hdr hdr; |
6185 | int status; | |
6c0195a4 | 6186 | |
bf269551 | 6187 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6188 | if (status) |
6189 | goto out; | |
bf269551 | 6190 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6191 | if (status) |
1da177e4 | 6192 | goto out; |
bf269551 | 6193 | status = decode_putfh(xdr); |
76b32999 TM |
6194 | if (status != 0) |
6195 | goto out; | |
6168f62c | 6196 | status = decode_access(xdr, &res->supported, &res->access); |
76b32999 TM |
6197 | if (status != 0) |
6198 | goto out; | |
8bcbe7d9 TM |
6199 | if (res->fattr) |
6200 | decode_getfattr(xdr, res->fattr, res->server); | |
1da177e4 LT |
6201 | out: |
6202 | return status; | |
6203 | } | |
6204 | ||
6205 | /* | |
6206 | * Decode LOOKUP response | |
6207 | */ | |
bf269551 | 6208 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6209 | void *data) |
1da177e4 | 6210 | { |
fc016483 | 6211 | struct nfs4_lookup_res *res = data; |
1da177e4 LT |
6212 | struct compound_hdr hdr; |
6213 | int status; | |
6c0195a4 | 6214 | |
bf269551 | 6215 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6216 | if (status) |
6217 | goto out; | |
bf269551 | 6218 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6219 | if (status) |
1da177e4 | 6220 | goto out; |
bf269551 CL |
6221 | status = decode_putfh(xdr); |
6222 | if (status) | |
1da177e4 | 6223 | goto out; |
bf269551 CL |
6224 | status = decode_lookup(xdr); |
6225 | if (status) | |
1da177e4 | 6226 | goto out; |
bf269551 CL |
6227 | status = decode_getfh(xdr, res->fh); |
6228 | if (status) | |
1da177e4 | 6229 | goto out; |
1e2f67da | 6230 | status = decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6231 | out: |
6232 | return status; | |
6233 | } | |
6234 | ||
5b5faaf6 JL |
6235 | /* |
6236 | * Decode LOOKUPP response | |
6237 | */ | |
6238 | static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | |
6239 | void *data) | |
6240 | { | |
6241 | struct nfs4_lookupp_res *res = data; | |
6242 | struct compound_hdr hdr; | |
6243 | int status; | |
6244 | ||
6245 | status = decode_compound_hdr(xdr, &hdr); | |
6246 | if (status) | |
6247 | goto out; | |
6248 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
6249 | if (status) | |
6250 | goto out; | |
6251 | status = decode_putfh(xdr); | |
6252 | if (status) | |
6253 | goto out; | |
6254 | status = decode_lookupp(xdr); | |
6255 | if (status) | |
6256 | goto out; | |
6257 | status = decode_getfh(xdr, res->fh); | |
6258 | if (status) | |
6259 | goto out; | |
1e2f67da | 6260 | status = decode_getfattr(xdr, res->fattr, res->server); |
5b5faaf6 JL |
6261 | out: |
6262 | return status; | |
6263 | } | |
6264 | ||
1da177e4 LT |
6265 | /* |
6266 | * Decode LOOKUP_ROOT response | |
6267 | */ | |
bf269551 CL |
6268 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
6269 | struct xdr_stream *xdr, | |
fc016483 | 6270 | void *data) |
1da177e4 | 6271 | { |
fc016483 | 6272 | struct nfs4_lookup_res *res = data; |
1da177e4 LT |
6273 | struct compound_hdr hdr; |
6274 | int status; | |
6c0195a4 | 6275 | |
bf269551 | 6276 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6277 | if (status) |
6278 | goto out; | |
bf269551 | 6279 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6280 | if (status) |
1da177e4 | 6281 | goto out; |
bf269551 CL |
6282 | status = decode_putrootfh(xdr); |
6283 | if (status) | |
1da177e4 | 6284 | goto out; |
bf269551 CL |
6285 | status = decode_getfh(xdr, res->fh); |
6286 | if (status == 0) | |
1e2f67da | 6287 | status = decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6288 | out: |
6289 | return status; | |
6290 | } | |
6291 | ||
6292 | /* | |
6293 | * Decode REMOVE response | |
6294 | */ | |
bf269551 | 6295 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6296 | void *data) |
1da177e4 | 6297 | { |
fc016483 | 6298 | struct nfs_removeres *res = data; |
1da177e4 LT |
6299 | struct compound_hdr hdr; |
6300 | int status; | |
6c0195a4 | 6301 | |
bf269551 | 6302 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6303 | if (status) |
6304 | goto out; | |
bf269551 | 6305 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6306 | if (status) |
1da177e4 | 6307 | goto out; |
bf269551 CL |
6308 | status = decode_putfh(xdr); |
6309 | if (status) | |
16e42959 | 6310 | goto out; |
bf269551 | 6311 | status = decode_remove(xdr, &res->cinfo); |
1da177e4 LT |
6312 | out: |
6313 | return status; | |
6314 | } | |
6315 | ||
6316 | /* | |
6317 | * Decode RENAME response | |
6318 | */ | |
bf269551 | 6319 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6320 | void *data) |
1da177e4 | 6321 | { |
fc016483 | 6322 | struct nfs_renameres *res = data; |
1da177e4 LT |
6323 | struct compound_hdr hdr; |
6324 | int status; | |
6c0195a4 | 6325 | |
bf269551 | 6326 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6327 | if (status) |
6328 | goto out; | |
bf269551 | 6329 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6330 | if (status) |
1da177e4 | 6331 | goto out; |
bf269551 CL |
6332 | status = decode_putfh(xdr); |
6333 | if (status) | |
1da177e4 | 6334 | goto out; |
bf269551 CL |
6335 | status = decode_savefh(xdr); |
6336 | if (status) | |
1da177e4 | 6337 | goto out; |
bf269551 CL |
6338 | status = decode_putfh(xdr); |
6339 | if (status) | |
1da177e4 | 6340 | goto out; |
bf269551 | 6341 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
1da177e4 LT |
6342 | out: |
6343 | return status; | |
6344 | } | |
6345 | ||
6346 | /* | |
6347 | * Decode LINK response | |
6348 | */ | |
bf269551 | 6349 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6350 | void *data) |
1da177e4 | 6351 | { |
fc016483 | 6352 | struct nfs4_link_res *res = data; |
1da177e4 LT |
6353 | struct compound_hdr hdr; |
6354 | int status; | |
6c0195a4 | 6355 | |
bf269551 | 6356 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6357 | if (status) |
6358 | goto out; | |
bf269551 | 6359 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6360 | if (status) |
1da177e4 | 6361 | goto out; |
bf269551 CL |
6362 | status = decode_putfh(xdr); |
6363 | if (status) | |
1da177e4 | 6364 | goto out; |
bf269551 CL |
6365 | status = decode_savefh(xdr); |
6366 | if (status) | |
1da177e4 | 6367 | goto out; |
bf269551 CL |
6368 | status = decode_putfh(xdr); |
6369 | if (status) | |
1da177e4 | 6370 | goto out; |
bf269551 CL |
6371 | status = decode_link(xdr, &res->cinfo); |
6372 | if (status) | |
91ba2eee TM |
6373 | goto out; |
6374 | /* | |
6375 | * Note order: OP_LINK leaves the directory as the current | |
6376 | * filehandle. | |
6377 | */ | |
bf269551 CL |
6378 | status = decode_restorefh(xdr); |
6379 | if (status) | |
91ba2eee | 6380 | goto out; |
1e2f67da | 6381 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6382 | out: |
6383 | return status; | |
6384 | } | |
6385 | ||
6386 | /* | |
6387 | * Decode CREATE response | |
6388 | */ | |
bf269551 | 6389 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6390 | void *data) |
1da177e4 | 6391 | { |
fc016483 | 6392 | struct nfs4_create_res *res = data; |
1da177e4 LT |
6393 | struct compound_hdr hdr; |
6394 | int status; | |
6c0195a4 | 6395 | |
bf269551 | 6396 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6397 | if (status) |
6398 | goto out; | |
bf269551 | 6399 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6400 | if (status) |
1da177e4 | 6401 | goto out; |
bf269551 | 6402 | status = decode_putfh(xdr); |
bf269551 | 6403 | if (status) |
56ae19f3 | 6404 | goto out; |
bf269551 CL |
6405 | status = decode_create(xdr, &res->dir_cinfo); |
6406 | if (status) | |
1da177e4 | 6407 | goto out; |
bf269551 CL |
6408 | status = decode_getfh(xdr, res->fh); |
6409 | if (status) | |
1da177e4 | 6410 | goto out; |
1e2f67da | 6411 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6412 | out: |
6413 | return status; | |
6414 | } | |
6415 | ||
6416 | /* | |
6417 | * Decode SYMLINK response | |
6418 | */ | |
bf269551 | 6419 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6420 | void *res) |
1da177e4 | 6421 | { |
bf269551 | 6422 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
1da177e4 LT |
6423 | } |
6424 | ||
6425 | /* | |
6426 | * Decode GETATTR response | |
6427 | */ | |
bf269551 | 6428 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6429 | void *data) |
1da177e4 | 6430 | { |
fc016483 | 6431 | struct nfs4_getattr_res *res = data; |
1da177e4 LT |
6432 | struct compound_hdr hdr; |
6433 | int status; | |
6c0195a4 | 6434 | |
bf269551 | 6435 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6436 | if (status) |
6437 | goto out; | |
bf269551 | 6438 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6439 | if (status) |
6440 | goto out; | |
bf269551 | 6441 | status = decode_putfh(xdr); |
1da177e4 LT |
6442 | if (status) |
6443 | goto out; | |
1e2f67da | 6444 | status = decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6445 | out: |
6446 | return status; | |
1da177e4 LT |
6447 | } |
6448 | ||
23ec6965 BF |
6449 | /* |
6450 | * Encode an SETACL request | |
6451 | */ | |
9f06c719 | 6452 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
fcc85819 | 6453 | const void *data) |
23ec6965 | 6454 | { |
fcc85819 | 6455 | const struct nfs_setaclargs *args = data; |
05d564fe | 6456 | struct compound_hdr hdr = { |
66cc0429 | 6457 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 6458 | }; |
05d564fe | 6459 | |
9f06c719 CL |
6460 | encode_compound_hdr(xdr, req, &hdr); |
6461 | encode_sequence(xdr, &args->seq_args, &hdr); | |
6462 | encode_putfh(xdr, args->fh, &hdr); | |
6463 | encode_setacl(xdr, args, &hdr); | |
d017931c | 6464 | encode_nops(&hdr); |
23ec6965 | 6465 | } |
05d564fe | 6466 | |
23ec6965 BF |
6467 | /* |
6468 | * Decode SETACL response | |
6469 | */ | |
6470 | static int | |
bf269551 | 6471 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6472 | void *data) |
23ec6965 | 6473 | { |
fc016483 | 6474 | struct nfs_setaclres *res = data; |
23ec6965 BF |
6475 | struct compound_hdr hdr; |
6476 | int status; | |
6477 | ||
bf269551 | 6478 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6479 | if (status) |
6480 | goto out; | |
bf269551 | 6481 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
23ec6965 BF |
6482 | if (status) |
6483 | goto out; | |
bf269551 | 6484 | status = decode_putfh(xdr); |
23ec6965 BF |
6485 | if (status) |
6486 | goto out; | |
bf269551 | 6487 | status = decode_setattr(xdr); |
23ec6965 BF |
6488 | out: |
6489 | return status; | |
6490 | } | |
1da177e4 | 6491 | |
029d105e BF |
6492 | /* |
6493 | * Decode GETACL response | |
6494 | */ | |
6495 | static int | |
bf269551 | 6496 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6497 | void *data) |
029d105e | 6498 | { |
fc016483 | 6499 | struct nfs_getaclres *res = data; |
029d105e BF |
6500 | struct compound_hdr hdr; |
6501 | int status; | |
6502 | ||
0ae4c3e8 CL |
6503 | if (res->acl_scratch != NULL) |
6504 | xdr_set_scratch_page(xdr, res->acl_scratch); | |
bf269551 | 6505 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6506 | if (status) |
6507 | goto out; | |
bf269551 | 6508 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
029d105e BF |
6509 | if (status) |
6510 | goto out; | |
bf269551 | 6511 | status = decode_putfh(xdr); |
029d105e BF |
6512 | if (status) |
6513 | goto out; | |
db145db0 | 6514 | status = decode_getacl(xdr, rqstp, res, res->acl_type); |
029d105e BF |
6515 | |
6516 | out: | |
6517 | return status; | |
6518 | } | |
6519 | ||
1da177e4 LT |
6520 | /* |
6521 | * Decode CLOSE response | |
6522 | */ | |
bf269551 | 6523 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6524 | void *data) |
1da177e4 | 6525 | { |
fc016483 | 6526 | struct nfs_closeres *res = data; |
05d564fe AA |
6527 | struct compound_hdr hdr; |
6528 | int status; | |
6529 | ||
bf269551 | 6530 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6531 | if (status) |
6532 | goto out; | |
bf269551 | 6533 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6534 | if (status) |
6535 | goto out; | |
bf269551 | 6536 | status = decode_putfh(xdr); |
05d564fe AA |
6537 | if (status) |
6538 | goto out; | |
cf805165 TM |
6539 | if (res->lr_res) { |
6540 | status = decode_layoutreturn(xdr, res->lr_res); | |
6541 | res->lr_ret = status; | |
6542 | if (status) | |
6543 | goto out; | |
6544 | } | |
d8d84983 TM |
6545 | if (res->fattr != NULL) { |
6546 | status = decode_getfattr(xdr, res->fattr, res->server); | |
6547 | if (status != 0) | |
6548 | goto out; | |
6549 | } | |
bf269551 | 6550 | status = decode_close(xdr, res); |
1da177e4 | 6551 | out: |
05d564fe | 6552 | return status; |
1da177e4 LT |
6553 | } |
6554 | ||
6555 | /* | |
6556 | * Decode OPEN response | |
6557 | */ | |
bf269551 | 6558 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6559 | void *data) |
1da177e4 | 6560 | { |
fc016483 | 6561 | struct nfs_openres *res = data; |
05d564fe AA |
6562 | struct compound_hdr hdr; |
6563 | int status; | |
6564 | ||
bf269551 | 6565 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6566 | if (status) |
6567 | goto out; | |
bf269551 | 6568 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6569 | if (status) |
6570 | goto out; | |
bf269551 | 6571 | status = decode_putfh(xdr); |
05d564fe AA |
6572 | if (status) |
6573 | goto out; | |
bf269551 | 6574 | status = decode_open(xdr, res); |
56ae19f3 TM |
6575 | if (status) |
6576 | goto out; | |
01913b49 WAA |
6577 | status = decode_getfh(xdr, &res->fh); |
6578 | if (status) | |
1da177e4 | 6579 | goto out; |
ae2bb032 WAA |
6580 | if (res->access_request) |
6581 | decode_access(xdr, &res->access_supported, &res->access_result); | |
1e2f67da | 6582 | decode_getfattr(xdr, res->f_attr, res->server); |
56f487f8 FI |
6583 | if (res->lg_res) |
6584 | decode_layoutget(xdr, rqstp, res->lg_res); | |
1da177e4 | 6585 | out: |
05d564fe | 6586 | return status; |
1da177e4 LT |
6587 | } |
6588 | ||
6589 | /* | |
6590 | * Decode OPEN_CONFIRM response | |
6591 | */ | |
bf269551 CL |
6592 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
6593 | struct xdr_stream *xdr, | |
fc016483 | 6594 | void *data) |
1da177e4 | 6595 | { |
fc016483 | 6596 | struct nfs_open_confirmres *res = data; |
05d564fe AA |
6597 | struct compound_hdr hdr; |
6598 | int status; | |
6599 | ||
bf269551 | 6600 | status = decode_compound_hdr(xdr, &hdr); |
05d564fe AA |
6601 | if (status) |
6602 | goto out; | |
bf269551 | 6603 | status = decode_putfh(xdr); |
05d564fe AA |
6604 | if (status) |
6605 | goto out; | |
bf269551 | 6606 | status = decode_open_confirm(xdr, res); |
1da177e4 | 6607 | out: |
05d564fe | 6608 | return status; |
1da177e4 LT |
6609 | } |
6610 | ||
6611 | /* | |
6612 | * Decode OPEN response | |
6613 | */ | |
bf269551 CL |
6614 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
6615 | struct xdr_stream *xdr, | |
fc016483 | 6616 | void *data) |
1da177e4 | 6617 | { |
fc016483 | 6618 | struct nfs_openres *res = data; |
05d564fe AA |
6619 | struct compound_hdr hdr; |
6620 | int status; | |
6621 | ||
bf269551 | 6622 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6623 | if (status) |
6624 | goto out; | |
bf269551 | 6625 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6626 | if (status) |
6627 | goto out; | |
bf269551 | 6628 | status = decode_putfh(xdr); |
05d564fe AA |
6629 | if (status) |
6630 | goto out; | |
bf269551 | 6631 | status = decode_open(xdr, res); |
05d564fe AA |
6632 | if (status) |
6633 | goto out; | |
ae2bb032 WAA |
6634 | if (res->access_request) |
6635 | decode_access(xdr, &res->access_supported, &res->access_result); | |
6926afd1 | 6636 | decode_getfattr(xdr, res->f_attr, res->server); |
56f487f8 FI |
6637 | if (res->lg_res) |
6638 | decode_layoutget(xdr, rqstp, res->lg_res); | |
1da177e4 | 6639 | out: |
05d564fe | 6640 | return status; |
1da177e4 LT |
6641 | } |
6642 | ||
6643 | /* | |
6644 | * Decode SETATTR response | |
6645 | */ | |
bf269551 CL |
6646 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
6647 | struct xdr_stream *xdr, | |
fc016483 | 6648 | void *data) |
1da177e4 | 6649 | { |
fc016483 | 6650 | struct nfs_setattrres *res = data; |
05d564fe AA |
6651 | struct compound_hdr hdr; |
6652 | int status; | |
6653 | ||
bf269551 | 6654 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6655 | if (status) |
6656 | goto out; | |
bf269551 | 6657 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6658 | if (status) |
6659 | goto out; | |
bf269551 | 6660 | status = decode_putfh(xdr); |
05d564fe AA |
6661 | if (status) |
6662 | goto out; | |
bf269551 | 6663 | status = decode_setattr(xdr); |
05d564fe AA |
6664 | if (status) |
6665 | goto out; | |
1e2f67da | 6666 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 | 6667 | out: |
05d564fe | 6668 | return status; |
1da177e4 LT |
6669 | } |
6670 | ||
6671 | /* | |
6672 | * Decode LOCK response | |
6673 | */ | |
bf269551 | 6674 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6675 | void *data) |
1da177e4 | 6676 | { |
fc016483 | 6677 | struct nfs_lock_res *res = data; |
1da177e4 LT |
6678 | struct compound_hdr hdr; |
6679 | int status; | |
6680 | ||
bf269551 | 6681 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6682 | if (status) |
6683 | goto out; | |
bf269551 | 6684 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6685 | if (status) |
6686 | goto out; | |
bf269551 | 6687 | status = decode_putfh(xdr); |
1da177e4 LT |
6688 | if (status) |
6689 | goto out; | |
bf269551 | 6690 | status = decode_lock(xdr, res); |
1da177e4 LT |
6691 | out: |
6692 | return status; | |
6693 | } | |
6694 | ||
6695 | /* | |
6696 | * Decode LOCKT response | |
6697 | */ | |
bf269551 | 6698 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6699 | void *data) |
1da177e4 | 6700 | { |
fc016483 | 6701 | struct nfs_lockt_res *res = data; |
1da177e4 LT |
6702 | struct compound_hdr hdr; |
6703 | int status; | |
6704 | ||
bf269551 | 6705 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6706 | if (status) |
6707 | goto out; | |
bf269551 | 6708 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6709 | if (status) |
6710 | goto out; | |
bf269551 | 6711 | status = decode_putfh(xdr); |
1da177e4 LT |
6712 | if (status) |
6713 | goto out; | |
bf269551 | 6714 | status = decode_lockt(xdr, res); |
1da177e4 LT |
6715 | out: |
6716 | return status; | |
6717 | } | |
6718 | ||
6719 | /* | |
6720 | * Decode LOCKU response | |
6721 | */ | |
bf269551 | 6722 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6723 | void *data) |
1da177e4 | 6724 | { |
fc016483 | 6725 | struct nfs_locku_res *res = data; |
1da177e4 LT |
6726 | struct compound_hdr hdr; |
6727 | int status; | |
6728 | ||
bf269551 | 6729 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6730 | if (status) |
6731 | goto out; | |
bf269551 | 6732 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6733 | if (status) |
6734 | goto out; | |
bf269551 | 6735 | status = decode_putfh(xdr); |
1da177e4 LT |
6736 | if (status) |
6737 | goto out; | |
bf269551 | 6738 | status = decode_locku(xdr, res); |
1da177e4 LT |
6739 | out: |
6740 | return status; | |
6741 | } | |
6742 | ||
bf269551 CL |
6743 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
6744 | struct xdr_stream *xdr, void *dummy) | |
d3c7b7cc | 6745 | { |
d3c7b7cc TM |
6746 | struct compound_hdr hdr; |
6747 | int status; | |
6748 | ||
bf269551 | 6749 | status = decode_compound_hdr(xdr, &hdr); |
d3c7b7cc | 6750 | if (!status) |
bf269551 | 6751 | status = decode_release_lockowner(xdr); |
d3c7b7cc TM |
6752 | return status; |
6753 | } | |
6754 | ||
1da177e4 LT |
6755 | /* |
6756 | * Decode READLINK response | |
6757 | */ | |
bf269551 CL |
6758 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
6759 | struct xdr_stream *xdr, | |
fc016483 | 6760 | void *data) |
1da177e4 | 6761 | { |
fc016483 | 6762 | struct nfs4_readlink_res *res = data; |
1da177e4 LT |
6763 | struct compound_hdr hdr; |
6764 | int status; | |
6765 | ||
bf269551 | 6766 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6767 | if (status) |
6768 | goto out; | |
bf269551 | 6769 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6770 | if (status) |
6771 | goto out; | |
bf269551 | 6772 | status = decode_putfh(xdr); |
1da177e4 LT |
6773 | if (status) |
6774 | goto out; | |
bf269551 | 6775 | status = decode_readlink(xdr, rqstp); |
1da177e4 LT |
6776 | out: |
6777 | return status; | |
6778 | } | |
6779 | ||
6780 | /* | |
6781 | * Decode READDIR response | |
6782 | */ | |
bf269551 | 6783 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6784 | void *data) |
1da177e4 | 6785 | { |
fc016483 | 6786 | struct nfs4_readdir_res *res = data; |
1da177e4 LT |
6787 | struct compound_hdr hdr; |
6788 | int status; | |
6789 | ||
bf269551 | 6790 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6791 | if (status) |
6792 | goto out; | |
bf269551 | 6793 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6794 | if (status) |
6795 | goto out; | |
bf269551 | 6796 | status = decode_putfh(xdr); |
1da177e4 LT |
6797 | if (status) |
6798 | goto out; | |
bf269551 | 6799 | status = decode_readdir(xdr, rqstp, res); |
1da177e4 LT |
6800 | out: |
6801 | return status; | |
6802 | } | |
6803 | ||
6804 | /* | |
6805 | * Decode Read response | |
6806 | */ | |
bf269551 | 6807 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6808 | void *data) |
1da177e4 | 6809 | { |
fc016483 | 6810 | struct nfs_pgio_res *res = data; |
1da177e4 LT |
6811 | struct compound_hdr hdr; |
6812 | int status; | |
6813 | ||
bf269551 | 6814 | status = decode_compound_hdr(xdr, &hdr); |
aabff4dd | 6815 | res->op_status = hdr.status; |
9b7b9fcc AA |
6816 | if (status) |
6817 | goto out; | |
bf269551 | 6818 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6819 | if (status) |
6820 | goto out; | |
bf269551 | 6821 | status = decode_putfh(xdr); |
1da177e4 LT |
6822 | if (status) |
6823 | goto out; | |
bf269551 | 6824 | status = decode_read(xdr, rqstp, res); |
1da177e4 LT |
6825 | if (!status) |
6826 | status = res->count; | |
6827 | out: | |
6828 | return status; | |
6829 | } | |
6830 | ||
6831 | /* | |
6832 | * Decode WRITE response | |
6833 | */ | |
bf269551 | 6834 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6835 | void *data) |
1da177e4 | 6836 | { |
fc016483 | 6837 | struct nfs_pgio_res *res = data; |
1da177e4 LT |
6838 | struct compound_hdr hdr; |
6839 | int status; | |
6840 | ||
bf269551 | 6841 | status = decode_compound_hdr(xdr, &hdr); |
aabff4dd | 6842 | res->op_status = hdr.status; |
9b7b9fcc AA |
6843 | if (status) |
6844 | goto out; | |
bf269551 | 6845 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6846 | if (status) |
6847 | goto out; | |
bf269551 | 6848 | status = decode_putfh(xdr); |
1da177e4 LT |
6849 | if (status) |
6850 | goto out; | |
bf269551 | 6851 | status = decode_write(xdr, res); |
4f9838c7 TM |
6852 | if (status) |
6853 | goto out; | |
7ffd1064 | 6854 | if (res->fattr) |
6926afd1 | 6855 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6856 | if (!status) |
6857 | status = res->count; | |
6858 | out: | |
6859 | return status; | |
6860 | } | |
6861 | ||
6862 | /* | |
6863 | * Decode COMMIT response | |
6864 | */ | |
bf269551 | 6865 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
fc016483 | 6866 | void *data) |
1da177e4 | 6867 | { |
fc016483 | 6868 | struct nfs_commitres *res = data; |
1da177e4 LT |
6869 | struct compound_hdr hdr; |
6870 | int status; | |
6871 | ||
bf269551 | 6872 | status = decode_compound_hdr(xdr, &hdr); |
aabff4dd | 6873 | res->op_status = hdr.status; |
9b7b9fcc AA |
6874 | if (status) |
6875 | goto out; | |
bf269551 | 6876 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6877 | if (status) |
6878 | goto out; | |
bf269551 | 6879 | status = decode_putfh(xdr); |
1da177e4 LT |
6880 | if (status) |
6881 | goto out; | |
bf269551 | 6882 | status = decode_commit(xdr, res); |
1da177e4 LT |
6883 | out: |
6884 | return status; | |
6885 | } | |
6886 | ||
6887 | /* | |
8b173218 | 6888 | * Decode FSINFO response |
1da177e4 | 6889 | */ |
bf269551 | 6890 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
fc016483 | 6891 | void *data) |
1da177e4 | 6892 | { |
fc016483 | 6893 | struct nfs4_fsinfo_res *res = data; |
1da177e4 LT |
6894 | struct compound_hdr hdr; |
6895 | int status; | |
6896 | ||
bf269551 | 6897 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6898 | if (!status) |
bf269551 | 6899 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6900 | if (!status) |
bf269551 | 6901 | status = decode_putfh(xdr); |
1da177e4 | 6902 | if (!status) |
bf269551 | 6903 | status = decode_fsinfo(xdr, res->fsinfo); |
1da177e4 LT |
6904 | return status; |
6905 | } | |
6906 | ||
6907 | /* | |
8b173218 | 6908 | * Decode PATHCONF response |
1da177e4 | 6909 | */ |
bf269551 | 6910 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
fc016483 | 6911 | void *data) |
1da177e4 | 6912 | { |
fc016483 | 6913 | struct nfs4_pathconf_res *res = data; |
1da177e4 LT |
6914 | struct compound_hdr hdr; |
6915 | int status; | |
6916 | ||
bf269551 | 6917 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6918 | if (!status) |
bf269551 | 6919 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6920 | if (!status) |
bf269551 | 6921 | status = decode_putfh(xdr); |
1da177e4 | 6922 | if (!status) |
bf269551 | 6923 | status = decode_pathconf(xdr, res->pathconf); |
1da177e4 LT |
6924 | return status; |
6925 | } | |
6926 | ||
6927 | /* | |
8b173218 | 6928 | * Decode STATFS response |
1da177e4 | 6929 | */ |
bf269551 | 6930 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
fc016483 | 6931 | void *data) |
1da177e4 | 6932 | { |
fc016483 | 6933 | struct nfs4_statfs_res *res = data; |
1da177e4 LT |
6934 | struct compound_hdr hdr; |
6935 | int status; | |
6936 | ||
bf269551 | 6937 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6938 | if (!status) |
bf269551 | 6939 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6940 | if (!status) |
bf269551 | 6941 | status = decode_putfh(xdr); |
1da177e4 | 6942 | if (!status) |
bf269551 | 6943 | status = decode_statfs(xdr, res->fsstat); |
1da177e4 LT |
6944 | return status; |
6945 | } | |
6946 | ||
6947 | /* | |
8b173218 | 6948 | * Decode GETATTR_BITMAP response |
1da177e4 | 6949 | */ |
bf269551 CL |
6950 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
6951 | struct xdr_stream *xdr, | |
fc016483 | 6952 | void *data) |
1da177e4 | 6953 | { |
fc016483 | 6954 | struct nfs4_server_caps_res *res = data; |
1da177e4 LT |
6955 | struct compound_hdr hdr; |
6956 | int status; | |
6957 | ||
bf269551 | 6958 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6959 | if (status) |
6960 | goto out; | |
bf269551 | 6961 | status = decode_sequence(xdr, &res->seq_res, req); |
9b7b9fcc | 6962 | if (status) |
1da177e4 | 6963 | goto out; |
bf269551 CL |
6964 | status = decode_putfh(xdr); |
6965 | if (status) | |
1da177e4 | 6966 | goto out; |
bf269551 | 6967 | status = decode_server_caps(xdr, res); |
1da177e4 LT |
6968 | out: |
6969 | return status; | |
6970 | } | |
6971 | ||
6972 | /* | |
6973 | * Decode RENEW response | |
6974 | */ | |
bf269551 CL |
6975 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6976 | void *__unused) | |
1da177e4 | 6977 | { |
1da177e4 LT |
6978 | struct compound_hdr hdr; |
6979 | int status; | |
6980 | ||
bf269551 | 6981 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 6982 | if (!status) |
bf269551 | 6983 | status = decode_renew(xdr); |
1da177e4 LT |
6984 | return status; |
6985 | } | |
6986 | ||
6987 | /* | |
8b173218 | 6988 | * Decode SETCLIENTID response |
1da177e4 | 6989 | */ |
bf269551 CL |
6990 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
6991 | struct xdr_stream *xdr, | |
fc016483 | 6992 | void *data) |
1da177e4 | 6993 | { |
fc016483 | 6994 | struct nfs4_setclientid_res *res = data; |
1da177e4 LT |
6995 | struct compound_hdr hdr; |
6996 | int status; | |
6997 | ||
bf269551 | 6998 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 6999 | if (!status) |
bf269551 | 7000 | status = decode_setclientid(xdr, res); |
1da177e4 LT |
7001 | return status; |
7002 | } | |
7003 | ||
7004 | /* | |
8b173218 | 7005 | * Decode SETCLIENTID_CONFIRM response |
1da177e4 | 7006 | */ |
bf269551 | 7007 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
fc016483 CH |
7008 | struct xdr_stream *xdr, |
7009 | void *data) | |
1da177e4 | 7010 | { |
1da177e4 LT |
7011 | struct compound_hdr hdr; |
7012 | int status; | |
7013 | ||
bf269551 | 7014 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 7015 | if (!status) |
bf269551 | 7016 | status = decode_setclientid_confirm(xdr); |
1da177e4 LT |
7017 | return status; |
7018 | } | |
7019 | ||
7020 | /* | |
8b173218 | 7021 | * Decode DELEGRETURN response |
1da177e4 | 7022 | */ |
bf269551 CL |
7023 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
7024 | struct xdr_stream *xdr, | |
fc016483 | 7025 | void *data) |
1da177e4 | 7026 | { |
fc016483 | 7027 | struct nfs4_delegreturnres *res = data; |
1da177e4 LT |
7028 | struct compound_hdr hdr; |
7029 | int status; | |
7030 | ||
bf269551 | 7031 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
7032 | if (status) |
7033 | goto out; | |
bf269551 | 7034 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 7035 | if (status) |
fa178f29 | 7036 | goto out; |
bf269551 | 7037 | status = decode_putfh(xdr); |
fa178f29 TM |
7038 | if (status != 0) |
7039 | goto out; | |
586f1c39 TM |
7040 | if (res->lr_res) { |
7041 | status = decode_layoutreturn(xdr, res->lr_res); | |
7042 | res->lr_ret = status; | |
7043 | if (status) | |
7044 | goto out; | |
7045 | } | |
8ac2b422 TM |
7046 | if (res->fattr) { |
7047 | status = decode_getfattr(xdr, res->fattr, res->server); | |
7048 | if (status != 0) | |
7049 | goto out; | |
7050 | } | |
e144cbcc | 7051 | status = decode_delegreturn(xdr); |
fa178f29 | 7052 | out: |
1da177e4 LT |
7053 | return status; |
7054 | } | |
7055 | ||
683b57b4 | 7056 | /* |
8b173218 | 7057 | * Decode FS_LOCATIONS response |
683b57b4 | 7058 | */ |
bf269551 CL |
7059 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
7060 | struct xdr_stream *xdr, | |
fc016483 | 7061 | void *data) |
683b57b4 | 7062 | { |
fc016483 | 7063 | struct nfs4_fs_locations_res *res = data; |
683b57b4 TM |
7064 | struct compound_hdr hdr; |
7065 | int status; | |
7066 | ||
bf269551 | 7067 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
7068 | if (status) |
7069 | goto out; | |
bf269551 | 7070 | status = decode_sequence(xdr, &res->seq_res, req); |
9b7b9fcc | 7071 | if (status) |
683b57b4 | 7072 | goto out; |
bf269551 CL |
7073 | status = decode_putfh(xdr); |
7074 | if (status) | |
683b57b4 | 7075 | goto out; |
b03d735b CL |
7076 | if (res->migration) { |
7077 | xdr_enter_page(xdr, PAGE_SIZE); | |
7078 | status = decode_getfattr_generic(xdr, | |
c3ed2227 | 7079 | res->fs_locations->fattr, |
8b7e3f49 | 7080 | NULL, res->fs_locations, |
1e2f67da | 7081 | res->fs_locations->server); |
b03d735b CL |
7082 | if (status) |
7083 | goto out; | |
7084 | if (res->renew) | |
7085 | status = decode_renew(xdr); | |
7086 | } else { | |
7087 | status = decode_lookup(xdr); | |
7088 | if (status) | |
7089 | goto out; | |
7090 | xdr_enter_page(xdr, PAGE_SIZE); | |
7091 | status = decode_getfattr_generic(xdr, | |
c3ed2227 | 7092 | res->fs_locations->fattr, |
b03d735b | 7093 | NULL, res->fs_locations, |
1e2f67da | 7094 | res->fs_locations->server); |
b03d735b | 7095 | } |
683b57b4 TM |
7096 | out: |
7097 | return status; | |
7098 | } | |
7099 | ||
5a5ea0d4 BS |
7100 | /* |
7101 | * Decode SECINFO response | |
7102 | */ | |
7103 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, | |
7104 | struct xdr_stream *xdr, | |
fc016483 | 7105 | void *data) |
5a5ea0d4 | 7106 | { |
fc016483 | 7107 | struct nfs4_secinfo_res *res = data; |
5a5ea0d4 BS |
7108 | struct compound_hdr hdr; |
7109 | int status; | |
7110 | ||
7111 | status = decode_compound_hdr(xdr, &hdr); | |
7112 | if (status) | |
7113 | goto out; | |
7114 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7115 | if (status) | |
7116 | goto out; | |
7117 | status = decode_putfh(xdr); | |
7118 | if (status) | |
7119 | goto out; | |
7120 | status = decode_secinfo(xdr, res); | |
5a5ea0d4 BS |
7121 | out: |
7122 | return status; | |
7123 | } | |
7124 | ||
44c99933 CL |
7125 | /* |
7126 | * Decode FSID_PRESENT response | |
7127 | */ | |
7128 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, | |
7129 | struct xdr_stream *xdr, | |
fc016483 | 7130 | void *data) |
44c99933 | 7131 | { |
fc016483 | 7132 | struct nfs4_fsid_present_res *res = data; |
44c99933 CL |
7133 | struct compound_hdr hdr; |
7134 | int status; | |
7135 | ||
7136 | status = decode_compound_hdr(xdr, &hdr); | |
7137 | if (status) | |
7138 | goto out; | |
7139 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7140 | if (status) | |
7141 | goto out; | |
7142 | status = decode_putfh(xdr); | |
7143 | if (status) | |
7144 | goto out; | |
7145 | status = decode_getfh(xdr, res->fh); | |
7146 | if (status) | |
7147 | goto out; | |
7148 | if (res->renew) | |
7149 | status = decode_renew(xdr); | |
7150 | out: | |
7151 | return status; | |
7152 | } | |
7153 | ||
99fe60d0 | 7154 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
7155 | /* |
7156 | * Decode BIND_CONN_TO_SESSION response | |
7157 | */ | |
7158 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, | |
7159 | struct xdr_stream *xdr, | |
7160 | void *res) | |
7161 | { | |
7162 | struct compound_hdr hdr; | |
7163 | int status; | |
7164 | ||
7165 | status = decode_compound_hdr(xdr, &hdr); | |
7166 | if (!status) | |
7167 | status = decode_bind_conn_to_session(xdr, res); | |
7168 | return status; | |
7169 | } | |
7170 | ||
99fe60d0 | 7171 | /* |
8b173218 | 7172 | * Decode EXCHANGE_ID response |
99fe60d0 | 7173 | */ |
bf269551 CL |
7174 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
7175 | struct xdr_stream *xdr, | |
99fe60d0 BH |
7176 | void *res) |
7177 | { | |
99fe60d0 BH |
7178 | struct compound_hdr hdr; |
7179 | int status; | |
7180 | ||
bf269551 | 7181 | status = decode_compound_hdr(xdr, &hdr); |
99fe60d0 | 7182 | if (!status) |
bf269551 | 7183 | status = decode_exchange_id(xdr, res); |
99fe60d0 BH |
7184 | return status; |
7185 | } | |
2050f0cc | 7186 | |
fc931582 | 7187 | /* |
8b173218 | 7188 | * Decode CREATE_SESSION response |
fc931582 | 7189 | */ |
bf269551 CL |
7190 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
7191 | struct xdr_stream *xdr, | |
fc016483 | 7192 | void *res) |
fc931582 | 7193 | { |
fc931582 AA |
7194 | struct compound_hdr hdr; |
7195 | int status; | |
7196 | ||
bf269551 | 7197 | status = decode_compound_hdr(xdr, &hdr); |
fc931582 | 7198 | if (!status) |
bf269551 | 7199 | status = decode_create_session(xdr, res); |
fc931582 AA |
7200 | return status; |
7201 | } | |
7202 | ||
0f3e66c6 | 7203 | /* |
8b173218 | 7204 | * Decode DESTROY_SESSION response |
0f3e66c6 | 7205 | */ |
bf269551 CL |
7206 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
7207 | struct xdr_stream *xdr, | |
7208 | void *res) | |
0f3e66c6 | 7209 | { |
0f3e66c6 AA |
7210 | struct compound_hdr hdr; |
7211 | int status; | |
7212 | ||
bf269551 | 7213 | status = decode_compound_hdr(xdr, &hdr); |
0f3e66c6 | 7214 | if (!status) |
bf269551 | 7215 | status = decode_destroy_session(xdr, res); |
0f3e66c6 AA |
7216 | return status; |
7217 | } | |
7218 | ||
66245539 TM |
7219 | /* |
7220 | * Decode DESTROY_CLIENTID response | |
7221 | */ | |
7222 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, | |
7223 | struct xdr_stream *xdr, | |
7224 | void *res) | |
7225 | { | |
7226 | struct compound_hdr hdr; | |
7227 | int status; | |
7228 | ||
7229 | status = decode_compound_hdr(xdr, &hdr); | |
7230 | if (!status) | |
7231 | status = decode_destroy_clientid(xdr, res); | |
7232 | return status; | |
7233 | } | |
7234 | ||
fc01cea9 | 7235 | /* |
8b173218 | 7236 | * Decode SEQUENCE response |
fc01cea9 | 7237 | */ |
bf269551 CL |
7238 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
7239 | struct xdr_stream *xdr, | |
fc016483 | 7240 | void *res) |
fc01cea9 | 7241 | { |
fc01cea9 AA |
7242 | struct compound_hdr hdr; |
7243 | int status; | |
7244 | ||
bf269551 | 7245 | status = decode_compound_hdr(xdr, &hdr); |
fc01cea9 | 7246 | if (!status) |
bf269551 | 7247 | status = decode_sequence(xdr, res, rqstp); |
fc01cea9 AA |
7248 | return status; |
7249 | } | |
7250 | ||
0efb01b2 DB |
7251 | #endif |
7252 | ||
2050f0cc | 7253 | /* |
8b173218 | 7254 | * Decode GET_LEASE_TIME response |
2050f0cc | 7255 | */ |
bf269551 CL |
7256 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
7257 | struct xdr_stream *xdr, | |
fc016483 | 7258 | void *data) |
2050f0cc | 7259 | { |
fc016483 | 7260 | struct nfs4_get_lease_time_res *res = data; |
2050f0cc AA |
7261 | struct compound_hdr hdr; |
7262 | int status; | |
7263 | ||
bf269551 | 7264 | status = decode_compound_hdr(xdr, &hdr); |
2050f0cc | 7265 | if (!status) |
bf269551 | 7266 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
2050f0cc | 7267 | if (!status) |
bf269551 | 7268 | status = decode_putrootfh(xdr); |
2050f0cc | 7269 | if (!status) |
bf269551 | 7270 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
2050f0cc AA |
7271 | return status; |
7272 | } | |
18019753 | 7273 | |
0efb01b2 DB |
7274 | #ifdef CONFIG_NFS_V4_1 |
7275 | ||
18019753 RL |
7276 | /* |
7277 | * Decode RECLAIM_COMPLETE response | |
7278 | */ | |
bf269551 CL |
7279 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
7280 | struct xdr_stream *xdr, | |
fc016483 | 7281 | void *data) |
18019753 | 7282 | { |
fc016483 | 7283 | struct nfs41_reclaim_complete_res *res = data; |
18019753 RL |
7284 | struct compound_hdr hdr; |
7285 | int status; | |
7286 | ||
bf269551 | 7287 | status = decode_compound_hdr(xdr, &hdr); |
18019753 | 7288 | if (!status) |
bf269551 | 7289 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
18019753 | 7290 | if (!status) |
8ee2b78a | 7291 | status = decode_reclaim_complete(xdr, NULL); |
18019753 RL |
7292 | return status; |
7293 | } | |
b1f69b75 AA |
7294 | |
7295 | /* | |
7296 | * Decode GETDEVINFO response | |
7297 | */ | |
bf269551 CL |
7298 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
7299 | struct xdr_stream *xdr, | |
fc016483 | 7300 | void *data) |
b1f69b75 | 7301 | { |
fc016483 | 7302 | struct nfs4_getdeviceinfo_res *res = data; |
b1f69b75 AA |
7303 | struct compound_hdr hdr; |
7304 | int status; | |
7305 | ||
bf269551 | 7306 | status = decode_compound_hdr(xdr, &hdr); |
b1f69b75 AA |
7307 | if (status != 0) |
7308 | goto out; | |
bf269551 | 7309 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
b1f69b75 AA |
7310 | if (status != 0) |
7311 | goto out; | |
4e590803 | 7312 | status = decode_getdeviceinfo(xdr, res); |
b1f69b75 AA |
7313 | out: |
7314 | return status; | |
7315 | } | |
7316 | ||
7317 | /* | |
7318 | * Decode LAYOUTGET response | |
7319 | */ | |
bf269551 CL |
7320 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
7321 | struct xdr_stream *xdr, | |
fc016483 | 7322 | void *data) |
b1f69b75 | 7323 | { |
fc016483 | 7324 | struct nfs4_layoutget_res *res = data; |
b1f69b75 AA |
7325 | struct compound_hdr hdr; |
7326 | int status; | |
7327 | ||
bf269551 | 7328 | status = decode_compound_hdr(xdr, &hdr); |
b1f69b75 AA |
7329 | if (status) |
7330 | goto out; | |
bf269551 | 7331 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
b1f69b75 AA |
7332 | if (status) |
7333 | goto out; | |
bf269551 | 7334 | status = decode_putfh(xdr); |
b1f69b75 AA |
7335 | if (status) |
7336 | goto out; | |
bf269551 | 7337 | status = decode_layoutget(xdr, rqstp, res); |
b1f69b75 AA |
7338 | out: |
7339 | return status; | |
7340 | } | |
863a3c6c | 7341 | |
cbe82603 BH |
7342 | /* |
7343 | * Decode LAYOUTRETURN response | |
7344 | */ | |
7345 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, | |
7346 | struct xdr_stream *xdr, | |
fc016483 | 7347 | void *data) |
cbe82603 | 7348 | { |
fc016483 | 7349 | struct nfs4_layoutreturn_res *res = data; |
cbe82603 BH |
7350 | struct compound_hdr hdr; |
7351 | int status; | |
7352 | ||
7353 | status = decode_compound_hdr(xdr, &hdr); | |
7354 | if (status) | |
7355 | goto out; | |
7356 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7357 | if (status) | |
7358 | goto out; | |
7359 | status = decode_putfh(xdr); | |
7360 | if (status) | |
7361 | goto out; | |
7362 | status = decode_layoutreturn(xdr, res); | |
7363 | out: | |
7364 | return status; | |
7365 | } | |
7366 | ||
863a3c6c AA |
7367 | /* |
7368 | * Decode LAYOUTCOMMIT response | |
7369 | */ | |
7370 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, | |
7371 | struct xdr_stream *xdr, | |
fc016483 | 7372 | void *data) |
863a3c6c | 7373 | { |
fc016483 | 7374 | struct nfs4_layoutcommit_res *res = data; |
863a3c6c AA |
7375 | struct compound_hdr hdr; |
7376 | int status; | |
7377 | ||
7378 | status = decode_compound_hdr(xdr, &hdr); | |
7379 | if (status) | |
7380 | goto out; | |
7381 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7382 | if (status) | |
7383 | goto out; | |
7384 | status = decode_putfh(xdr); | |
7385 | if (status) | |
7386 | goto out; | |
7387 | status = decode_layoutcommit(xdr, rqstp, res); | |
7388 | if (status) | |
7389 | goto out; | |
6926afd1 | 7390 | decode_getfattr(xdr, res->fattr, res->server); |
863a3c6c AA |
7391 | out: |
7392 | return status; | |
7393 | } | |
fca78d6d BS |
7394 | |
7395 | /* | |
7396 | * Decode SECINFO_NO_NAME response | |
7397 | */ | |
7398 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, | |
7399 | struct xdr_stream *xdr, | |
fc016483 | 7400 | void *data) |
fca78d6d | 7401 | { |
fc016483 | 7402 | struct nfs4_secinfo_res *res = data; |
fca78d6d BS |
7403 | struct compound_hdr hdr; |
7404 | int status; | |
7405 | ||
7406 | status = decode_compound_hdr(xdr, &hdr); | |
7407 | if (status) | |
7408 | goto out; | |
7409 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7410 | if (status) | |
7411 | goto out; | |
7412 | status = decode_putrootfh(xdr); | |
7413 | if (status) | |
7414 | goto out; | |
31e4dda4 | 7415 | status = decode_secinfo_no_name(xdr, res); |
fca78d6d BS |
7416 | out: |
7417 | return status; | |
7418 | } | |
7d974794 BS |
7419 | |
7420 | /* | |
7421 | * Decode TEST_STATEID response | |
7422 | */ | |
7423 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, | |
7424 | struct xdr_stream *xdr, | |
fc016483 | 7425 | void *data) |
7d974794 | 7426 | { |
fc016483 | 7427 | struct nfs41_test_stateid_res *res = data; |
7d974794 BS |
7428 | struct compound_hdr hdr; |
7429 | int status; | |
7430 | ||
7431 | status = decode_compound_hdr(xdr, &hdr); | |
7432 | if (status) | |
7433 | goto out; | |
7434 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7435 | if (status) | |
7436 | goto out; | |
7437 | status = decode_test_stateid(xdr, res); | |
7438 | out: | |
7439 | return status; | |
7440 | } | |
9aeda35f BS |
7441 | |
7442 | /* | |
7443 | * Decode FREE_STATEID response | |
7444 | */ | |
7445 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, | |
7446 | struct xdr_stream *xdr, | |
fc016483 | 7447 | void *data) |
9aeda35f | 7448 | { |
fc016483 | 7449 | struct nfs41_free_stateid_res *res = data; |
9aeda35f BS |
7450 | struct compound_hdr hdr; |
7451 | int status; | |
7452 | ||
7453 | status = decode_compound_hdr(xdr, &hdr); | |
7454 | if (status) | |
7455 | goto out; | |
7456 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7457 | if (status) | |
7458 | goto out; | |
7459 | status = decode_free_stateid(xdr, res); | |
7460 | out: | |
7461 | return status; | |
7462 | } | |
99fe60d0 BH |
7463 | #endif /* CONFIG_NFS_V4_1 */ |
7464 | ||
573c4e1e CL |
7465 | /** |
7466 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in | |
7467 | * the local page cache. | |
7468 | * @xdr: XDR stream where entry resides | |
7469 | * @entry: buffer to fill in with entry data | |
7470 | * @plus: boolean indicating whether this should be a readdirplus entry | |
7471 | * | |
7472 | * Returns zero if successful, otherwise a negative errno value is | |
7473 | * returned. | |
7474 | * | |
7475 | * This function is not invoked during READDIR reply decoding, but | |
7476 | * rather whenever an application invokes the getdents(2) system call | |
7477 | * on a directory already in our cache. | |
7478 | */ | |
7479 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | |
a7a3b1e9 | 7480 | bool plus) |
1da177e4 | 7481 | { |
256e48bb | 7482 | unsigned int savep; |
dae100c2 | 7483 | uint32_t bitmap[3] = {0}; |
1da177e4 | 7484 | uint32_t len; |
98de9ce6 | 7485 | uint64_t new_cookie; |
babddc72 BS |
7486 | __be32 *p = xdr_inline_decode(xdr, 4); |
7487 | if (unlikely(!p)) | |
eb72f484 | 7488 | return -EAGAIN; |
c08e76d0 | 7489 | if (*p == xdr_zero) { |
babddc72 BS |
7490 | p = xdr_inline_decode(xdr, 4); |
7491 | if (unlikely(!p)) | |
eb72f484 | 7492 | return -EAGAIN; |
c08e76d0 | 7493 | if (*p == xdr_zero) |
573c4e1e | 7494 | return -EAGAIN; |
1da177e4 | 7495 | entry->eof = 1; |
573c4e1e | 7496 | return -EBADCOOKIE; |
1da177e4 LT |
7497 | } |
7498 | ||
babddc72 BS |
7499 | p = xdr_inline_decode(xdr, 12); |
7500 | if (unlikely(!p)) | |
eb72f484 | 7501 | return -EAGAIN; |
98de9ce6 | 7502 | p = xdr_decode_hyper(p, &new_cookie); |
c08e76d0 | 7503 | entry->len = be32_to_cpup(p); |
babddc72 | 7504 | |
9af8c222 | 7505 | p = xdr_inline_decode(xdr, entry->len); |
babddc72 | 7506 | if (unlikely(!p)) |
eb72f484 | 7507 | return -EAGAIN; |
1da177e4 | 7508 | entry->name = (const char *) p; |
1da177e4 LT |
7509 | |
7510 | /* | |
7511 | * In case the server doesn't return an inode number, | |
7512 | * we fake one here. (We don't use inode number 0, | |
7513 | * since glibc seems to choke on it...) | |
7514 | */ | |
7515 | entry->ino = 1; | |
4f082222 | 7516 | entry->fattr->valid = 0; |
1da177e4 | 7517 | |
9af8c222 | 7518 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
eb72f484 | 7519 | return -EAGAIN; |
9af8c222 | 7520 | |
256e48bb | 7521 | if (decode_attr_length(xdr, &len, &savep) < 0) |
eb72f484 | 7522 | return -EAGAIN; |
9af8c222 | 7523 | |
573c4e1e | 7524 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
1e2f67da | 7525 | NULL, entry->server) < 0) |
eb72f484 | 7526 | return -EAGAIN; |
28331a46 TM |
7527 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
7528 | entry->ino = entry->fattr->mounted_on_fileid; | |
7529 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) | |
9af8c222 TM |
7530 | entry->ino = entry->fattr->fileid; |
7531 | ||
0b26a0bf TM |
7532 | entry->d_type = DT_UNKNOWN; |
7533 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) | |
7534 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); | |
7535 | ||
98de9ce6 FS |
7536 | entry->cookie = new_cookie; |
7537 | ||
573c4e1e | 7538 | return 0; |
1da177e4 LT |
7539 | } |
7540 | ||
7541 | /* | |
7542 | * We need to translate between nfs status return values and | |
7543 | * the local errno values which may not be the same. | |
7544 | */ | |
7545 | static struct { | |
7546 | int stat; | |
7547 | int errno; | |
7548 | } nfs_errtbl[] = { | |
7549 | { NFS4_OK, 0 }, | |
856dff3d BH |
7550 | { NFS4ERR_PERM, -EPERM }, |
7551 | { NFS4ERR_NOENT, -ENOENT }, | |
7552 | { NFS4ERR_IO, -errno_NFSERR_IO}, | |
7553 | { NFS4ERR_NXIO, -ENXIO }, | |
7554 | { NFS4ERR_ACCESS, -EACCES }, | |
7555 | { NFS4ERR_EXIST, -EEXIST }, | |
7556 | { NFS4ERR_XDEV, -EXDEV }, | |
7557 | { NFS4ERR_NOTDIR, -ENOTDIR }, | |
7558 | { NFS4ERR_ISDIR, -EISDIR }, | |
7559 | { NFS4ERR_INVAL, -EINVAL }, | |
7560 | { NFS4ERR_FBIG, -EFBIG }, | |
7561 | { NFS4ERR_NOSPC, -ENOSPC }, | |
7562 | { NFS4ERR_ROFS, -EROFS }, | |
7563 | { NFS4ERR_MLINK, -EMLINK }, | |
7564 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, | |
7565 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, | |
7566 | { NFS4ERR_DQUOT, -EDQUOT }, | |
7567 | { NFS4ERR_STALE, -ESTALE }, | |
7568 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, | |
856dff3d BH |
7569 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
7570 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, | |
7571 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, | |
fdcb4577 | 7572 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
856dff3d BH |
7573 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
7574 | { NFS4ERR_LOCKED, -EAGAIN }, | |
856dff3d BH |
7575 | { NFS4ERR_SYMLINK, -ELOOP }, |
7576 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, | |
7577 | { NFS4ERR_DEADLOCK, -EDEADLK }, | |
3e1f0212 FL |
7578 | { NFS4ERR_NOXATTR, -ENODATA }, |
7579 | { NFS4ERR_XATTR2BIG, -E2BIG }, | |
856dff3d | 7580 | { -1, -EIO } |
1da177e4 LT |
7581 | }; |
7582 | ||
7583 | /* | |
7584 | * Convert an NFS error code to a local one. | |
7585 | * This one is used jointly by NFSv2 and NFSv3. | |
7586 | */ | |
7587 | static int | |
0a8ea437 | 7588 | nfs4_stat_to_errno(int stat) |
1da177e4 LT |
7589 | { |
7590 | int i; | |
7591 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { | |
7592 | if (nfs_errtbl[i].stat == stat) | |
7593 | return nfs_errtbl[i].errno; | |
7594 | } | |
7595 | if (stat <= 10000 || stat > 10100) { | |
7596 | /* The server is looney tunes. */ | |
fdcb4577 | 7597 | return -EREMOTEIO; |
1da177e4 LT |
7598 | } |
7599 | /* If we cannot translate the error, the recovery routines should | |
7600 | * handle it. | |
7601 | * Note: remaining NFSv4 error codes have values > 10000, so should | |
7602 | * not conflict with native Linux error codes. | |
7603 | */ | |
856dff3d | 7604 | return -stat; |
1da177e4 LT |
7605 | } |
7606 | ||
1c6dcbe5 AS |
7607 | #ifdef CONFIG_NFS_V4_2 |
7608 | #include "nfs42xdr.c" | |
7609 | #endif /* CONFIG_NFS_V4_2 */ | |
7610 | ||
1da177e4 LT |
7611 | #define PROC(proc, argtype, restype) \ |
7612 | [NFSPROC4_CLNT_##proc] = { \ | |
7613 | .p_proc = NFSPROC4_COMPOUND, \ | |
fcc85819 | 7614 | .p_encode = nfs4_xdr_##argtype, \ |
fc016483 | 7615 | .p_decode = nfs4_xdr_##restype, \ |
2bea90d4 CL |
7616 | .p_arglen = NFS4_##argtype##_sz, \ |
7617 | .p_replen = NFS4_##restype##_sz, \ | |
cc0175c1 CL |
7618 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
7619 | .p_name = #proc, \ | |
05d564fe | 7620 | } |
1da177e4 | 7621 | |
7c61f0d3 AS |
7622 | #define STUB(proc) \ |
7623 | [NFSPROC4_CLNT_##proc] = { \ | |
7624 | .p_name = #proc, \ | |
7625 | } | |
7626 | ||
8634ef5e TM |
7627 | #if defined(CONFIG_NFS_V4_1) |
7628 | #define PROC41(proc, argtype, restype) \ | |
7629 | PROC(proc, argtype, restype) | |
7630 | #else | |
7631 | #define PROC41(proc, argtype, restype) \ | |
7632 | STUB(proc) | |
7633 | #endif | |
7634 | ||
7635 | #if defined(CONFIG_NFS_V4_2) | |
7636 | #define PROC42(proc, argtype, restype) \ | |
7637 | PROC(proc, argtype, restype) | |
7638 | #else | |
7639 | #define PROC42(proc, argtype, restype) \ | |
7640 | STUB(proc) | |
7641 | #endif | |
7642 | ||
511e936b | 7643 | const struct rpc_procinfo nfs4_procedures[] = { |
7d93bd71 CL |
7644 | PROC(READ, enc_read, dec_read), |
7645 | PROC(WRITE, enc_write, dec_write), | |
7646 | PROC(COMMIT, enc_commit, dec_commit), | |
7647 | PROC(OPEN, enc_open, dec_open), | |
7648 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), | |
7649 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), | |
7650 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), | |
7651 | PROC(CLOSE, enc_close, dec_close), | |
7652 | PROC(SETATTR, enc_setattr, dec_setattr), | |
7653 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), | |
7654 | PROC(RENEW, enc_renew, dec_renew), | |
7655 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), | |
7656 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), | |
7657 | PROC(LOCK, enc_lock, dec_lock), | |
7658 | PROC(LOCKT, enc_lockt, dec_lockt), | |
7659 | PROC(LOCKU, enc_locku, dec_locku), | |
7660 | PROC(ACCESS, enc_access, dec_access), | |
7661 | PROC(GETATTR, enc_getattr, dec_getattr), | |
7662 | PROC(LOOKUP, enc_lookup, dec_lookup), | |
7663 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), | |
7664 | PROC(REMOVE, enc_remove, dec_remove), | |
7665 | PROC(RENAME, enc_rename, dec_rename), | |
7666 | PROC(LINK, enc_link, dec_link), | |
7667 | PROC(SYMLINK, enc_symlink, dec_symlink), | |
7668 | PROC(CREATE, enc_create, dec_create), | |
7669 | PROC(PATHCONF, enc_pathconf, dec_pathconf), | |
7670 | PROC(STATFS, enc_statfs, dec_statfs), | |
7671 | PROC(READLINK, enc_readlink, dec_readlink), | |
7672 | PROC(READDIR, enc_readdir, dec_readdir), | |
7673 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), | |
7674 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), | |
7675 | PROC(GETACL, enc_getacl, dec_getacl), | |
7676 | PROC(SETACL, enc_setacl, dec_setacl), | |
7677 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), | |
7678 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), | |
5a5ea0d4 | 7679 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
44c99933 | 7680 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
8634ef5e TM |
7681 | PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
7682 | PROC41(CREATE_SESSION, enc_create_session, dec_create_session), | |
7683 | PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | |
7684 | PROC41(SEQUENCE, enc_sequence, dec_sequence), | |
0efb01b2 | 7685 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
8634ef5e TM |
7686 | PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete), |
7687 | PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), | |
7688 | PROC41(LAYOUTGET, enc_layoutget, dec_layoutget), | |
7689 | PROC41(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), | |
7690 | PROC41(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), | |
7691 | PROC41(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), | |
7692 | PROC41(TEST_STATEID, enc_test_stateid, dec_test_stateid), | |
7693 | PROC41(FREE_STATEID, enc_free_stateid, dec_free_stateid), | |
7c61f0d3 | 7694 | STUB(GETDEVICELIST), |
8634ef5e | 7695 | PROC41(BIND_CONN_TO_SESSION, |
ad24ecfb | 7696 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
8634ef5e TM |
7697 | PROC41(DESTROY_CLIENTID,enc_destroy_clientid, dec_destroy_clientid), |
7698 | PROC42(SEEK, enc_seek, dec_seek), | |
7699 | PROC42(ALLOCATE, enc_allocate, dec_allocate), | |
7700 | PROC42(DEALLOCATE, enc_deallocate, dec_deallocate), | |
7701 | PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats), | |
7702 | PROC42(CLONE, enc_clone, dec_clone), | |
7703 | PROC42(COPY, enc_copy, dec_copy), | |
cb95deea | 7704 | PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), |
0491567b | 7705 | PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), |
8634ef5e | 7706 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
3eb86093 | 7707 | PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), |
3e1f0212 FL |
7708 | PROC42(GETXATTR, enc_getxattr, dec_getxattr), |
7709 | PROC42(SETXATTR, enc_setxattr, dec_setxattr), | |
7710 | PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs), | |
7711 | PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr), | |
c5675526 | 7712 | PROC42(READ_PLUS, enc_read_plus, dec_read_plus), |
1da177e4 LT |
7713 | }; |
7714 | ||
c551858a | 7715 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
a613fa16 | 7716 | const struct rpc_version nfs_version4 = { |
1da177e4 | 7717 | .number = 4, |
e8c96f8c | 7718 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
c551858a CH |
7719 | .procs = nfs4_procedures, |
7720 | .counts = nfs_version4_counts, | |
1da177e4 | 7721 | }; |