4 * Client-side XDR for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
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.
38 #include <linux/param.h>
39 #include <linux/time.h>
41 #include <linux/errno.h>
42 #include <linux/string.h>
44 #include <linux/pagemap.h>
45 #include <linux/proc_fs.h>
46 #include <linux/kdev_t.h>
47 #include <linux/module.h>
48 #include <linux/utsname.h>
49 #include <linux/sunrpc/clnt.h>
50 #include <linux/sunrpc/msg_prot.h>
51 #include <linux/sunrpc/gss_api.h>
52 #include <linux/nfs.h>
53 #include <linux/nfs4.h>
54 #include <linux/nfs_fs.h>
58 #include "nfs4idmap.h"
59 #include "nfs4session.h"
63 #define NFSDBG_FACILITY NFSDBG_XDR
65 /* Mapping from NFS error code to "errno" error code. */
66 #define errno_NFSERR_IO EIO
68 static int nfs4_stat_to_errno(int);
70 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
72 #define NFS4_MAXTAGLEN 20
74 #define NFS4_MAXTAGLEN 0
77 /* lock,open owner id:
78 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
80 #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2)
81 #define lock_owner_id_maxsz (1 + 1 + 4)
82 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
83 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
84 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
85 #define op_encode_hdr_maxsz (1)
86 #define op_decode_hdr_maxsz (2)
87 #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
88 #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
89 #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
90 #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
91 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
93 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
94 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
95 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
96 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
97 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
98 ((3+NFS4_FHSIZE) >> 2))
99 #define nfs4_fattr_bitmap_maxsz 4
100 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
101 #define nfstime4_maxsz (3)
102 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
103 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
104 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
105 #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
106 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
107 /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */
108 #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN))
110 #define nfs4_label_maxsz 0
112 /* We support only one layout type per file system */
113 #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8)
114 /* This is based on getfattr, which uses the most attributes: */
115 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
118 nfs4_group_maxsz + nfs4_label_maxsz + \
119 decode_mdsthreshold_maxsz))
120 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
121 nfs4_fattr_value_maxsz)
122 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
123 #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
128 1 + nfstime4_maxsz + \
130 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
131 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
132 #define encode_restorefh_maxsz (op_encode_hdr_maxsz)
133 #define decode_restorefh_maxsz (op_decode_hdr_maxsz)
134 #define encode_fsinfo_maxsz (encode_getattr_maxsz)
135 /* The 5 accounts for the PNFS attributes, and assumes that at most three
136 * layout types will be returned.
138 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \
139 nfs4_fattr_bitmap_maxsz + 4 + 8 + 5)
140 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
141 #define decode_renew_maxsz (op_decode_hdr_maxsz)
142 #define encode_setclientid_maxsz \
143 (op_encode_hdr_maxsz + \
144 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
146 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
148 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
149 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
151 #define decode_setclientid_maxsz \
152 (op_decode_hdr_maxsz + \
154 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
155 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
156 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
157 #define encode_setclientid_confirm_maxsz \
158 (op_encode_hdr_maxsz + \
159 3 + (NFS4_VERIFIER_SIZE >> 2))
160 #define decode_setclientid_confirm_maxsz \
161 (op_decode_hdr_maxsz)
162 #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
163 #define decode_lookup_maxsz (op_decode_hdr_maxsz)
164 #define encode_lookupp_maxsz (op_encode_hdr_maxsz)
165 #define decode_lookupp_maxsz (op_decode_hdr_maxsz)
166 #define encode_share_access_maxsz \
168 #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
169 #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
170 #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
171 #define encode_open_maxsz (op_encode_hdr_maxsz + \
172 2 + encode_share_access_maxsz + 2 + \
173 open_owner_id_maxsz + \
174 encode_opentype_maxsz + \
175 encode_claim_null_maxsz)
176 #define decode_space_limit_maxsz (3)
177 #define decode_ace_maxsz (3 + nfs4_owner_maxsz)
178 #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
179 decode_space_limit_maxsz + \
181 #define decode_change_info_maxsz (5)
182 #define decode_open_maxsz (op_decode_hdr_maxsz + \
183 decode_stateid_maxsz + \
184 decode_change_info_maxsz + 1 + \
185 nfs4_fattr_bitmap_maxsz + \
186 decode_delegation_maxsz)
187 #define encode_open_confirm_maxsz \
188 (op_encode_hdr_maxsz + \
189 encode_stateid_maxsz + 1)
190 #define decode_open_confirm_maxsz \
191 (op_decode_hdr_maxsz + \
192 decode_stateid_maxsz)
193 #define encode_open_downgrade_maxsz \
194 (op_encode_hdr_maxsz + \
195 encode_stateid_maxsz + 1 + \
196 encode_share_access_maxsz)
197 #define decode_open_downgrade_maxsz \
198 (op_decode_hdr_maxsz + \
199 decode_stateid_maxsz)
200 #define encode_close_maxsz (op_encode_hdr_maxsz + \
201 1 + encode_stateid_maxsz)
202 #define decode_close_maxsz (op_decode_hdr_maxsz + \
203 decode_stateid_maxsz)
204 #define encode_setattr_maxsz (op_encode_hdr_maxsz + \
205 encode_stateid_maxsz + \
207 #define decode_setattr_maxsz (op_decode_hdr_maxsz + \
208 nfs4_fattr_bitmap_maxsz)
209 #define encode_read_maxsz (op_encode_hdr_maxsz + \
210 encode_stateid_maxsz + 3)
211 #define decode_read_maxsz (op_decode_hdr_maxsz + 2)
212 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
213 2 + encode_verifier_maxsz + 5 + \
215 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
216 decode_verifier_maxsz)
217 #define encode_readlink_maxsz (op_encode_hdr_maxsz)
218 #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1)
219 #define encode_write_maxsz (op_encode_hdr_maxsz + \
220 encode_stateid_maxsz + 4)
221 #define decode_write_maxsz (op_decode_hdr_maxsz + \
222 2 + decode_verifier_maxsz)
223 #define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
224 #define decode_commit_maxsz (op_decode_hdr_maxsz + \
225 decode_verifier_maxsz)
226 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
228 #define decode_remove_maxsz (op_decode_hdr_maxsz + \
229 decode_change_info_maxsz)
230 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
232 #define decode_rename_maxsz (op_decode_hdr_maxsz + \
233 decode_change_info_maxsz + \
234 decode_change_info_maxsz)
235 #define encode_link_maxsz (op_encode_hdr_maxsz + \
237 #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
238 #define encode_lockowner_maxsz (7)
239 #define encode_lock_maxsz (op_encode_hdr_maxsz + \
241 1 + encode_stateid_maxsz + 1 + \
242 encode_lockowner_maxsz)
243 #define decode_lock_denied_maxsz \
244 (8 + decode_lockowner_maxsz)
245 #define decode_lock_maxsz (op_decode_hdr_maxsz + \
246 decode_lock_denied_maxsz)
247 #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \
248 encode_lockowner_maxsz)
249 #define decode_lockt_maxsz (op_decode_hdr_maxsz + \
250 decode_lock_denied_maxsz)
251 #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
252 encode_stateid_maxsz + \
254 #define decode_locku_maxsz (op_decode_hdr_maxsz + \
255 decode_stateid_maxsz)
256 #define encode_release_lockowner_maxsz \
257 (op_encode_hdr_maxsz + \
258 encode_lockowner_maxsz)
259 #define decode_release_lockowner_maxsz \
260 (op_decode_hdr_maxsz)
261 #define encode_access_maxsz (op_encode_hdr_maxsz + 1)
262 #define decode_access_maxsz (op_decode_hdr_maxsz + 2)
263 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
264 1 + nfs4_name_maxsz + \
267 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
268 #define encode_create_maxsz (op_encode_hdr_maxsz + \
269 1 + 2 + nfs4_name_maxsz + \
271 #define decode_create_maxsz (op_decode_hdr_maxsz + \
272 decode_change_info_maxsz + \
273 nfs4_fattr_bitmap_maxsz)
274 #define encode_statfs_maxsz (encode_getattr_maxsz)
275 #define decode_statfs_maxsz (decode_getattr_maxsz)
276 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
277 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
278 #define encode_getacl_maxsz (encode_getattr_maxsz)
279 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
280 nfs4_fattr_bitmap_maxsz + 1)
281 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
282 encode_stateid_maxsz + 3)
283 #define decode_setacl_maxsz (decode_setattr_maxsz)
284 #define encode_fs_locations_maxsz \
285 (encode_getattr_maxsz)
286 #define decode_fs_locations_maxsz \
288 #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
289 #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
291 #if defined(CONFIG_NFS_V4_1)
292 #define NFS4_MAX_MACHINE_NAME_LEN (64)
293 #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \
294 sizeof(utsname()->version) + sizeof(utsname()->machine) + 8)
296 #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
297 encode_verifier_maxsz + \
298 1 /* co_ownerid.len */ + \
299 /* eia_clientowner */ \
300 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
303 /* max is SP4_MACH_CRED (for now) */ + \
304 1 + NFS4_OP_MAP_NUM_WORDS + \
305 1 + NFS4_OP_MAP_NUM_WORDS + \
306 1 /* implementation id array of size 1 */ + \
307 1 /* nii_domain */ + \
308 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
310 XDR_QUADLEN(IMPL_NAME_LIMIT) + \
312 #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
313 2 /* eir_clientid */ + \
314 1 /* eir_sequenceid */ + \
315 1 /* eir_flags */ + \
317 /* max is SP4_MACH_CRED (for now) */ + \
318 1 + NFS4_OP_MAP_NUM_WORDS + \
319 1 + NFS4_OP_MAP_NUM_WORDS + \
320 2 /* eir_server_owner.so_minor_id */ + \
321 /* eir_server_owner.so_major_id<> */ \
322 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
323 /* eir_server_scope<> */ \
324 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
325 1 /* eir_server_impl_id array length */ + \
326 1 /* nii_domain */ + \
327 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
329 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
331 #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */)
332 #define decode_channel_attrs_maxsz (6 + \
333 1 /* ca_rdma_ird.len */ + \
335 #define encode_create_session_maxsz (op_encode_hdr_maxsz + \
336 2 /* csa_clientid */ + \
337 1 /* csa_sequence */ + \
338 1 /* csa_flags */ + \
339 encode_channel_attrs_maxsz + \
340 encode_channel_attrs_maxsz + \
341 1 /* csa_cb_program */ + \
342 1 /* csa_sec_parms.len (1) */ + \
343 1 /* cb_secflavor (AUTH_SYS) */ + \
345 1 /* machinename.len */ + \
346 XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \
349 1 /* gids.len (0) */)
350 #define decode_create_session_maxsz (op_decode_hdr_maxsz + \
351 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
352 1 /* csr_sequence */ + \
353 1 /* csr_flags */ + \
354 decode_channel_attrs_maxsz + \
355 decode_channel_attrs_maxsz)
356 #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \
358 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
359 1 /* bctsa_dir */ + \
360 1 /* bctsa_use_conn_in_rdma_mode */)
361 #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \
363 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
364 1 /* bctsr_dir */ + \
365 1 /* bctsr_use_conn_in_rdma_mode */)
366 #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)
367 #define decode_destroy_session_maxsz (op_decode_hdr_maxsz)
368 #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2)
369 #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz)
370 #define encode_sequence_maxsz (op_encode_hdr_maxsz + \
371 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
372 #define decode_sequence_maxsz (op_decode_hdr_maxsz + \
373 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
374 #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
375 #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
376 #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \
377 XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
378 1 /* layout type */ + \
380 1 /* bitmap size */ + \
381 1 /* notification bitmap length */ + \
382 1 /* notification bitmap, word 0 */)
383 #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \
384 1 /* layout type */ + \
385 1 /* opaque devaddr4 length */ + \
386 /* devaddr4 payload is read into page */ \
387 1 /* notification bitmap length */ + \
388 1 /* notification bitmap, word 0 */)
389 #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \
390 encode_stateid_maxsz)
391 #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \
392 decode_stateid_maxsz + \
393 XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE))
394 #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \
398 encode_stateid_maxsz + \
399 1 /* new offset (true) */ + \
400 2 /* last byte written */ + \
401 1 /* nt_timechanged (false) */ + \
402 1 /* layoutupdate4 layout type */ + \
403 1 /* layoutupdate4 opaqueue len */)
404 /* the actual content of layoutupdate4 should
405 be allocated by drivers and spliced in
406 using xdr_write_pages */
407 #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3)
408 #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \
409 encode_stateid_maxsz + \
411 XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
412 #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \
413 1 + decode_stateid_maxsz)
414 #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1)
415 #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz
416 #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \
417 XDR_QUADLEN(NFS4_STATEID_SIZE))
418 #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1)
419 #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \
420 XDR_QUADLEN(NFS4_STATEID_SIZE))
421 #define decode_free_stateid_maxsz (op_decode_hdr_maxsz)
422 #else /* CONFIG_NFS_V4_1 */
423 #define encode_sequence_maxsz 0
424 #define decode_sequence_maxsz 0
425 #define encode_layoutreturn_maxsz 0
426 #define decode_layoutreturn_maxsz 0
427 #endif /* CONFIG_NFS_V4_1 */
429 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
430 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
431 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
432 encode_sequence_maxsz + \
433 encode_putfh_maxsz + \
435 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
436 decode_sequence_maxsz + \
437 decode_putfh_maxsz + \
439 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
440 encode_sequence_maxsz + \
441 encode_putfh_maxsz + \
442 encode_readlink_maxsz)
443 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
444 decode_sequence_maxsz + \
445 decode_putfh_maxsz + \
446 decode_readlink_maxsz)
447 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
448 encode_sequence_maxsz + \
449 encode_putfh_maxsz + \
450 encode_readdir_maxsz)
451 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
452 decode_sequence_maxsz + \
453 decode_putfh_maxsz + \
454 decode_readdir_maxsz)
455 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
456 encode_sequence_maxsz + \
457 encode_putfh_maxsz + \
458 encode_write_maxsz + \
459 encode_getattr_maxsz)
460 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
461 decode_sequence_maxsz + \
462 decode_putfh_maxsz + \
463 decode_write_maxsz + \
464 decode_getattr_maxsz)
465 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
466 encode_sequence_maxsz + \
467 encode_putfh_maxsz + \
469 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
470 decode_sequence_maxsz + \
471 decode_putfh_maxsz + \
473 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
474 encode_sequence_maxsz + \
475 encode_putfh_maxsz + \
476 encode_open_maxsz + \
477 encode_access_maxsz + \
478 encode_getfh_maxsz + \
479 encode_getattr_maxsz)
480 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
481 decode_sequence_maxsz + \
482 decode_putfh_maxsz + \
483 decode_open_maxsz + \
484 decode_access_maxsz + \
485 decode_getfh_maxsz + \
486 decode_getattr_maxsz)
487 #define NFS4_enc_open_confirm_sz \
488 (compound_encode_hdr_maxsz + \
489 encode_putfh_maxsz + \
490 encode_open_confirm_maxsz)
491 #define NFS4_dec_open_confirm_sz \
492 (compound_decode_hdr_maxsz + \
493 decode_putfh_maxsz + \
494 decode_open_confirm_maxsz)
495 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
496 encode_sequence_maxsz + \
497 encode_putfh_maxsz + \
498 encode_open_maxsz + \
499 encode_access_maxsz + \
500 encode_getattr_maxsz)
501 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
502 decode_sequence_maxsz + \
503 decode_putfh_maxsz + \
504 decode_open_maxsz + \
505 decode_access_maxsz + \
506 decode_getattr_maxsz)
507 #define NFS4_enc_open_downgrade_sz \
508 (compound_encode_hdr_maxsz + \
509 encode_sequence_maxsz + \
510 encode_putfh_maxsz + \
511 encode_layoutreturn_maxsz + \
512 encode_open_downgrade_maxsz)
513 #define NFS4_dec_open_downgrade_sz \
514 (compound_decode_hdr_maxsz + \
515 decode_sequence_maxsz + \
516 decode_putfh_maxsz + \
517 decode_layoutreturn_maxsz + \
518 decode_open_downgrade_maxsz)
519 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
520 encode_sequence_maxsz + \
521 encode_putfh_maxsz + \
522 encode_layoutreturn_maxsz + \
523 encode_close_maxsz + \
524 encode_getattr_maxsz)
525 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
526 decode_sequence_maxsz + \
527 decode_putfh_maxsz + \
528 decode_layoutreturn_maxsz + \
529 decode_close_maxsz + \
530 decode_getattr_maxsz)
531 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
532 encode_sequence_maxsz + \
533 encode_putfh_maxsz + \
534 encode_setattr_maxsz + \
535 encode_getattr_maxsz)
536 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
537 decode_sequence_maxsz + \
538 decode_putfh_maxsz + \
539 decode_setattr_maxsz + \
540 decode_getattr_maxsz)
541 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
542 encode_sequence_maxsz + \
543 encode_putfh_maxsz + \
545 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
546 decode_sequence_maxsz + \
547 decode_putfh_maxsz + \
549 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
551 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
553 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
554 encode_setclientid_maxsz)
555 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
556 decode_setclientid_maxsz)
557 #define NFS4_enc_setclientid_confirm_sz \
558 (compound_encode_hdr_maxsz + \
559 encode_setclientid_confirm_maxsz)
560 #define NFS4_dec_setclientid_confirm_sz \
561 (compound_decode_hdr_maxsz + \
562 decode_setclientid_confirm_maxsz)
563 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
564 encode_sequence_maxsz + \
565 encode_putfh_maxsz + \
567 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
568 decode_sequence_maxsz + \
569 decode_putfh_maxsz + \
571 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
572 encode_sequence_maxsz + \
573 encode_putfh_maxsz + \
575 #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
576 decode_sequence_maxsz + \
577 decode_putfh_maxsz + \
579 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
580 encode_sequence_maxsz + \
581 encode_putfh_maxsz + \
583 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
584 decode_sequence_maxsz + \
585 decode_putfh_maxsz + \
587 #define NFS4_enc_release_lockowner_sz \
588 (compound_encode_hdr_maxsz + \
589 encode_lockowner_maxsz)
590 #define NFS4_dec_release_lockowner_sz \
591 (compound_decode_hdr_maxsz + \
592 decode_lockowner_maxsz)
593 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
594 encode_sequence_maxsz + \
595 encode_putfh_maxsz + \
596 encode_access_maxsz + \
597 encode_getattr_maxsz)
598 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
599 decode_sequence_maxsz + \
600 decode_putfh_maxsz + \
601 decode_access_maxsz + \
602 decode_getattr_maxsz)
603 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
604 encode_sequence_maxsz + \
605 encode_putfh_maxsz + \
606 encode_getattr_maxsz + \
608 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
609 decode_sequence_maxsz + \
610 decode_putfh_maxsz + \
611 decode_getattr_maxsz + \
613 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
614 encode_sequence_maxsz + \
615 encode_putfh_maxsz + \
616 encode_lookup_maxsz + \
617 encode_getattr_maxsz + \
619 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
620 decode_sequence_maxsz + \
621 decode_putfh_maxsz + \
622 decode_lookup_maxsz + \
623 decode_getattr_maxsz + \
625 #define NFS4_enc_lookupp_sz (compound_encode_hdr_maxsz + \
626 encode_sequence_maxsz + \
627 encode_putfh_maxsz + \
628 encode_lookupp_maxsz + \
629 encode_getattr_maxsz + \
631 #define NFS4_dec_lookupp_sz (compound_decode_hdr_maxsz + \
632 decode_sequence_maxsz + \
633 decode_putfh_maxsz + \
634 decode_lookupp_maxsz + \
635 decode_getattr_maxsz + \
637 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
638 encode_sequence_maxsz + \
639 encode_putrootfh_maxsz + \
640 encode_getattr_maxsz + \
642 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
643 decode_sequence_maxsz + \
644 decode_putrootfh_maxsz + \
645 decode_getattr_maxsz + \
647 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
648 encode_sequence_maxsz + \
649 encode_putfh_maxsz + \
651 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
652 decode_sequence_maxsz + \
653 decode_putfh_maxsz + \
655 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
656 encode_sequence_maxsz + \
657 encode_putfh_maxsz + \
658 encode_savefh_maxsz + \
659 encode_putfh_maxsz + \
661 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
662 decode_sequence_maxsz + \
663 decode_putfh_maxsz + \
664 decode_savefh_maxsz + \
665 decode_putfh_maxsz + \
667 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
668 encode_sequence_maxsz + \
669 encode_putfh_maxsz + \
670 encode_savefh_maxsz + \
671 encode_putfh_maxsz + \
672 encode_link_maxsz + \
673 encode_restorefh_maxsz + \
674 encode_getattr_maxsz)
675 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
676 decode_sequence_maxsz + \
677 decode_putfh_maxsz + \
678 decode_savefh_maxsz + \
679 decode_putfh_maxsz + \
680 decode_link_maxsz + \
681 decode_restorefh_maxsz + \
682 decode_getattr_maxsz)
683 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
684 encode_sequence_maxsz + \
685 encode_putfh_maxsz + \
686 encode_symlink_maxsz + \
687 encode_getattr_maxsz + \
689 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
690 decode_sequence_maxsz + \
691 decode_putfh_maxsz + \
692 decode_symlink_maxsz + \
693 decode_getattr_maxsz + \
695 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
696 encode_sequence_maxsz + \
697 encode_putfh_maxsz + \
698 encode_create_maxsz + \
699 encode_getfh_maxsz + \
700 encode_getattr_maxsz)
701 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
702 decode_sequence_maxsz + \
703 decode_putfh_maxsz + \
704 decode_create_maxsz + \
705 decode_getfh_maxsz + \
706 decode_getattr_maxsz)
707 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
708 encode_sequence_maxsz + \
709 encode_putfh_maxsz + \
710 encode_getattr_maxsz)
711 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
712 decode_sequence_maxsz + \
713 decode_putfh_maxsz + \
714 decode_getattr_maxsz)
715 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
716 encode_sequence_maxsz + \
717 encode_putfh_maxsz + \
719 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
720 decode_sequence_maxsz + \
721 decode_putfh_maxsz + \
723 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
724 encode_sequence_maxsz + \
725 encode_putfh_maxsz + \
726 encode_getattr_maxsz)
727 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
728 decode_sequence_maxsz + \
729 decode_putfh_maxsz + \
730 decode_getattr_maxsz)
731 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
732 encode_sequence_maxsz + \
733 encode_putfh_maxsz + \
734 encode_layoutreturn_maxsz + \
735 encode_delegreturn_maxsz + \
736 encode_getattr_maxsz)
737 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
738 decode_sequence_maxsz + \
739 decode_putfh_maxsz + \
740 decode_layoutreturn_maxsz + \
741 decode_delegreturn_maxsz + \
742 decode_getattr_maxsz)
743 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
744 encode_sequence_maxsz + \
745 encode_putfh_maxsz + \
747 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
748 decode_sequence_maxsz + \
749 decode_putfh_maxsz + \
751 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
752 encode_sequence_maxsz + \
753 encode_putfh_maxsz + \
755 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
756 decode_sequence_maxsz + \
757 decode_putfh_maxsz + \
759 #define NFS4_enc_fs_locations_sz \
760 (compound_encode_hdr_maxsz + \
761 encode_sequence_maxsz + \
762 encode_putfh_maxsz + \
763 encode_lookup_maxsz + \
764 encode_fs_locations_maxsz + \
766 #define NFS4_dec_fs_locations_sz \
767 (compound_decode_hdr_maxsz + \
768 decode_sequence_maxsz + \
769 decode_putfh_maxsz + \
770 decode_lookup_maxsz + \
771 decode_fs_locations_maxsz + \
773 #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \
774 encode_sequence_maxsz + \
775 encode_putfh_maxsz + \
776 encode_secinfo_maxsz)
777 #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \
778 decode_sequence_maxsz + \
779 decode_putfh_maxsz + \
780 decode_secinfo_maxsz)
781 #define NFS4_enc_fsid_present_sz \
782 (compound_encode_hdr_maxsz + \
783 encode_sequence_maxsz + \
784 encode_putfh_maxsz + \
785 encode_getfh_maxsz + \
787 #define NFS4_dec_fsid_present_sz \
788 (compound_decode_hdr_maxsz + \
789 decode_sequence_maxsz + \
790 decode_putfh_maxsz + \
791 decode_getfh_maxsz + \
793 #if defined(CONFIG_NFS_V4_1)
794 #define NFS4_enc_bind_conn_to_session_sz \
795 (compound_encode_hdr_maxsz + \
796 encode_bind_conn_to_session_maxsz)
797 #define NFS4_dec_bind_conn_to_session_sz \
798 (compound_decode_hdr_maxsz + \
799 decode_bind_conn_to_session_maxsz)
800 #define NFS4_enc_exchange_id_sz \
801 (compound_encode_hdr_maxsz + \
802 encode_exchange_id_maxsz)
803 #define NFS4_dec_exchange_id_sz \
804 (compound_decode_hdr_maxsz + \
805 decode_exchange_id_maxsz)
806 #define NFS4_enc_create_session_sz \
807 (compound_encode_hdr_maxsz + \
808 encode_create_session_maxsz)
809 #define NFS4_dec_create_session_sz \
810 (compound_decode_hdr_maxsz + \
811 decode_create_session_maxsz)
812 #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \
813 encode_destroy_session_maxsz)
814 #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \
815 decode_destroy_session_maxsz)
816 #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \
817 encode_destroy_clientid_maxsz)
818 #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \
819 decode_destroy_clientid_maxsz)
820 #define NFS4_enc_sequence_sz \
821 (compound_decode_hdr_maxsz + \
822 encode_sequence_maxsz)
823 #define NFS4_dec_sequence_sz \
824 (compound_decode_hdr_maxsz + \
825 decode_sequence_maxsz)
826 #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \
827 encode_sequence_maxsz + \
828 encode_putrootfh_maxsz + \
830 #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \
831 decode_sequence_maxsz + \
832 decode_putrootfh_maxsz + \
834 #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
835 encode_sequence_maxsz + \
836 encode_reclaim_complete_maxsz)
837 #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \
838 decode_sequence_maxsz + \
839 decode_reclaim_complete_maxsz)
840 #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \
841 encode_sequence_maxsz +\
842 encode_getdeviceinfo_maxsz)
843 #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \
844 decode_sequence_maxsz + \
845 decode_getdeviceinfo_maxsz)
846 #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \
847 encode_sequence_maxsz + \
848 encode_putfh_maxsz + \
849 encode_layoutget_maxsz)
850 #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \
851 decode_sequence_maxsz + \
852 decode_putfh_maxsz + \
853 decode_layoutget_maxsz)
854 #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \
855 encode_sequence_maxsz +\
856 encode_putfh_maxsz + \
857 encode_layoutcommit_maxsz + \
858 encode_getattr_maxsz)
859 #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \
860 decode_sequence_maxsz + \
861 decode_putfh_maxsz + \
862 decode_layoutcommit_maxsz + \
863 decode_getattr_maxsz)
864 #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \
865 encode_sequence_maxsz + \
866 encode_putfh_maxsz + \
867 encode_layoutreturn_maxsz)
868 #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \
869 decode_sequence_maxsz + \
870 decode_putfh_maxsz + \
871 decode_layoutreturn_maxsz)
872 #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \
873 encode_sequence_maxsz + \
874 encode_putrootfh_maxsz +\
875 encode_secinfo_no_name_maxsz)
876 #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \
877 decode_sequence_maxsz + \
878 decode_putrootfh_maxsz + \
879 decode_secinfo_no_name_maxsz)
880 #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \
881 encode_sequence_maxsz + \
882 encode_test_stateid_maxsz)
883 #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \
884 decode_sequence_maxsz + \
885 decode_test_stateid_maxsz)
886 #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \
887 encode_sequence_maxsz + \
888 encode_free_stateid_maxsz)
889 #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \
890 decode_sequence_maxsz + \
891 decode_free_stateid_maxsz)
893 const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
894 compound_encode_hdr_maxsz +
895 encode_sequence_maxsz +
897 encode_getattr_maxsz) *
900 const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
901 compound_decode_hdr_maxsz +
902 decode_sequence_maxsz +
903 decode_putfh_maxsz) *
906 const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH +
907 compound_decode_hdr_maxsz +
908 decode_sequence_maxsz) *
910 EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead);
911 #endif /* CONFIG_NFS_V4_1 */
913 static const umode_t nfs_type2fmt[] = {
920 [NF4SOCK] = S_IFSOCK,
926 struct compound_hdr {
932 uint32_t replen; /* expected reply words */
936 static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
938 __be32 *p = xdr_reserve_space(xdr, nbytes);
943 static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
945 WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
948 static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
950 WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
953 static void encode_uint32(struct xdr_stream *xdr, u32 n)
955 WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
958 static void encode_uint64(struct xdr_stream *xdr, u64 n)
960 WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
963 static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr,
964 const __u32 *bitmap, size_t len)
968 /* Trim empty words */
969 while (len > 0 && bitmap[len-1] == 0)
971 ret = xdr_stream_encode_uint32_array(xdr, bitmap, len);
972 if (WARN_ON_ONCE(ret < 0))
977 static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask,
978 __u32 *res, size_t len)
983 while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0))
985 for (i = len; i-- > 0;) {
986 tmp = bitmap[i] & mask[i];
992 static void encode_nfs4_seqid(struct xdr_stream *xdr,
993 const struct nfs_seqid *seqid)
996 encode_uint32(xdr, seqid->sequence->counter);
998 encode_uint32(xdr, 0);
1001 static void encode_compound_hdr(struct xdr_stream *xdr,
1002 struct rpc_rqst *req,
1003 struct compound_hdr *hdr)
1006 struct rpc_auth *auth = req->rq_cred->cr_auth;
1008 /* initialize running count of expected bytes in reply.
1009 * NOTE: the replied tag SHOULD be the same is the one sent,
1010 * but this is not required as a MUST for the server to do so. */
1011 hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen;
1013 WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN);
1014 encode_string(xdr, hdr->taglen, hdr->tag);
1015 p = reserve_space(xdr, 8);
1016 *p++ = cpu_to_be32(hdr->minorversion);
1018 *p = cpu_to_be32(hdr->nops);
1021 static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op,
1023 struct compound_hdr *hdr)
1025 encode_uint32(xdr, op);
1027 hdr->replen += replen;
1030 static void encode_nops(struct compound_hdr *hdr)
1032 WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS);
1033 *hdr->nops_p = htonl(hdr->nops);
1036 static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1038 encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
1041 static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
1043 encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE);
1047 xdr_encode_nfstime4(__be32 *p, const struct timespec *t)
1049 p = xdr_encode_hyper(p, (__s64)t->tv_sec);
1050 *p++ = cpu_to_be32(t->tv_nsec);
1054 static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1055 const struct nfs4_label *label,
1056 const umode_t *umask,
1057 const struct nfs_server *server,
1058 const uint32_t attrmask[])
1061 char owner_name[IDMAP_NAMESZ];
1062 char owner_group[IDMAP_NAMESZ];
1063 int owner_namelen = 0;
1064 int owner_grouplen = 0;
1067 uint32_t bmval[3] = { 0 };
1070 * We reserve enough space to write the entire attribute buffer at once.
1072 if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) {
1073 bmval[0] |= FATTR4_WORD0_SIZE;
1076 if (iap->ia_valid & ATTR_MODE) {
1077 if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) {
1078 bmval[2] |= FATTR4_WORD2_MODE_UMASK;
1080 } else if (attrmask[1] & FATTR4_WORD1_MODE) {
1081 bmval[1] |= FATTR4_WORD1_MODE;
1085 if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) {
1086 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
1087 if (owner_namelen < 0) {
1088 dprintk("nfs: couldn't resolve uid %d to string\n",
1089 from_kuid(&init_user_ns, iap->ia_uid));
1091 strcpy(owner_name, "nobody");
1092 owner_namelen = sizeof("nobody") - 1;
1095 bmval[1] |= FATTR4_WORD1_OWNER;
1096 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
1098 if ((iap->ia_valid & ATTR_GID) &&
1099 (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) {
1100 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
1101 if (owner_grouplen < 0) {
1102 dprintk("nfs: couldn't resolve gid %d to string\n",
1103 from_kgid(&init_user_ns, iap->ia_gid));
1104 strcpy(owner_group, "nobody");
1105 owner_grouplen = sizeof("nobody") - 1;
1108 bmval[1] |= FATTR4_WORD1_OWNER_GROUP;
1109 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
1111 if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1112 if (iap->ia_valid & ATTR_ATIME_SET) {
1113 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1114 len += 4 + (nfstime4_maxsz << 2);
1115 } else if (iap->ia_valid & ATTR_ATIME) {
1116 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1120 if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1121 if (iap->ia_valid & ATTR_MTIME_SET) {
1122 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1123 len += 4 + (nfstime4_maxsz << 2);
1124 } else if (iap->ia_valid & ATTR_MTIME) {
1125 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1130 if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) {
1131 len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
1132 bmval[2] |= FATTR4_WORD2_SECURITY_LABEL;
1135 xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval));
1136 xdr_stream_encode_opaque_inline(xdr, (void **)&p, len);
1138 if (bmval[0] & FATTR4_WORD0_SIZE)
1139 p = xdr_encode_hyper(p, iap->ia_size);
1140 if (bmval[1] & FATTR4_WORD1_MODE)
1141 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1142 if (bmval[1] & FATTR4_WORD1_OWNER)
1143 p = xdr_encode_opaque(p, owner_name, owner_namelen);
1144 if (bmval[1] & FATTR4_WORD1_OWNER_GROUP)
1145 p = xdr_encode_opaque(p, owner_group, owner_grouplen);
1146 if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1147 if (iap->ia_valid & ATTR_ATIME_SET) {
1148 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1149 ts = timespec64_to_timespec(iap->ia_atime);
1150 p = xdr_encode_nfstime4(p, &ts);
1152 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1154 if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1155 if (iap->ia_valid & ATTR_MTIME_SET) {
1156 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1157 ts = timespec64_to_timespec(iap->ia_mtime);
1158 p = xdr_encode_nfstime4(p, &ts);
1160 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1162 if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) {
1163 *p++ = cpu_to_be32(label->lfs);
1164 *p++ = cpu_to_be32(label->pi);
1165 *p++ = cpu_to_be32(label->len);
1166 p = xdr_encode_opaque_fixed(p, label->label, label->len);
1168 if (bmval[2] & FATTR4_WORD2_MODE_UMASK) {
1169 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1170 *p++ = cpu_to_be32(*umask);
1176 static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
1178 encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr);
1179 encode_uint32(xdr, access);
1182 static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1184 encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr);
1185 encode_nfs4_seqid(xdr, arg->seqid);
1186 encode_nfs4_stateid(xdr, &arg->stateid);
1189 static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr)
1193 encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
1194 p = reserve_space(xdr, 12);
1195 p = xdr_encode_hyper(p, args->offset);
1196 *p = cpu_to_be32(args->count);
1199 static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
1203 encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr);
1204 encode_uint32(xdr, create->ftype);
1206 switch (create->ftype) {
1208 p = reserve_space(xdr, 4);
1209 *p = cpu_to_be32(create->u.symlink.len);
1210 xdr_write_pages(xdr, create->u.symlink.pages, 0,
1211 create->u.symlink.len);
1212 xdr->buf->flags |= XDRBUF_WRITE;
1215 case NF4BLK: case NF4CHR:
1216 p = reserve_space(xdr, 8);
1217 *p++ = cpu_to_be32(create->u.device.specdata1);
1218 *p = cpu_to_be32(create->u.device.specdata2);
1225 encode_string(xdr, create->name->len, create->name->name);
1226 encode_attrs(xdr, create->attrs, create->label, &create->umask,
1227 create->server, create->server->attr_bitmask);
1230 static void encode_getattr(struct xdr_stream *xdr,
1231 const __u32 *bitmap, const __u32 *mask, size_t len,
1232 struct compound_hdr *hdr)
1234 __u32 masked_bitmap[nfs4_fattr_bitmap_maxsz];
1236 encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr);
1238 if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap)))
1239 len = ARRAY_SIZE(masked_bitmap);
1240 len = mask_bitmap4(bitmap, mask, masked_bitmap, len);
1241 bitmap = masked_bitmap;
1243 xdr_encode_bitmap4(xdr, bitmap, len);
1246 static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1248 encode_getattr(xdr, nfs4_fattr_bitmap, bitmask,
1249 ARRAY_SIZE(nfs4_fattr_bitmap), hdr);
1252 static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask,
1253 const u32 *open_bitmap,
1254 struct compound_hdr *hdr)
1256 encode_getattr(xdr, open_bitmap, bitmask, 3, hdr);
1259 static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1261 encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask,
1262 ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr);
1265 static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1267 encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask,
1268 ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr);
1271 static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1273 encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr);
1276 static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1278 encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr);
1279 encode_string(xdr, name->len, name->name);
1282 static inline int nfs4_lock_type(struct file_lock *fl, int block)
1284 if (fl->fl_type == F_RDLCK)
1285 return block ? NFS4_READW_LT : NFS4_READ_LT;
1286 return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
1289 static inline uint64_t nfs4_lock_length(struct file_lock *fl)
1291 if (fl->fl_end == OFFSET_MAX)
1292 return ~(uint64_t)0;
1293 return fl->fl_end - fl->fl_start + 1;
1296 static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner)
1300 p = reserve_space(xdr, 32);
1301 p = xdr_encode_hyper(p, lowner->clientid);
1302 *p++ = cpu_to_be32(20);
1303 p = xdr_encode_opaque_fixed(p, "lock id:", 8);
1304 *p++ = cpu_to_be32(lowner->s_dev);
1305 xdr_encode_hyper(p, lowner->id);
1309 * opcode,type,reclaim,offset,length,new_lock_owner = 32
1310 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
1312 static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
1316 encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr);
1317 p = reserve_space(xdr, 28);
1318 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
1319 *p++ = cpu_to_be32(args->reclaim);
1320 p = xdr_encode_hyper(p, args->fl->fl_start);
1321 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1322 *p = cpu_to_be32(args->new_lock_owner);
1323 if (args->new_lock_owner){
1324 encode_nfs4_seqid(xdr, args->open_seqid);
1325 encode_nfs4_stateid(xdr, &args->open_stateid);
1326 encode_nfs4_seqid(xdr, args->lock_seqid);
1327 encode_lockowner(xdr, &args->lock_owner);
1330 encode_nfs4_stateid(xdr, &args->lock_stateid);
1331 encode_nfs4_seqid(xdr, args->lock_seqid);
1335 static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
1339 encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr);
1340 p = reserve_space(xdr, 20);
1341 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1342 p = xdr_encode_hyper(p, args->fl->fl_start);
1343 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1344 encode_lockowner(xdr, &args->lock_owner);
1347 static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
1351 encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr);
1352 encode_uint32(xdr, nfs4_lock_type(args->fl, 0));
1353 encode_nfs4_seqid(xdr, args->seqid);
1354 encode_nfs4_stateid(xdr, &args->stateid);
1355 p = reserve_space(xdr, 16);
1356 p = xdr_encode_hyper(p, args->fl->fl_start);
1357 xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1360 static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
1362 encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr);
1363 encode_lockowner(xdr, lowner);
1366 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1368 encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr);
1369 encode_string(xdr, name->len, name->name);
1372 static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr)
1374 encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr);
1377 static void encode_share_access(struct xdr_stream *xdr, u32 share_access)
1381 p = reserve_space(xdr, 8);
1382 *p++ = cpu_to_be32(share_access);
1383 *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */
1386 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1390 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1393 encode_nfs4_seqid(xdr, arg->seqid);
1394 encode_share_access(xdr, arg->share_access);
1395 p = reserve_space(xdr, 36);
1396 p = xdr_encode_hyper(p, arg->clientid);
1397 *p++ = cpu_to_be32(24);
1398 p = xdr_encode_opaque_fixed(p, "open id:", 8);
1399 *p++ = cpu_to_be32(arg->server->s_dev);
1400 *p++ = cpu_to_be32(arg->id.uniquifier);
1401 xdr_encode_hyper(p, arg->id.create_time);
1404 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1408 p = reserve_space(xdr, 4);
1409 switch(arg->createmode) {
1410 case NFS4_CREATE_UNCHECKED:
1411 *p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
1412 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1413 arg->server, arg->server->attr_bitmask);
1415 case NFS4_CREATE_GUARDED:
1416 *p = cpu_to_be32(NFS4_CREATE_GUARDED);
1417 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1418 arg->server, arg->server->attr_bitmask);
1420 case NFS4_CREATE_EXCLUSIVE:
1421 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
1422 encode_nfs4_verifier(xdr, &arg->u.verifier);
1424 case NFS4_CREATE_EXCLUSIVE4_1:
1425 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
1426 encode_nfs4_verifier(xdr, &arg->u.verifier);
1427 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1428 arg->server, arg->server->exclcreat_bitmask);
1432 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1436 p = reserve_space(xdr, 4);
1437 switch (arg->open_flags & O_CREAT) {
1439 *p = cpu_to_be32(NFS4_OPEN_NOCREATE);
1442 *p = cpu_to_be32(NFS4_OPEN_CREATE);
1443 encode_createmode(xdr, arg);
1447 static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
1451 p = reserve_space(xdr, 4);
1452 switch (delegation_type) {
1454 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
1457 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ);
1459 case FMODE_WRITE|FMODE_READ:
1460 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE);
1467 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
1471 p = reserve_space(xdr, 4);
1472 *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
1473 encode_string(xdr, name->len, name->name);
1476 static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1480 p = reserve_space(xdr, 4);
1481 *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
1482 encode_delegation_type(xdr, type);
1485 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
1489 p = reserve_space(xdr, 4);
1490 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1491 encode_nfs4_stateid(xdr, stateid);
1492 encode_string(xdr, name->len, name->name);
1495 static inline void encode_claim_fh(struct xdr_stream *xdr)
1499 p = reserve_space(xdr, 4);
1500 *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH);
1503 static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1507 p = reserve_space(xdr, 4);
1508 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
1509 encode_nfs4_stateid(xdr, stateid);
1512 static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
1514 encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr);
1515 encode_openhdr(xdr, arg);
1516 encode_opentype(xdr, arg);
1517 switch (arg->claim) {
1518 case NFS4_OPEN_CLAIM_NULL:
1519 encode_claim_null(xdr, arg->name);
1521 case NFS4_OPEN_CLAIM_PREVIOUS:
1522 encode_claim_previous(xdr, arg->u.delegation_type);
1524 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
1525 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
1527 case NFS4_OPEN_CLAIM_FH:
1528 encode_claim_fh(xdr);
1530 case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
1531 encode_claim_delegate_cur_fh(xdr, &arg->u.delegation);
1538 static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
1540 encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr);
1541 encode_nfs4_stateid(xdr, arg->stateid);
1542 encode_nfs4_seqid(xdr, arg->seqid);
1545 static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1547 encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr);
1548 encode_nfs4_stateid(xdr, &arg->stateid);
1549 encode_nfs4_seqid(xdr, arg->seqid);
1550 encode_share_access(xdr, arg->share_access);
1554 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1556 encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr);
1557 encode_string(xdr, fh->size, fh->data);
1560 static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1562 encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
1565 static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1566 struct compound_hdr *hdr)
1570 encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
1571 encode_nfs4_stateid(xdr, &args->stateid);
1573 p = reserve_space(xdr, 12);
1574 p = xdr_encode_hyper(p, args->offset);
1575 *p = cpu_to_be32(args->count);
1578 static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
1580 uint32_t attrs[3] = {
1581 FATTR4_WORD0_RDATTR_ERROR,
1582 FATTR4_WORD1_MOUNTED_ON_FILEID,
1584 uint32_t dircount = readdir->count >> 1;
1586 uint32_t attrlen = 0;
1589 if (readdir->plus) {
1590 attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
1591 FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID;
1592 attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
1593 FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
1594 FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
1595 FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
1596 attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
1599 /* Use mounted_on_fileid only if the server supports it */
1600 if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID))
1601 attrs[0] |= FATTR4_WORD0_FILEID;
1602 for (i = 0; i < ARRAY_SIZE(attrs); i++) {
1603 attrs[i] &= readdir->bitmask[i];
1608 encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr);
1609 encode_uint64(xdr, readdir->cookie);
1610 encode_nfs4_verifier(xdr, &readdir->verifier);
1611 p = reserve_space(xdr, 12 + (attrlen << 2));
1612 *p++ = cpu_to_be32(dircount);
1613 *p++ = cpu_to_be32(readdir->count);
1614 *p++ = cpu_to_be32(attrlen);
1615 for (i = 0; i < attrlen; i++)
1616 *p++ = cpu_to_be32(attrs[i]);
1617 memcpy(verf, readdir->verifier.data, sizeof(verf));
1619 dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n",
1621 (unsigned long long)readdir->cookie,
1623 attrs[0] & readdir->bitmask[0],
1624 attrs[1] & readdir->bitmask[1],
1625 attrs[2] & readdir->bitmask[2]);
1628 static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
1630 encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr);
1633 static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1635 encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr);
1636 encode_string(xdr, name->len, name->name);
1639 static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
1641 encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr);
1642 encode_string(xdr, oldname->len, oldname->name);
1643 encode_string(xdr, newname->len, newname->name);
1646 static void encode_renew(struct xdr_stream *xdr, clientid4 clid,
1647 struct compound_hdr *hdr)
1649 encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr);
1650 encode_uint64(xdr, clid);
1654 encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1656 encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr);
1660 encode_setacl(struct xdr_stream *xdr, const struct nfs_setaclargs *arg,
1661 struct compound_hdr *hdr)
1665 encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr);
1666 encode_nfs4_stateid(xdr, &zero_stateid);
1667 p = reserve_space(xdr, 2*4);
1668 *p++ = cpu_to_be32(1);
1669 *p = cpu_to_be32(FATTR4_WORD0_ACL);
1670 p = reserve_space(xdr, 4);
1671 *p = cpu_to_be32(arg->acl_len);
1672 xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len);
1676 encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1678 encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr);
1681 static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
1683 encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr);
1684 encode_nfs4_stateid(xdr, &arg->stateid);
1685 encode_attrs(xdr, arg->iap, arg->label, NULL, server,
1686 server->attr_bitmask);
1689 static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
1693 encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr);
1694 encode_nfs4_verifier(xdr, setclientid->sc_verifier);
1696 encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id),
1697 setclientid->sc_clnt->cl_owner_id);
1698 p = reserve_space(xdr, 4);
1699 *p = cpu_to_be32(setclientid->sc_prog);
1700 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1701 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1702 p = reserve_space(xdr, 4);
1703 *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident);
1706 static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
1708 encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM,
1709 decode_setclientid_confirm_maxsz, hdr);
1710 encode_uint64(xdr, arg->clientid);
1711 encode_nfs4_verifier(xdr, &arg->confirm);
1714 static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1715 struct compound_hdr *hdr)
1719 encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
1720 encode_nfs4_stateid(xdr, &args->stateid);
1722 p = reserve_space(xdr, 16);
1723 p = xdr_encode_hyper(p, args->offset);
1724 *p++ = cpu_to_be32(args->stable);
1725 *p = cpu_to_be32(args->count);
1727 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1730 static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
1732 encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr);
1733 encode_nfs4_stateid(xdr, stateid);
1736 static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1738 encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr);
1739 encode_string(xdr, name->len, name->name);
1742 #if defined(CONFIG_NFS_V4_1)
1743 /* NFSv4.1 operations */
1744 static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1745 const struct nfs41_bind_conn_to_session_args *args,
1746 struct compound_hdr *hdr)
1750 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
1751 decode_bind_conn_to_session_maxsz, hdr);
1752 encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
1753 p = xdr_reserve_space(xdr, 8);
1754 *p++ = cpu_to_be32(args->dir);
1755 *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
1758 static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map)
1761 encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS);
1762 for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++)
1763 encode_uint32(xdr, op_map->u.words[i]);
1766 static void encode_exchange_id(struct xdr_stream *xdr,
1767 const struct nfs41_exchange_id_args *args,
1768 struct compound_hdr *hdr)
1771 char impl_name[IMPL_NAME_LIMIT];
1774 encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
1775 encode_nfs4_verifier(xdr, &args->verifier);
1777 encode_string(xdr, strlen(args->client->cl_owner_id),
1778 args->client->cl_owner_id);
1780 encode_uint32(xdr, args->flags);
1781 encode_uint32(xdr, args->state_protect.how);
1783 switch (args->state_protect.how) {
1787 encode_op_map(xdr, &args->state_protect.enforce);
1788 encode_op_map(xdr, &args->state_protect.allow);
1795 if (send_implementation_id &&
1796 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 &&
1797 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN)
1798 <= sizeof(impl_name) + 1)
1799 len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s",
1800 utsname()->sysname, utsname()->release,
1801 utsname()->version, utsname()->machine);
1804 encode_uint32(xdr, 1); /* implementation id array length=1 */
1807 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1,
1808 CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN);
1809 encode_string(xdr, len, impl_name);
1810 /* just send zeros for nii_date - the date is in nii_name */
1811 p = reserve_space(xdr, 12);
1812 p = xdr_encode_hyper(p, 0);
1813 *p = cpu_to_be32(0);
1815 encode_uint32(xdr, 0); /* implementation id array length=0 */
1818 static void encode_create_session(struct xdr_stream *xdr,
1819 const struct nfs41_create_session_args *args,
1820 struct compound_hdr *hdr)
1823 struct nfs_client *clp = args->client;
1824 struct rpc_clnt *clnt = clp->cl_rpcclient;
1825 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
1826 u32 max_resp_sz_cached;
1829 * Assumes OPEN is the biggest non-idempotent compound.
1830 * 2 is the verifier.
1832 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
1833 * XDR_UNIT + RPC_MAX_AUTH_SIZE;
1835 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
1836 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
1837 p = xdr_encode_hyper(p, args->clientid);
1838 *p++ = cpu_to_be32(args->seqid); /*Sequence id */
1839 *p++ = cpu_to_be32(args->flags); /*flags */
1842 *p++ = cpu_to_be32(0); /* header padding size */
1843 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */
1844 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */
1845 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */
1846 *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */
1847 *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */
1848 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1851 *p++ = cpu_to_be32(0); /* header padding size */
1852 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */
1853 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */
1854 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */
1855 *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */
1856 *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */
1857 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1859 *p++ = cpu_to_be32(args->cb_program); /* cb_program */
1860 *p++ = cpu_to_be32(1);
1861 *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
1863 /* authsys_parms rfc1831 */
1864 *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
1865 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
1866 *p++ = cpu_to_be32(0); /* UID */
1867 *p++ = cpu_to_be32(0); /* GID */
1868 *p = cpu_to_be32(0); /* No more gids */
1871 static void encode_destroy_session(struct xdr_stream *xdr,
1872 const struct nfs4_session *session,
1873 struct compound_hdr *hdr)
1875 encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr);
1876 encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1879 static void encode_destroy_clientid(struct xdr_stream *xdr,
1881 struct compound_hdr *hdr)
1883 encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr);
1884 encode_uint64(xdr, clientid);
1887 static void encode_reclaim_complete(struct xdr_stream *xdr,
1888 const struct nfs41_reclaim_complete_args *args,
1889 struct compound_hdr *hdr)
1891 encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr);
1892 encode_uint32(xdr, args->one_fs);
1894 #endif /* CONFIG_NFS_V4_1 */
1896 static void encode_sequence(struct xdr_stream *xdr,
1897 const struct nfs4_sequence_args *args,
1898 struct compound_hdr *hdr)
1900 #if defined(CONFIG_NFS_V4_1)
1901 struct nfs4_session *session;
1902 struct nfs4_slot_table *tp;
1903 struct nfs4_slot *slot = args->sa_slot;
1907 session = tp->session;
1911 encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr);
1914 * Sessionid + seqid + slotid + max slotid + cache_this
1916 dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
1917 "max_slotid=%d cache_this=%d\n",
1919 ((u32 *)session->sess_id.data)[0],
1920 ((u32 *)session->sess_id.data)[1],
1921 ((u32 *)session->sess_id.data)[2],
1922 ((u32 *)session->sess_id.data)[3],
1923 slot->seq_nr, slot->slot_nr,
1924 tp->highest_used_slotid, args->sa_cache_this);
1925 p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16);
1926 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1927 *p++ = cpu_to_be32(slot->seq_nr);
1928 *p++ = cpu_to_be32(slot->slot_nr);
1929 *p++ = cpu_to_be32(tp->highest_used_slotid);
1930 *p = cpu_to_be32(args->sa_cache_this);
1931 #endif /* CONFIG_NFS_V4_1 */
1934 #ifdef CONFIG_NFS_V4_1
1936 encode_getdeviceinfo(struct xdr_stream *xdr,
1937 const struct nfs4_getdeviceinfo_args *args,
1938 struct compound_hdr *hdr)
1942 encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr);
1943 p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4);
1944 p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data,
1945 NFS4_DEVICEID4_SIZE);
1946 *p++ = cpu_to_be32(args->pdev->layout_type);
1947 *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */
1949 p = reserve_space(xdr, 4 + 4);
1950 *p++ = cpu_to_be32(1); /* bitmap length */
1951 *p++ = cpu_to_be32(args->notify_types);
1955 encode_layoutget(struct xdr_stream *xdr,
1956 const struct nfs4_layoutget_args *args,
1957 struct compound_hdr *hdr)
1961 encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr);
1962 p = reserve_space(xdr, 36);
1963 *p++ = cpu_to_be32(0); /* Signal layout available */
1964 *p++ = cpu_to_be32(args->type);
1965 *p++ = cpu_to_be32(args->range.iomode);
1966 p = xdr_encode_hyper(p, args->range.offset);
1967 p = xdr_encode_hyper(p, args->range.length);
1968 p = xdr_encode_hyper(p, args->minlength);
1969 encode_nfs4_stateid(xdr, &args->stateid);
1970 encode_uint32(xdr, args->maxcount);
1972 dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n",
1976 (unsigned long)args->range.offset,
1977 (unsigned long)args->range.length,
1982 encode_layoutcommit(struct xdr_stream *xdr,
1983 struct inode *inode,
1984 const struct nfs4_layoutcommit_args *args,
1985 struct compound_hdr *hdr)
1989 dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten,
1990 NFS_SERVER(args->inode)->pnfs_curr_ld->id);
1992 encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr);
1993 p = reserve_space(xdr, 20);
1994 /* Only whole file layouts */
1995 p = xdr_encode_hyper(p, 0); /* offset */
1996 p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */
1997 *p = cpu_to_be32(0); /* reclaim */
1998 encode_nfs4_stateid(xdr, &args->stateid);
1999 if (args->lastbytewritten != U64_MAX) {
2000 p = reserve_space(xdr, 20);
2001 *p++ = cpu_to_be32(1); /* newoffset = TRUE */
2002 p = xdr_encode_hyper(p, args->lastbytewritten);
2004 p = reserve_space(xdr, 12);
2005 *p++ = cpu_to_be32(0); /* newoffset = FALSE */
2007 *p++ = cpu_to_be32(0); /* Never send time_modify_changed */
2008 *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
2010 encode_uint32(xdr, args->layoutupdate_len);
2011 if (args->layoutupdate_pages)
2012 xdr_write_pages(xdr, args->layoutupdate_pages, 0,
2013 args->layoutupdate_len);
2019 encode_layoutreturn(struct xdr_stream *xdr,
2020 const struct nfs4_layoutreturn_args *args,
2021 struct compound_hdr *hdr)
2025 encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr);
2026 p = reserve_space(xdr, 16);
2027 *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */
2028 *p++ = cpu_to_be32(args->layout_type);
2029 *p++ = cpu_to_be32(args->range.iomode);
2030 *p = cpu_to_be32(RETURN_FILE);
2031 p = reserve_space(xdr, 16);
2032 p = xdr_encode_hyper(p, args->range.offset);
2033 p = xdr_encode_hyper(p, args->range.length);
2034 spin_lock(&args->inode->i_lock);
2035 encode_nfs4_stateid(xdr, &args->stateid);
2036 spin_unlock(&args->inode->i_lock);
2037 if (args->ld_private->ops && args->ld_private->ops->encode)
2038 args->ld_private->ops->encode(xdr, args, args->ld_private);
2040 encode_uint32(xdr, 0);
2044 encode_secinfo_no_name(struct xdr_stream *xdr,
2045 const struct nfs41_secinfo_no_name_args *args,
2046 struct compound_hdr *hdr)
2048 encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr);
2049 encode_uint32(xdr, args->style);
2053 static void encode_test_stateid(struct xdr_stream *xdr,
2054 const struct nfs41_test_stateid_args *args,
2055 struct compound_hdr *hdr)
2057 encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr);
2058 encode_uint32(xdr, 1);
2059 encode_nfs4_stateid(xdr, args->stateid);
2062 static void encode_free_stateid(struct xdr_stream *xdr,
2063 const struct nfs41_free_stateid_args *args,
2064 struct compound_hdr *hdr)
2066 encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr);
2067 encode_nfs4_stateid(xdr, &args->stateid);
2071 encode_layoutreturn(struct xdr_stream *xdr,
2072 const struct nfs4_layoutreturn_args *args,
2073 struct compound_hdr *hdr)
2076 #endif /* CONFIG_NFS_V4_1 */
2079 * END OF "GENERIC" ENCODE ROUTINES.
2082 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
2084 #if defined(CONFIG_NFS_V4_1)
2085 struct nfs4_session *session = args->sa_slot->table->session;
2087 return session->clp->cl_mvops->minor_version;
2088 #endif /* CONFIG_NFS_V4_1 */
2093 * Encode an ACCESS request
2095 static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr,
2098 const struct nfs4_accessargs *args = data;
2099 struct compound_hdr hdr = {
2100 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2103 encode_compound_hdr(xdr, req, &hdr);
2104 encode_sequence(xdr, &args->seq_args, &hdr);
2105 encode_putfh(xdr, args->fh, &hdr);
2106 encode_access(xdr, args->access, &hdr);
2108 encode_getfattr(xdr, args->bitmask, &hdr);
2113 * Encode LOOKUP request
2115 static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr,
2118 const struct nfs4_lookup_arg *args = data;
2119 struct compound_hdr hdr = {
2120 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2123 encode_compound_hdr(xdr, req, &hdr);
2124 encode_sequence(xdr, &args->seq_args, &hdr);
2125 encode_putfh(xdr, args->dir_fh, &hdr);
2126 encode_lookup(xdr, args->name, &hdr);
2127 encode_getfh(xdr, &hdr);
2128 encode_getfattr(xdr, args->bitmask, &hdr);
2133 * Encode LOOKUPP request
2135 static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr,
2138 const struct nfs4_lookupp_arg *args = data;
2139 struct compound_hdr hdr = {
2140 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2143 encode_compound_hdr(xdr, req, &hdr);
2144 encode_sequence(xdr, &args->seq_args, &hdr);
2145 encode_putfh(xdr, args->fh, &hdr);
2146 encode_lookupp(xdr, &hdr);
2147 encode_getfh(xdr, &hdr);
2148 encode_getfattr(xdr, args->bitmask, &hdr);
2153 * Encode LOOKUP_ROOT request
2155 static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req,
2156 struct xdr_stream *xdr,
2159 const struct nfs4_lookup_root_arg *args = data;
2160 struct compound_hdr hdr = {
2161 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2164 encode_compound_hdr(xdr, req, &hdr);
2165 encode_sequence(xdr, &args->seq_args, &hdr);
2166 encode_putrootfh(xdr, &hdr);
2167 encode_getfh(xdr, &hdr);
2168 encode_getfattr(xdr, args->bitmask, &hdr);
2173 * Encode REMOVE request
2175 static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
2178 const struct nfs_removeargs *args = data;
2179 struct compound_hdr hdr = {
2180 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2183 encode_compound_hdr(xdr, req, &hdr);
2184 encode_sequence(xdr, &args->seq_args, &hdr);
2185 encode_putfh(xdr, args->fh, &hdr);
2186 encode_remove(xdr, &args->name, &hdr);
2191 * Encode RENAME request
2193 static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
2196 const struct nfs_renameargs *args = data;
2197 struct compound_hdr hdr = {
2198 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2201 encode_compound_hdr(xdr, req, &hdr);
2202 encode_sequence(xdr, &args->seq_args, &hdr);
2203 encode_putfh(xdr, args->old_dir, &hdr);
2204 encode_savefh(xdr, &hdr);
2205 encode_putfh(xdr, args->new_dir, &hdr);
2206 encode_rename(xdr, args->old_name, args->new_name, &hdr);
2211 * Encode LINK request
2213 static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
2216 const struct nfs4_link_arg *args = data;
2217 struct compound_hdr hdr = {
2218 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2221 encode_compound_hdr(xdr, req, &hdr);
2222 encode_sequence(xdr, &args->seq_args, &hdr);
2223 encode_putfh(xdr, args->fh, &hdr);
2224 encode_savefh(xdr, &hdr);
2225 encode_putfh(xdr, args->dir_fh, &hdr);
2226 encode_link(xdr, args->name, &hdr);
2227 encode_restorefh(xdr, &hdr);
2228 encode_getfattr(xdr, args->bitmask, &hdr);
2233 * Encode CREATE request
2235 static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr,
2238 const struct nfs4_create_arg *args = data;
2239 struct compound_hdr hdr = {
2240 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2243 encode_compound_hdr(xdr, req, &hdr);
2244 encode_sequence(xdr, &args->seq_args, &hdr);
2245 encode_putfh(xdr, args->dir_fh, &hdr);
2246 encode_create(xdr, args, &hdr);
2247 encode_getfh(xdr, &hdr);
2248 encode_getfattr(xdr, args->bitmask, &hdr);
2253 * Encode SYMLINK request
2255 static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2258 const struct nfs4_create_arg *args = data;
2260 nfs4_xdr_enc_create(req, xdr, args);
2264 * Encode GETATTR request
2266 static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2269 const struct nfs4_getattr_arg *args = data;
2270 struct compound_hdr hdr = {
2271 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2274 encode_compound_hdr(xdr, req, &hdr);
2275 encode_sequence(xdr, &args->seq_args, &hdr);
2276 encode_putfh(xdr, args->fh, &hdr);
2277 encode_getfattr(xdr, args->bitmask, &hdr);
2282 * Encode a CLOSE request
2284 static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
2287 const struct nfs_closeargs *args = data;
2288 struct compound_hdr hdr = {
2289 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2292 encode_compound_hdr(xdr, req, &hdr);
2293 encode_sequence(xdr, &args->seq_args, &hdr);
2294 encode_putfh(xdr, args->fh, &hdr);
2296 encode_layoutreturn(xdr, args->lr_args, &hdr);
2297 if (args->bitmask != NULL)
2298 encode_getfattr(xdr, args->bitmask, &hdr);
2299 encode_close(xdr, args, &hdr);
2304 * Encode an OPEN request
2306 static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
2309 const struct nfs_openargs *args = data;
2310 struct compound_hdr hdr = {
2311 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2314 encode_compound_hdr(xdr, req, &hdr);
2315 encode_sequence(xdr, &args->seq_args, &hdr);
2316 encode_putfh(xdr, args->fh, &hdr);
2317 encode_open(xdr, args, &hdr);
2318 encode_getfh(xdr, &hdr);
2320 encode_access(xdr, args->access, &hdr);
2321 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2326 * Encode an OPEN_CONFIRM request
2328 static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req,
2329 struct xdr_stream *xdr,
2332 const struct nfs_open_confirmargs *args = data;
2333 struct compound_hdr hdr = {
2337 encode_compound_hdr(xdr, req, &hdr);
2338 encode_putfh(xdr, args->fh, &hdr);
2339 encode_open_confirm(xdr, args, &hdr);
2344 * Encode an OPEN request with no attributes.
2346 static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
2347 struct xdr_stream *xdr,
2350 const struct nfs_openargs *args = data;
2351 struct compound_hdr hdr = {
2352 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2355 encode_compound_hdr(xdr, req, &hdr);
2356 encode_sequence(xdr, &args->seq_args, &hdr);
2357 encode_putfh(xdr, args->fh, &hdr);
2358 encode_open(xdr, args, &hdr);
2360 encode_access(xdr, args->access, &hdr);
2361 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2366 * Encode an OPEN_DOWNGRADE request
2368 static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req,
2369 struct xdr_stream *xdr,
2372 const struct nfs_closeargs *args = data;
2373 struct compound_hdr hdr = {
2374 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2377 encode_compound_hdr(xdr, req, &hdr);
2378 encode_sequence(xdr, &args->seq_args, &hdr);
2379 encode_putfh(xdr, args->fh, &hdr);
2381 encode_layoutreturn(xdr, args->lr_args, &hdr);
2382 encode_open_downgrade(xdr, args, &hdr);
2387 * Encode a LOCK request
2389 static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr,
2392 const struct nfs_lock_args *args = data;
2393 struct compound_hdr hdr = {
2394 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2397 encode_compound_hdr(xdr, req, &hdr);
2398 encode_sequence(xdr, &args->seq_args, &hdr);
2399 encode_putfh(xdr, args->fh, &hdr);
2400 encode_lock(xdr, args, &hdr);
2405 * Encode a LOCKT request
2407 static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr,
2410 const struct nfs_lockt_args *args = data;
2411 struct compound_hdr hdr = {
2412 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2415 encode_compound_hdr(xdr, req, &hdr);
2416 encode_sequence(xdr, &args->seq_args, &hdr);
2417 encode_putfh(xdr, args->fh, &hdr);
2418 encode_lockt(xdr, args, &hdr);
2423 * Encode a LOCKU request
2425 static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
2428 const struct nfs_locku_args *args = data;
2429 struct compound_hdr hdr = {
2430 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2433 encode_compound_hdr(xdr, req, &hdr);
2434 encode_sequence(xdr, &args->seq_args, &hdr);
2435 encode_putfh(xdr, args->fh, &hdr);
2436 encode_locku(xdr, args, &hdr);
2440 static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
2441 struct xdr_stream *xdr,
2444 const struct nfs_release_lockowner_args *args = data;
2445 struct compound_hdr hdr = {
2449 encode_compound_hdr(xdr, req, &hdr);
2450 encode_release_lockowner(xdr, &args->lock_owner, &hdr);
2455 * Encode a READLINK request
2457 static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2460 const struct nfs4_readlink *args = data;
2461 struct compound_hdr hdr = {
2462 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2465 encode_compound_hdr(xdr, req, &hdr);
2466 encode_sequence(xdr, &args->seq_args, &hdr);
2467 encode_putfh(xdr, args->fh, &hdr);
2468 encode_readlink(xdr, args, req, &hdr);
2470 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2471 args->pgbase, args->pglen);
2476 * Encode a READDIR request
2478 static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
2481 const struct nfs4_readdir_arg *args = data;
2482 struct compound_hdr hdr = {
2483 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2486 encode_compound_hdr(xdr, req, &hdr);
2487 encode_sequence(xdr, &args->seq_args, &hdr);
2488 encode_putfh(xdr, args->fh, &hdr);
2489 encode_readdir(xdr, args, req, &hdr);
2491 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2492 args->pgbase, args->count);
2493 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
2494 __func__, hdr.replen << 2, args->pages,
2495 args->pgbase, args->count);
2500 * Encode a READ request
2502 static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
2505 const struct nfs_pgio_args *args = data;
2506 struct compound_hdr hdr = {
2507 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2510 encode_compound_hdr(xdr, req, &hdr);
2511 encode_sequence(xdr, &args->seq_args, &hdr);
2512 encode_putfh(xdr, args->fh, &hdr);
2513 encode_read(xdr, args, &hdr);
2515 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
2516 args->pages, args->pgbase, args->count);
2517 req->rq_rcv_buf.flags |= XDRBUF_READ;
2522 * Encode an SETATTR request
2524 static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2527 const struct nfs_setattrargs *args = data;
2528 struct compound_hdr hdr = {
2529 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2532 encode_compound_hdr(xdr, req, &hdr);
2533 encode_sequence(xdr, &args->seq_args, &hdr);
2534 encode_putfh(xdr, args->fh, &hdr);
2535 encode_setattr(xdr, args, args->server, &hdr);
2536 encode_getfattr(xdr, args->bitmask, &hdr);
2541 * Encode a GETACL request
2543 static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2546 const struct nfs_getaclargs *args = data;
2547 struct compound_hdr hdr = {
2548 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2550 const __u32 nfs4_acl_bitmap[1] = {
2551 [0] = FATTR4_WORD0_ACL,
2555 encode_compound_hdr(xdr, req, &hdr);
2556 encode_sequence(xdr, &args->seq_args, &hdr);
2557 encode_putfh(xdr, args->fh, &hdr);
2558 replen = hdr.replen + op_decode_hdr_maxsz;
2559 encode_getattr(xdr, nfs4_acl_bitmap, NULL,
2560 ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
2562 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2563 args->acl_pages, 0, args->acl_len);
2569 * Encode a WRITE request
2571 static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
2574 const struct nfs_pgio_args *args = data;
2575 struct compound_hdr hdr = {
2576 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2579 encode_compound_hdr(xdr, req, &hdr);
2580 encode_sequence(xdr, &args->seq_args, &hdr);
2581 encode_putfh(xdr, args->fh, &hdr);
2582 encode_write(xdr, args, &hdr);
2583 req->rq_snd_buf.flags |= XDRBUF_WRITE;
2585 encode_getfattr(xdr, args->bitmask, &hdr);
2592 static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr,
2595 const struct nfs_commitargs *args = data;
2596 struct compound_hdr hdr = {
2597 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2600 encode_compound_hdr(xdr, req, &hdr);
2601 encode_sequence(xdr, &args->seq_args, &hdr);
2602 encode_putfh(xdr, args->fh, &hdr);
2603 encode_commit(xdr, args, &hdr);
2610 static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
2613 const struct nfs4_fsinfo_arg *args = data;
2614 struct compound_hdr hdr = {
2615 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2618 encode_compound_hdr(xdr, req, &hdr);
2619 encode_sequence(xdr, &args->seq_args, &hdr);
2620 encode_putfh(xdr, args->fh, &hdr);
2621 encode_fsinfo(xdr, args->bitmask, &hdr);
2626 * a PATHCONF request
2628 static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
2631 const struct nfs4_pathconf_arg *args = data;
2632 struct compound_hdr hdr = {
2633 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2636 encode_compound_hdr(xdr, req, &hdr);
2637 encode_sequence(xdr, &args->seq_args, &hdr);
2638 encode_putfh(xdr, args->fh, &hdr);
2639 encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask,
2640 ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr);
2647 static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
2650 const struct nfs4_statfs_arg *args = data;
2651 struct compound_hdr hdr = {
2652 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2655 encode_compound_hdr(xdr, req, &hdr);
2656 encode_sequence(xdr, &args->seq_args, &hdr);
2657 encode_putfh(xdr, args->fh, &hdr);
2658 encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask,
2659 ARRAY_SIZE(nfs4_statfs_bitmap), &hdr);
2664 * GETATTR_BITMAP request
2666 static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
2667 struct xdr_stream *xdr,
2670 const struct nfs4_server_caps_arg *args = data;
2671 const u32 *bitmask = args->bitmask;
2672 struct compound_hdr hdr = {
2673 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2676 encode_compound_hdr(xdr, req, &hdr);
2677 encode_sequence(xdr, &args->seq_args, &hdr);
2678 encode_putfh(xdr, args->fhandle, &hdr);
2679 encode_getattr(xdr, bitmask, NULL, 3, &hdr);
2686 static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
2690 const struct nfs_client *clp = data;
2691 struct compound_hdr hdr = {
2695 encode_compound_hdr(xdr, req, &hdr);
2696 encode_renew(xdr, clp->cl_clientid, &hdr);
2701 * a SETCLIENTID request
2703 static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req,
2704 struct xdr_stream *xdr,
2707 const struct nfs4_setclientid *sc = data;
2708 struct compound_hdr hdr = {
2712 encode_compound_hdr(xdr, req, &hdr);
2713 encode_setclientid(xdr, sc, &hdr);
2718 * a SETCLIENTID_CONFIRM request
2720 static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
2721 struct xdr_stream *xdr,
2724 const struct nfs4_setclientid_res *arg = data;
2725 struct compound_hdr hdr = {
2729 encode_compound_hdr(xdr, req, &hdr);
2730 encode_setclientid_confirm(xdr, arg, &hdr);
2735 * DELEGRETURN request
2737 static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req,
2738 struct xdr_stream *xdr,
2741 const struct nfs4_delegreturnargs *args = data;
2742 struct compound_hdr hdr = {
2743 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2746 encode_compound_hdr(xdr, req, &hdr);
2747 encode_sequence(xdr, &args->seq_args, &hdr);
2748 encode_putfh(xdr, args->fhandle, &hdr);
2750 encode_layoutreturn(xdr, args->lr_args, &hdr);
2752 encode_getfattr(xdr, args->bitmask, &hdr);
2753 encode_delegreturn(xdr, args->stateid, &hdr);
2758 * Encode FS_LOCATIONS request
2760 static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
2761 struct xdr_stream *xdr,
2764 const struct nfs4_fs_locations_arg *args = data;
2765 struct compound_hdr hdr = {
2766 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2770 encode_compound_hdr(xdr, req, &hdr);
2771 encode_sequence(xdr, &args->seq_args, &hdr);
2772 if (args->migration) {
2773 encode_putfh(xdr, args->fh, &hdr);
2774 replen = hdr.replen;
2775 encode_fs_locations(xdr, args->bitmask, &hdr);
2777 encode_renew(xdr, args->clientid, &hdr);
2779 encode_putfh(xdr, args->dir_fh, &hdr);
2780 encode_lookup(xdr, args->name, &hdr);
2781 replen = hdr.replen;
2782 encode_fs_locations(xdr, args->bitmask, &hdr);
2785 /* Set up reply kvec to capture returned fs_locations array. */
2786 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2787 (struct page **)&args->page, 0, PAGE_SIZE);
2792 * Encode SECINFO request
2794 static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req,
2795 struct xdr_stream *xdr,
2798 const struct nfs4_secinfo_arg *args = data;
2799 struct compound_hdr hdr = {
2800 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2803 encode_compound_hdr(xdr, req, &hdr);
2804 encode_sequence(xdr, &args->seq_args, &hdr);
2805 encode_putfh(xdr, args->dir_fh, &hdr);
2806 encode_secinfo(xdr, args->name, &hdr);
2811 * Encode FSID_PRESENT request
2813 static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req,
2814 struct xdr_stream *xdr,
2817 const struct nfs4_fsid_present_arg *args = data;
2818 struct compound_hdr hdr = {
2819 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2822 encode_compound_hdr(xdr, req, &hdr);
2823 encode_sequence(xdr, &args->seq_args, &hdr);
2824 encode_putfh(xdr, args->fh, &hdr);
2825 encode_getfh(xdr, &hdr);
2827 encode_renew(xdr, args->clientid, &hdr);
2831 #if defined(CONFIG_NFS_V4_1)
2833 * BIND_CONN_TO_SESSION request
2835 static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
2836 struct xdr_stream *xdr,
2839 const struct nfs41_bind_conn_to_session_args *args = data;
2840 struct compound_hdr hdr = {
2841 .minorversion = args->client->cl_mvops->minor_version,
2844 encode_compound_hdr(xdr, req, &hdr);
2845 encode_bind_conn_to_session(xdr, args, &hdr);
2850 * EXCHANGE_ID request
2852 static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req,
2853 struct xdr_stream *xdr,
2856 const struct nfs41_exchange_id_args *args = data;
2857 struct compound_hdr hdr = {
2858 .minorversion = args->client->cl_mvops->minor_version,
2861 encode_compound_hdr(xdr, req, &hdr);
2862 encode_exchange_id(xdr, args, &hdr);
2867 * a CREATE_SESSION request
2869 static void nfs4_xdr_enc_create_session(struct rpc_rqst *req,
2870 struct xdr_stream *xdr,
2873 const struct nfs41_create_session_args *args = data;
2874 struct compound_hdr hdr = {
2875 .minorversion = args->client->cl_mvops->minor_version,
2878 encode_compound_hdr(xdr, req, &hdr);
2879 encode_create_session(xdr, args, &hdr);
2884 * a DESTROY_SESSION request
2886 static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req,
2887 struct xdr_stream *xdr,
2890 const struct nfs4_session *session = data;
2891 struct compound_hdr hdr = {
2892 .minorversion = session->clp->cl_mvops->minor_version,
2895 encode_compound_hdr(xdr, req, &hdr);
2896 encode_destroy_session(xdr, session, &hdr);
2901 * a DESTROY_CLIENTID request
2903 static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req,
2904 struct xdr_stream *xdr,
2907 const struct nfs_client *clp = data;
2908 struct compound_hdr hdr = {
2909 .minorversion = clp->cl_mvops->minor_version,
2912 encode_compound_hdr(xdr, req, &hdr);
2913 encode_destroy_clientid(xdr, clp->cl_clientid, &hdr);
2918 * a SEQUENCE request
2920 static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr,
2923 const struct nfs4_sequence_args *args = data;
2924 struct compound_hdr hdr = {
2925 .minorversion = nfs4_xdr_minorversion(args),
2928 encode_compound_hdr(xdr, req, &hdr);
2929 encode_sequence(xdr, args, &hdr);
2934 * a GET_LEASE_TIME request
2936 static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req,
2937 struct xdr_stream *xdr,
2940 const struct nfs4_get_lease_time_args *args = data;
2941 struct compound_hdr hdr = {
2942 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
2944 const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME };
2946 encode_compound_hdr(xdr, req, &hdr);
2947 encode_sequence(xdr, &args->la_seq_args, &hdr);
2948 encode_putrootfh(xdr, &hdr);
2949 encode_fsinfo(xdr, lease_bitmap, &hdr);
2954 * a RECLAIM_COMPLETE request
2956 static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req,
2957 struct xdr_stream *xdr,
2960 const struct nfs41_reclaim_complete_args *args = data;
2961 struct compound_hdr hdr = {
2962 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
2965 encode_compound_hdr(xdr, req, &hdr);
2966 encode_sequence(xdr, &args->seq_args, &hdr);
2967 encode_reclaim_complete(xdr, args, &hdr);
2972 * Encode GETDEVICEINFO request
2974 static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req,
2975 struct xdr_stream *xdr,
2978 const struct nfs4_getdeviceinfo_args *args = data;
2979 struct compound_hdr hdr = {
2980 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2983 encode_compound_hdr(xdr, req, &hdr);
2984 encode_sequence(xdr, &args->seq_args, &hdr);
2985 encode_getdeviceinfo(xdr, args, &hdr);
2987 /* set up reply kvec. Subtract notification bitmap max size (2)
2988 * so that notification bitmap is put in xdr_buf tail */
2989 xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2,
2990 args->pdev->pages, args->pdev->pgbase,
2997 * Encode LAYOUTGET request
2999 static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req,
3000 struct xdr_stream *xdr,
3003 const struct nfs4_layoutget_args *args = data;
3004 struct compound_hdr hdr = {
3005 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3008 encode_compound_hdr(xdr, req, &hdr);
3009 encode_sequence(xdr, &args->seq_args, &hdr);
3010 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3011 encode_layoutget(xdr, args, &hdr);
3013 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
3014 args->layout.pages, 0, args->layout.pglen);
3020 * Encode LAYOUTCOMMIT request
3022 static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
3023 struct xdr_stream *xdr,
3026 const struct nfs4_layoutcommit_args *args = priv;
3027 struct nfs4_layoutcommit_data *data =
3028 container_of(args, struct nfs4_layoutcommit_data, args);
3029 struct compound_hdr hdr = {
3030 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3033 encode_compound_hdr(xdr, req, &hdr);
3034 encode_sequence(xdr, &args->seq_args, &hdr);
3035 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3036 encode_layoutcommit(xdr, data->args.inode, args, &hdr);
3037 encode_getfattr(xdr, args->bitmask, &hdr);
3042 * Encode LAYOUTRETURN request
3044 static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req,
3045 struct xdr_stream *xdr,
3048 const struct nfs4_layoutreturn_args *args = data;
3049 struct compound_hdr hdr = {
3050 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3053 encode_compound_hdr(xdr, req, &hdr);
3054 encode_sequence(xdr, &args->seq_args, &hdr);
3055 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3056 encode_layoutreturn(xdr, args, &hdr);
3061 * Encode SECINFO_NO_NAME request
3063 static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req,
3064 struct xdr_stream *xdr,
3067 const struct nfs41_secinfo_no_name_args *args = data;
3068 struct compound_hdr hdr = {
3069 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3072 encode_compound_hdr(xdr, req, &hdr);
3073 encode_sequence(xdr, &args->seq_args, &hdr);
3074 encode_putrootfh(xdr, &hdr);
3075 encode_secinfo_no_name(xdr, args, &hdr);
3080 * Encode TEST_STATEID request
3082 static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req,
3083 struct xdr_stream *xdr,
3086 const struct nfs41_test_stateid_args *args = data;
3087 struct compound_hdr hdr = {
3088 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3091 encode_compound_hdr(xdr, req, &hdr);
3092 encode_sequence(xdr, &args->seq_args, &hdr);
3093 encode_test_stateid(xdr, args, &hdr);
3098 * Encode FREE_STATEID request
3100 static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req,
3101 struct xdr_stream *xdr,
3104 const struct nfs41_free_stateid_args *args = data;
3105 struct compound_hdr hdr = {
3106 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3109 encode_compound_hdr(xdr, req, &hdr);
3110 encode_sequence(xdr, &args->seq_args, &hdr);
3111 encode_free_stateid(xdr, args, &hdr);
3114 #endif /* CONFIG_NFS_V4_1 */
3116 static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
3118 dprintk("nfs: %s: prematurely hit end of receive buffer. "
3119 "Remaining buffer length is %tu words.\n",
3120 func, xdr->end - xdr->p);
3123 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
3125 ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
3127 if (unlikely(ret < 0)) {
3128 if (ret == -EBADMSG)
3129 print_overflow_msg(__func__, xdr);
3136 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
3140 p = xdr_inline_decode(xdr, 8);
3143 hdr->status = be32_to_cpup(p++);
3144 hdr->taglen = be32_to_cpup(p);
3146 p = xdr_inline_decode(xdr, hdr->taglen + 4);
3149 hdr->tag = (char *)p;
3150 p += XDR_QUADLEN(hdr->taglen);
3151 hdr->nops = be32_to_cpup(p);
3152 if (unlikely(hdr->nops < 1))
3153 return nfs4_stat_to_errno(hdr->status);
3156 print_overflow_msg(__func__, xdr);
3160 static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
3167 p = xdr_inline_decode(xdr, 8);
3170 opnum = be32_to_cpup(p++);
3171 if (unlikely(opnum != expected))
3172 goto out_bad_operation;
3173 nfserr = be32_to_cpup(p);
3174 if (nfserr == NFS_OK)
3177 *nfs_retval = nfs4_stat_to_errno(nfserr);
3180 dprintk("nfs: Server returned operation"
3181 " %d but we issued a request for %d\n",
3183 *nfs_retval = -EREMOTEIO;
3186 print_overflow_msg(__func__, xdr);
3191 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
3195 __decode_op_hdr(xdr, expected, &retval);
3200 static int decode_ace(struct xdr_stream *xdr, void *ace)
3203 unsigned int strlen;
3206 p = xdr_inline_decode(xdr, 12);
3208 return decode_opaque_inline(xdr, &strlen, &str);
3209 print_overflow_msg(__func__, xdr);
3214 decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz)
3218 ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz);
3219 if (likely(ret >= 0))
3221 if (ret == -EMSGSIZE)
3223 print_overflow_msg(__func__, xdr);
3227 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
3230 ret = decode_bitmap4(xdr, bitmap, 3);
3231 return ret < 0 ? ret : 0;
3234 static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep)
3238 p = xdr_inline_decode(xdr, 4);
3241 *attrlen = be32_to_cpup(p);
3242 *savep = xdr_stream_pos(xdr);
3245 print_overflow_msg(__func__, xdr);
3249 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
3251 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
3253 ret = decode_attr_bitmap(xdr, bitmask);
3254 if (unlikely(ret < 0))
3256 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
3258 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3259 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3260 bitmask[0], bitmask[1], bitmask[2]);
3264 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
3270 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
3272 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
3273 p = xdr_inline_decode(xdr, 4);
3276 *type = be32_to_cpup(p);
3277 if (*type < NF4REG || *type > NF4NAMEDATTR) {
3278 dprintk("%s: bad type %d\n", __func__, *type);
3281 bitmap[0] &= ~FATTR4_WORD0_TYPE;
3282 ret = NFS_ATTR_FATTR_TYPE;
3284 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
3287 print_overflow_msg(__func__, xdr);
3291 static int decode_attr_fh_expire_type(struct xdr_stream *xdr,
3292 uint32_t *bitmap, uint32_t *type)
3297 if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U)))
3299 if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) {
3300 p = xdr_inline_decode(xdr, 4);
3303 *type = be32_to_cpup(p);
3304 bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE;
3306 dprintk("%s: expire type=0x%x\n", __func__, *type);
3309 print_overflow_msg(__func__, xdr);
3313 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
3319 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
3321 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
3322 p = xdr_inline_decode(xdr, 8);
3325 xdr_decode_hyper(p, change);
3326 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
3327 ret = NFS_ATTR_FATTR_CHANGE;
3329 dprintk("%s: change attribute=%Lu\n", __func__,
3330 (unsigned long long)*change);
3333 print_overflow_msg(__func__, xdr);
3337 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
3343 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
3345 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
3346 p = xdr_inline_decode(xdr, 8);
3349 xdr_decode_hyper(p, size);
3350 bitmap[0] &= ~FATTR4_WORD0_SIZE;
3351 ret = NFS_ATTR_FATTR_SIZE;
3353 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
3356 print_overflow_msg(__func__, xdr);
3360 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3365 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
3367 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
3368 p = xdr_inline_decode(xdr, 4);
3371 *res = be32_to_cpup(p);
3372 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
3374 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
3377 print_overflow_msg(__func__, xdr);
3381 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3386 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
3388 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
3389 p = xdr_inline_decode(xdr, 4);
3392 *res = be32_to_cpup(p);
3393 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
3395 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
3398 print_overflow_msg(__func__, xdr);
3402 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
3409 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
3411 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
3412 p = xdr_inline_decode(xdr, 16);
3415 p = xdr_decode_hyper(p, &fsid->major);
3416 xdr_decode_hyper(p, &fsid->minor);
3417 bitmap[0] &= ~FATTR4_WORD0_FSID;
3418 ret = NFS_ATTR_FATTR_FSID;
3420 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
3421 (unsigned long long)fsid->major,
3422 (unsigned long long)fsid->minor);
3425 print_overflow_msg(__func__, xdr);
3429 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3434 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
3436 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
3437 p = xdr_inline_decode(xdr, 4);
3440 *res = be32_to_cpup(p);
3441 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
3443 dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
3446 print_overflow_msg(__func__, xdr);
3450 static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
3454 if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U)))
3456 if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
3457 p = xdr_inline_decode(xdr, 4);
3460 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
3461 *res = -be32_to_cpup(p);
3465 print_overflow_msg(__func__, xdr);
3469 static int decode_attr_exclcreat_supported(struct xdr_stream *xdr,
3470 uint32_t *bitmap, uint32_t *bitmask)
3472 if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) {
3474 ret = decode_attr_bitmap(xdr, bitmask);
3475 if (unlikely(ret < 0))
3477 bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT;
3479 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3480 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3481 bitmask[0], bitmask[1], bitmask[2]);
3485 static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
3491 memset(fh, 0, sizeof(*fh));
3493 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
3495 if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
3496 p = xdr_inline_decode(xdr, 4);
3499 len = be32_to_cpup(p);
3500 if (len > NFS4_FHSIZE)
3502 p = xdr_inline_decode(xdr, len);
3506 memcpy(fh->data, p, len);
3509 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
3513 print_overflow_msg(__func__, xdr);
3517 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3522 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
3524 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
3525 p = xdr_inline_decode(xdr, 4);
3528 *res = be32_to_cpup(p);
3529 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
3531 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
3534 print_overflow_msg(__func__, xdr);
3538 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3544 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
3546 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
3547 p = xdr_inline_decode(xdr, 8);
3550 xdr_decode_hyper(p, fileid);
3551 bitmap[0] &= ~FATTR4_WORD0_FILEID;
3552 ret = NFS_ATTR_FATTR_FILEID;
3554 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3557 print_overflow_msg(__func__, xdr);
3561 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3567 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
3569 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
3570 p = xdr_inline_decode(xdr, 8);
3573 xdr_decode_hyper(p, fileid);
3574 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
3575 ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
3577 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3580 print_overflow_msg(__func__, xdr);
3584 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3590 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
3592 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
3593 p = xdr_inline_decode(xdr, 8);
3596 xdr_decode_hyper(p, res);
3597 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
3599 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
3602 print_overflow_msg(__func__, xdr);
3606 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3612 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
3614 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
3615 p = xdr_inline_decode(xdr, 8);
3618 xdr_decode_hyper(p, res);
3619 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
3621 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
3624 print_overflow_msg(__func__, xdr);
3628 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3634 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
3636 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
3637 p = xdr_inline_decode(xdr, 8);
3640 xdr_decode_hyper(p, res);
3641 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
3643 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
3646 print_overflow_msg(__func__, xdr);
3650 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3656 p = xdr_inline_decode(xdr, 4);
3659 n = be32_to_cpup(p);
3662 dprintk("pathname4: ");
3663 if (n > NFS4_PATHNAME_MAXCOMPONENTS) {
3664 dprintk("cannot parse %d components in path\n", n);
3667 for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) {
3668 struct nfs4_string *component = &path->components[path->ncomponents];
3669 status = decode_opaque_inline(xdr, &component->len, &component->data);
3670 if (unlikely(status != 0))
3674 (path->ncomponents != n ? "/ " : ""),
3675 component->len, component->data);
3680 /* a root pathname is sent as a zero component4 */
3681 path->ncomponents = 1;
3682 path->components[0].len=0;
3683 path->components[0].data=NULL;
3684 dprintk("pathname4: /\n");
3687 dprintk(" status %d", status);
3691 print_overflow_msg(__func__, xdr);
3695 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
3701 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
3704 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
3706 bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS;
3708 /* Ignore borken servers that return unrequested attrs */
3709 if (unlikely(res == NULL))
3711 dprintk("%s: fsroot:\n", __func__);
3712 status = decode_pathname(xdr, &res->fs_path);
3713 if (unlikely(status != 0))
3715 p = xdr_inline_decode(xdr, 4);
3718 n = be32_to_cpup(p);
3721 for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
3723 struct nfs4_fs_location *loc;
3725 if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES)
3727 loc = &res->locations[res->nlocations];
3728 p = xdr_inline_decode(xdr, 4);
3731 m = be32_to_cpup(p);
3733 dprintk("%s: servers:\n", __func__);
3734 for (loc->nservers = 0; loc->nservers < m; loc->nservers++) {
3735 struct nfs4_string *server;
3737 if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) {
3739 dprintk("%s: using first %u of %u servers "
3740 "returned for location %u\n",
3742 NFS4_FS_LOCATION_MAXSERVERS,
3743 m, res->nlocations);
3744 for (i = loc->nservers; i < m; i++) {
3747 status = decode_opaque_inline(xdr, &len, &data);
3748 if (unlikely(status != 0))
3753 server = &loc->servers[loc->nservers];
3754 status = decode_opaque_inline(xdr, &server->len, &server->data);
3755 if (unlikely(status != 0))
3757 dprintk("%s ", server->data);
3759 status = decode_pathname(xdr, &loc->rootpath);
3760 if (unlikely(status != 0))
3763 if (res->nlocations != 0)
3764 status = NFS_ATTR_FATTR_V4_LOCATIONS;
3766 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
3769 print_overflow_msg(__func__, xdr);
3775 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3781 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
3783 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
3784 p = xdr_inline_decode(xdr, 8);
3787 xdr_decode_hyper(p, res);
3788 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
3790 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
3793 print_overflow_msg(__func__, xdr);
3797 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
3803 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
3805 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
3806 p = xdr_inline_decode(xdr, 4);
3809 *maxlink = be32_to_cpup(p);
3810 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
3812 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
3815 print_overflow_msg(__func__, xdr);
3819 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
3825 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
3827 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
3828 p = xdr_inline_decode(xdr, 4);
3831 *maxname = be32_to_cpup(p);
3832 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
3834 dprintk("%s: maxname=%u\n", __func__, *maxname);
3837 print_overflow_msg(__func__, xdr);
3841 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3847 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
3849 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
3851 p = xdr_inline_decode(xdr, 8);
3854 xdr_decode_hyper(p, &maxread);
3855 if (maxread > 0x7FFFFFFF)
3856 maxread = 0x7FFFFFFF;
3857 *res = (uint32_t)maxread;
3858 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
3860 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
3863 print_overflow_msg(__func__, xdr);
3867 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3873 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
3875 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
3877 p = xdr_inline_decode(xdr, 8);
3880 xdr_decode_hyper(p, &maxwrite);
3881 if (maxwrite > 0x7FFFFFFF)
3882 maxwrite = 0x7FFFFFFF;
3883 *res = (uint32_t)maxwrite;
3884 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
3886 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
3889 print_overflow_msg(__func__, xdr);
3893 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
3900 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
3902 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
3903 p = xdr_inline_decode(xdr, 4);
3906 tmp = be32_to_cpup(p);
3907 *mode = tmp & ~S_IFMT;
3908 bitmap[1] &= ~FATTR4_WORD1_MODE;
3909 ret = NFS_ATTR_FATTR_MODE;
3911 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
3914 print_overflow_msg(__func__, xdr);
3918 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
3924 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
3926 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
3927 p = xdr_inline_decode(xdr, 4);
3930 *nlink = be32_to_cpup(p);
3931 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
3932 ret = NFS_ATTR_FATTR_NLINK;
3934 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
3937 print_overflow_msg(__func__, xdr);
3941 static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
3942 struct nfs4_string *name, gfp_t gfp_flags)
3946 ret = xdr_stream_decode_string_dup(xdr, &name->data,
3947 XDR_MAX_NETOBJ, gfp_flags);
3954 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3955 const struct nfs_server *server, kuid_t *uid,
3956 struct nfs4_string *owner_name)
3961 *uid = make_kuid(&init_user_ns, -2);
3962 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3964 if (!(bitmap[1] & FATTR4_WORD1_OWNER))
3966 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3968 if (owner_name != NULL) {
3969 len = decode_nfs4_string(xdr, owner_name, GFP_NOIO);
3972 dprintk("%s: name=%s\n", __func__, owner_name->data);
3973 return NFS_ATTR_FATTR_OWNER_NAME;
3975 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
3977 if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0)
3979 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
3980 return NFS_ATTR_FATTR_OWNER;
3983 if (len != -EBADMSG)
3985 print_overflow_msg(__func__, xdr);
3989 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3990 const struct nfs_server *server, kgid_t *gid,
3991 struct nfs4_string *group_name)
3996 *gid = make_kgid(&init_user_ns, -2);
3997 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
3999 if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP))
4001 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
4003 if (group_name != NULL) {
4004 len = decode_nfs4_string(xdr, group_name, GFP_NOIO);
4007 dprintk("%s: name=%s\n", __func__, group_name->data);
4008 return NFS_ATTR_FATTR_GROUP_NAME;
4010 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
4012 if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0)
4014 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
4015 return NFS_ATTR_FATTR_GROUP;
4018 if (len != -EBADMSG)
4020 print_overflow_msg(__func__, xdr);
4024 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
4026 uint32_t major = 0, minor = 0;
4031 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
4033 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
4036 p = xdr_inline_decode(xdr, 8);
4039 major = be32_to_cpup(p++);
4040 minor = be32_to_cpup(p);
4041 tmp = MKDEV(major, minor);
4042 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
4044 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
4045 ret = NFS_ATTR_FATTR_RDEV;
4047 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
4050 print_overflow_msg(__func__, xdr);
4054 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4060 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
4062 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
4063 p = xdr_inline_decode(xdr, 8);
4066 xdr_decode_hyper(p, res);
4067 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
4069 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
4072 print_overflow_msg(__func__, xdr);
4076 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4082 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
4084 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
4085 p = xdr_inline_decode(xdr, 8);
4088 xdr_decode_hyper(p, res);
4089 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
4091 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
4094 print_overflow_msg(__func__, xdr);
4098 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4104 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
4106 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
4107 p = xdr_inline_decode(xdr, 8);
4110 xdr_decode_hyper(p, res);
4111 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
4113 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
4116 print_overflow_msg(__func__, xdr);
4120 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
4126 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
4128 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
4129 p = xdr_inline_decode(xdr, 8);
4132 xdr_decode_hyper(p, used);
4133 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
4134 ret = NFS_ATTR_FATTR_SPACE_USED;
4136 dprintk("%s: space used=%Lu\n", __func__,
4137 (unsigned long long)*used);
4140 print_overflow_msg(__func__, xdr);
4145 xdr_decode_nfstime4(__be32 *p, struct timespec *t)
4149 p = xdr_decode_hyper(p, &sec);
4150 t-> tv_sec = (time_t)sec;
4151 t->tv_nsec = be32_to_cpup(p++);
4155 static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
4159 p = xdr_inline_decode(xdr, nfstime4_maxsz << 2);
4162 xdr_decode_nfstime4(p, time);
4165 print_overflow_msg(__func__, xdr);
4169 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4175 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
4177 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
4178 status = decode_attr_time(xdr, time);
4180 status = NFS_ATTR_FATTR_ATIME;
4181 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
4183 dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
4187 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4193 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
4195 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
4196 status = decode_attr_time(xdr, time);
4198 status = NFS_ATTR_FATTR_CTIME;
4199 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
4201 dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
4205 static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
4206 struct timespec *time)
4212 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U)))
4214 if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) {
4215 status = decode_attr_time(xdr, time);
4216 bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
4218 dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec,
4219 (long)time->tv_nsec);
4223 static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
4224 struct nfs4_label *label)
4232 if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
4234 if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
4235 p = xdr_inline_decode(xdr, 4);
4238 lfs = be32_to_cpup(p++);
4239 p = xdr_inline_decode(xdr, 4);
4242 pi = be32_to_cpup(p++);
4243 p = xdr_inline_decode(xdr, 4);
4246 len = be32_to_cpup(p++);
4247 p = xdr_inline_decode(xdr, len);
4250 if (len < NFS4_MAXLABELLEN) {
4252 memcpy(label->label, p, len);
4256 status = NFS_ATTR_FATTR_V4_SECURITY_LABEL;
4258 bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
4260 printk(KERN_WARNING "%s: label too long (%u)!\n",
4263 if (label && label->label)
4264 dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__,
4265 (char *)label->label, label->len, label->pi, label->lfs);
4269 print_overflow_msg(__func__, xdr);
4273 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4279 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
4281 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
4282 status = decode_attr_time(xdr, time);
4284 status = NFS_ATTR_FATTR_MTIME;
4285 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
4287 dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
4291 static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
4293 unsigned int attrwords = XDR_QUADLEN(attrlen);
4294 unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2;
4296 if (unlikely(attrwords != nwords)) {
4297 dprintk("%s: server returned incorrect attribute length: "
4301 (attrwords < nwords) ? '<' : '>',
4308 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4312 p = xdr_inline_decode(xdr, 20);
4315 cinfo->atomic = be32_to_cpup(p++);
4316 p = xdr_decode_hyper(p, &cinfo->before);
4317 xdr_decode_hyper(p, &cinfo->after);
4320 print_overflow_msg(__func__, xdr);
4324 static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
4330 status = decode_op_hdr(xdr, OP_ACCESS);
4333 p = xdr_inline_decode(xdr, 8);
4336 supp = be32_to_cpup(p++);
4337 acc = be32_to_cpup(p);
4342 print_overflow_msg(__func__, xdr);
4346 static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
4348 ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
4349 if (unlikely(ret < 0)) {
4350 print_overflow_msg(__func__, xdr);
4356 static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4358 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4361 static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4363 stateid->type = NFS4_OPEN_STATEID_TYPE;
4364 return decode_stateid(xdr, stateid);
4367 static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4369 stateid->type = NFS4_LOCK_STATEID_TYPE;
4370 return decode_stateid(xdr, stateid);
4373 static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4375 stateid->type = NFS4_DELEGATION_STATEID_TYPE;
4376 return decode_stateid(xdr, stateid);
4379 static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4383 nfs4_stateid_copy(stateid, &invalid_stateid);
4384 return decode_stateid(xdr, &dummy);
4387 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4391 status = decode_op_hdr(xdr, OP_CLOSE);
4393 nfs_increment_open_seqid(status, res->seqid);
4395 status = decode_invalid_stateid(xdr, &res->stateid);
4399 static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4401 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4404 static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
4406 return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
4409 static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
4413 status = decode_op_hdr(xdr, OP_COMMIT);
4415 status = decode_write_verifier(xdr, &res->verf->verifier);
4419 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4425 status = decode_op_hdr(xdr, OP_CREATE);
4428 if ((status = decode_change_info(xdr, cinfo)))
4430 p = xdr_inline_decode(xdr, 4);
4433 bmlen = be32_to_cpup(p);
4434 p = xdr_inline_decode(xdr, bmlen << 2);
4438 print_overflow_msg(__func__, xdr);
4442 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
4445 uint32_t attrlen, bitmap[3] = {0};
4448 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4450 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4452 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4454 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
4456 if ((status = decode_attr_fh_expire_type(xdr, bitmap,
4457 &res->fh_expire_type)) != 0)
4459 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
4461 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
4463 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
4465 if ((status = decode_attr_exclcreat_supported(xdr, bitmap,
4466 res->exclcreat_bitmask)) != 0)
4468 status = verify_attr_len(xdr, savep, attrlen);
4470 dprintk("%s: xdr returned %d!\n", __func__, -status);
4474 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
4477 uint32_t attrlen, bitmap[3] = {0};
4480 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4482 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4484 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4487 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
4489 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
4491 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
4495 if (unlikely(bitmap[0]))
4498 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
4500 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
4502 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
4505 status = verify_attr_len(xdr, savep, attrlen);
4507 dprintk("%s: xdr returned %d!\n", __func__, -status);
4511 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
4514 uint32_t attrlen, bitmap[3] = {0};
4517 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4519 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4521 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4524 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
4526 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
4529 status = verify_attr_len(xdr, savep, attrlen);
4531 dprintk("%s: xdr returned %d!\n", __func__, -status);
4535 static int decode_threshold_hint(struct xdr_stream *xdr,
4543 if (likely(bitmap[0] & hint_bit)) {
4544 p = xdr_inline_decode(xdr, 8);
4547 xdr_decode_hyper(p, res);
4551 print_overflow_msg(__func__, xdr);
4555 static int decode_first_threshold_item4(struct xdr_stream *xdr,
4556 struct nfs4_threshold *res)
4560 uint32_t bitmap[3] = {0,}, attrlen;
4564 p = xdr_inline_decode(xdr, 4);
4566 print_overflow_msg(__func__, xdr);
4569 res->l_type = be32_to_cpup(p);
4571 /* thi_hintset bitmap */
4572 status = decode_attr_bitmap(xdr, bitmap);
4576 /* thi_hintlist length */
4577 status = decode_attr_length(xdr, &attrlen, &savep);
4581 status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD);
4584 status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR);
4587 status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz,
4591 status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz,
4596 status = verify_attr_len(xdr, savep, attrlen);
4597 res->bm = bitmap[0];
4599 dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n",
4600 __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz,
4603 dprintk("%s ret=%d!\n", __func__, status);
4608 * Thresholds on pNFS direct I/O vrs MDS I/O
4610 static int decode_attr_mdsthreshold(struct xdr_stream *xdr,
4612 struct nfs4_threshold *res)
4618 if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U)))
4620 if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) {
4621 /* Did the server return an unrequested attribute? */
4622 if (unlikely(res == NULL))
4624 p = xdr_inline_decode(xdr, 4);
4627 num = be32_to_cpup(p);
4631 printk(KERN_INFO "%s: Warning: Multiple pNFS layout "
4632 "drivers per filesystem not supported\n",
4635 status = decode_first_threshold_item4(xdr, res);
4636 bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
4640 print_overflow_msg(__func__, xdr);
4644 static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
4645 struct nfs_fattr *fattr, struct nfs_fh *fh,
4646 struct nfs4_fs_locations *fs_loc, struct nfs4_label *label,
4647 const struct nfs_server *server)
4654 status = decode_attr_type(xdr, bitmap, &type);
4659 fattr->mode |= nfs_type2fmt[type];
4660 fattr->valid |= status;
4663 status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
4666 fattr->valid |= status;
4668 status = decode_attr_size(xdr, bitmap, &fattr->size);
4671 fattr->valid |= status;
4673 status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
4676 fattr->valid |= status;
4679 status = decode_attr_error(xdr, bitmap, &err);
4683 status = decode_attr_filehandle(xdr, bitmap, fh);
4687 status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
4690 fattr->valid |= status;
4692 status = decode_attr_fs_locations(xdr, bitmap, fs_loc);
4695 fattr->valid |= status;
4698 if (unlikely(bitmap[0]))
4701 status = decode_attr_mode(xdr, bitmap, &fmode);
4705 fattr->mode |= fmode;
4706 fattr->valid |= status;
4709 status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
4712 fattr->valid |= status;
4714 status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name);
4717 fattr->valid |= status;
4719 status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name);
4722 fattr->valid |= status;
4724 status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
4727 fattr->valid |= status;
4729 status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
4732 fattr->valid |= status;
4734 status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
4737 fattr->valid |= status;
4739 status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
4742 fattr->valid |= status;
4744 status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
4747 fattr->valid |= status;
4749 status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid);
4752 fattr->valid |= status;
4755 if (unlikely(bitmap[1]))
4758 status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold);
4763 status = decode_attr_security_label(xdr, bitmap, label);
4766 fattr->valid |= status;
4770 dprintk("%s: xdr returned %d\n", __func__, -status);
4774 static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4775 struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc,
4776 struct nfs4_label *label, const struct nfs_server *server)
4783 status = decode_op_hdr(xdr, OP_GETATTR);
4787 status = decode_attr_bitmap(xdr, bitmap);
4791 status = decode_attr_length(xdr, &attrlen, &savep);
4795 status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc,
4800 status = verify_attr_len(xdr, savep, attrlen);
4802 dprintk("%s: xdr returned %d\n", __func__, -status);
4806 static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4807 struct nfs4_label *label, const struct nfs_server *server)
4809 return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server);
4812 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4813 const struct nfs_server *server)
4815 return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server);
4819 * Decode potentially multiple layout types.
4821 static int decode_pnfs_layout_types(struct xdr_stream *xdr,
4822 struct nfs_fsinfo *fsinfo)
4827 p = xdr_inline_decode(xdr, 4);
4830 fsinfo->nlayouttypes = be32_to_cpup(p);
4832 /* pNFS is not supported by the underlying file system */
4833 if (fsinfo->nlayouttypes == 0)
4836 /* Decode and set first layout type, move xdr->p past unused types */
4837 p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
4841 /* If we get too many, then just cap it at the max */
4842 if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
4843 printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n",
4844 __func__, fsinfo->nlayouttypes);
4845 fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES;
4848 for(i = 0; i < fsinfo->nlayouttypes; ++i)
4849 fsinfo->layouttype[i] = be32_to_cpup(p++);
4852 print_overflow_msg(__func__, xdr);
4857 * The type of file system exported.
4858 * Note we must ensure that layouttype is set in any non-error case.
4860 static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
4861 struct nfs_fsinfo *fsinfo)
4865 dprintk("%s: bitmap is %x\n", __func__, bitmap[1]);
4866 if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U)))
4868 if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) {
4869 status = decode_pnfs_layout_types(xdr, fsinfo);
4870 bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES;
4876 * The prefered block size for layout directed io
4878 static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4883 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4885 if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) {
4886 p = xdr_inline_decode(xdr, 4);
4888 print_overflow_msg(__func__, xdr);
4891 *res = be32_to_cpup(p);
4892 bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE;
4898 * The granularity of a CLONE operation.
4900 static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4905 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4907 if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
4908 p = xdr_inline_decode(xdr, 4);
4910 print_overflow_msg(__func__, xdr);
4913 *res = be32_to_cpup(p);
4914 bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE;
4919 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
4922 uint32_t attrlen, bitmap[3];
4925 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4927 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4929 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4932 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
4934 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
4936 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
4938 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
4940 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
4941 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
4943 fsinfo->wtpref = fsinfo->wtmax;
4946 if (unlikely(bitmap[0]))
4949 status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta);
4952 status = decode_attr_pnfstype(xdr, bitmap, fsinfo);
4957 if (unlikely(bitmap[1]))
4960 status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize);
4963 status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize);
4967 status = verify_attr_len(xdr, savep, attrlen);
4969 dprintk("%s: xdr returned %d!\n", __func__, -status);
4973 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
4979 /* Zero handle first to allow comparisons */
4980 memset(fh, 0, sizeof(*fh));
4982 status = decode_op_hdr(xdr, OP_GETFH);
4986 p = xdr_inline_decode(xdr, 4);
4989 len = be32_to_cpup(p);
4990 if (len > NFS4_FHSIZE)
4993 p = xdr_inline_decode(xdr, len);
4996 memcpy(fh->data, p, len);
4999 print_overflow_msg(__func__, xdr);
5003 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5007 status = decode_op_hdr(xdr, OP_LINK);
5010 return decode_change_info(xdr, cinfo);
5014 * We create the owner, so we know a proper owner.id length is 4.
5016 static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
5018 uint64_t offset, length, clientid;
5020 uint32_t namelen, type;
5022 p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
5025 p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
5026 p = xdr_decode_hyper(p, &length);
5027 type = be32_to_cpup(p++); /* 4 byte read */
5028 if (fl != NULL) { /* manipulate file lock */
5029 fl->fl_start = (loff_t)offset;
5030 fl->fl_end = fl->fl_start + (loff_t)length - 1;
5031 if (length == ~(uint64_t)0)
5032 fl->fl_end = OFFSET_MAX;
5033 fl->fl_type = F_WRLCK;
5035 fl->fl_type = F_RDLCK;
5038 p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
5039 namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */
5040 p = xdr_inline_decode(xdr, namelen); /* variable size field */
5042 return -NFS4ERR_DENIED;
5044 print_overflow_msg(__func__, xdr);
5048 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
5052 status = decode_op_hdr(xdr, OP_LOCK);
5056 status = decode_lock_stateid(xdr, &res->stateid);
5057 if (unlikely(status))
5059 } else if (status == -NFS4ERR_DENIED)
5060 status = decode_lock_denied(xdr, NULL);
5061 if (res->open_seqid != NULL)
5062 nfs_increment_open_seqid(status, res->open_seqid);
5063 nfs_increment_lock_seqid(status, res->lock_seqid);
5068 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
5071 status = decode_op_hdr(xdr, OP_LOCKT);
5072 if (status == -NFS4ERR_DENIED)
5073 return decode_lock_denied(xdr, res->denied);
5077 static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
5081 status = decode_op_hdr(xdr, OP_LOCKU);
5083 nfs_increment_lock_seqid(status, res->seqid);
5085 status = decode_lock_stateid(xdr, &res->stateid);
5089 static int decode_release_lockowner(struct xdr_stream *xdr)
5091 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
5094 static int decode_lookup(struct xdr_stream *xdr)
5096 return decode_op_hdr(xdr, OP_LOOKUP);
5099 static int decode_lookupp(struct xdr_stream *xdr)
5101 return decode_op_hdr(xdr, OP_LOOKUPP);
5104 /* This is too sick! */
5105 static int decode_space_limit(struct xdr_stream *xdr,
5106 unsigned long *pagemod_limit)
5109 uint32_t limit_type, nblocks, blocksize;
5112 p = xdr_inline_decode(xdr, 12);
5115 limit_type = be32_to_cpup(p++);
5116 switch (limit_type) {
5117 case NFS4_LIMIT_SIZE:
5118 xdr_decode_hyper(p, &maxsize);
5120 case NFS4_LIMIT_BLOCKS:
5121 nblocks = be32_to_cpup(p++);
5122 blocksize = be32_to_cpup(p);
5123 maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
5125 maxsize >>= PAGE_SHIFT;
5126 *pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
5129 print_overflow_msg(__func__, xdr);
5133 static int decode_rw_delegation(struct xdr_stream *xdr,
5134 uint32_t delegation_type,
5135 struct nfs_openres *res)
5140 status = decode_delegation_stateid(xdr, &res->delegation);
5141 if (unlikely(status))
5143 p = xdr_inline_decode(xdr, 4);
5146 res->do_recall = be32_to_cpup(p);
5148 switch (delegation_type) {
5149 case NFS4_OPEN_DELEGATE_READ:
5150 res->delegation_type = FMODE_READ;
5152 case NFS4_OPEN_DELEGATE_WRITE:
5153 res->delegation_type = FMODE_WRITE|FMODE_READ;
5154 if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
5157 return decode_ace(xdr, NULL);
5159 print_overflow_msg(__func__, xdr);
5163 static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5166 uint32_t why_no_delegation;
5168 p = xdr_inline_decode(xdr, 4);
5171 why_no_delegation = be32_to_cpup(p);
5172 switch (why_no_delegation) {
5173 case WND4_CONTENTION:
5175 xdr_inline_decode(xdr, 4);
5176 /* Ignore for now */
5180 print_overflow_msg(__func__, xdr);
5184 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5187 uint32_t delegation_type;
5189 p = xdr_inline_decode(xdr, 4);
5192 delegation_type = be32_to_cpup(p);
5193 res->delegation_type = 0;
5194 switch (delegation_type) {
5195 case NFS4_OPEN_DELEGATE_NONE:
5197 case NFS4_OPEN_DELEGATE_READ:
5198 case NFS4_OPEN_DELEGATE_WRITE:
5199 return decode_rw_delegation(xdr, delegation_type, res);
5200 case NFS4_OPEN_DELEGATE_NONE_EXT:
5201 return decode_no_delegation(xdr, res);
5205 print_overflow_msg(__func__, xdr);
5209 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
5212 uint32_t savewords, bmlen, i;
5215 if (!__decode_op_hdr(xdr, OP_OPEN, &status))
5217 nfs_increment_open_seqid(status, res->seqid);
5220 status = decode_open_stateid(xdr, &res->stateid);
5221 if (unlikely(status))
5224 decode_change_info(xdr, &res->cinfo);
5226 p = xdr_inline_decode(xdr, 8);
5229 res->rflags = be32_to_cpup(p++);
5230 bmlen = be32_to_cpup(p);
5234 p = xdr_inline_decode(xdr, bmlen << 2);
5237 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
5238 for (i = 0; i < savewords; ++i)
5239 res->attrset[i] = be32_to_cpup(p++);
5240 for (; i < NFS4_BITMAP_SIZE; i++)
5241 res->attrset[i] = 0;
5243 return decode_delegation(xdr, res);
5245 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
5248 print_overflow_msg(__func__, xdr);
5252 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
5256 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
5258 nfs_increment_open_seqid(status, res->seqid);
5260 status = decode_open_stateid(xdr, &res->stateid);
5264 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
5268 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
5270 nfs_increment_open_seqid(status, res->seqid);
5272 status = decode_open_stateid(xdr, &res->stateid);
5276 static int decode_putfh(struct xdr_stream *xdr)
5278 return decode_op_hdr(xdr, OP_PUTFH);
5281 static int decode_putrootfh(struct xdr_stream *xdr)
5283 return decode_op_hdr(xdr, OP_PUTROOTFH);
5286 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req,
5287 struct nfs_pgio_res *res)
5290 uint32_t count, eof, recvd;
5293 status = decode_op_hdr(xdr, OP_READ);
5296 p = xdr_inline_decode(xdr, 8);
5299 eof = be32_to_cpup(p++);
5300 count = be32_to_cpup(p);
5301 recvd = xdr_read_pages(xdr, count);
5302 if (count > recvd) {
5303 dprintk("NFS: server cheating in read reply: "
5304 "count %u > recvd %u\n", count, recvd);
5312 print_overflow_msg(__func__, xdr);
5316 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
5321 status = decode_op_hdr(xdr, OP_READDIR);
5323 status = decode_verifier(xdr, readdir->verifier.data);
5324 if (unlikely(status))
5326 memcpy(verf, readdir->verifier.data, sizeof(verf));
5327 dprintk("%s: verifier = %08x:%08x\n",
5328 __func__, verf[0], verf[1]);
5329 return xdr_read_pages(xdr, xdr->buf->page_len);
5332 static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
5334 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
5339 status = decode_op_hdr(xdr, OP_READLINK);
5343 /* Convert length of symlink */
5344 p = xdr_inline_decode(xdr, 4);
5347 len = be32_to_cpup(p);
5348 if (len >= rcvbuf->page_len || len <= 0) {
5349 dprintk("nfs: server returned giant symlink!\n");
5350 return -ENAMETOOLONG;
5352 recvd = xdr_read_pages(xdr, len);
5354 dprintk("NFS: server cheating in readlink reply: "
5355 "count %u > recvd %u\n", len, recvd);
5359 * The XDR encode routine has set things up so that
5360 * the link text will be copied directly into the
5361 * buffer. We just have to do overflow-checking,
5362 * and and null-terminate the text (the VFS expects
5363 * null-termination).
5365 xdr_terminate_string(rcvbuf, len);
5368 print_overflow_msg(__func__, xdr);
5372 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5376 status = decode_op_hdr(xdr, OP_REMOVE);
5379 status = decode_change_info(xdr, cinfo);
5384 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
5385 struct nfs4_change_info *new_cinfo)
5389 status = decode_op_hdr(xdr, OP_RENAME);
5392 if ((status = decode_change_info(xdr, old_cinfo)))
5394 status = decode_change_info(xdr, new_cinfo);
5399 static int decode_renew(struct xdr_stream *xdr)
5401 return decode_op_hdr(xdr, OP_RENEW);
5405 decode_restorefh(struct xdr_stream *xdr)
5407 return decode_op_hdr(xdr, OP_RESTOREFH);
5410 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
5411 struct nfs_getaclres *res)
5417 unsigned int pg_offset;
5420 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
5423 xdr_enter_page(xdr, xdr->buf->page_len);
5425 /* Calculate the offset of the page data */
5426 pg_offset = xdr->buf->head[0].iov_len;
5428 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
5430 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
5433 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
5435 if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
5437 /* The bitmap (xdr len + bitmaps) and the attr xdr len words
5438 * are stored with the acl data to handle the problem of
5439 * variable length bitmaps.*/
5440 res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset;
5441 res->acl_len = attrlen;
5443 /* Check for receive buffer overflow */
5444 if (res->acl_len > (xdr->nwords << 2) ||
5445 res->acl_len + res->acl_data_offset > xdr->buf->page_len) {
5446 res->acl_flags |= NFS4_ACL_TRUNC;
5447 dprintk("NFS: acl reply: attrlen %u > page_len %u\n",
5448 attrlen, xdr->nwords << 2);
5451 status = -EOPNOTSUPP;
5458 decode_savefh(struct xdr_stream *xdr)
5460 return decode_op_hdr(xdr, OP_SAVEFH);
5463 static int decode_setattr(struct xdr_stream *xdr)
5467 status = decode_op_hdr(xdr, OP_SETATTR);
5470 if (decode_bitmap4(xdr, NULL, 0) >= 0)
5472 print_overflow_msg(__func__, xdr);
5476 static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
5482 p = xdr_inline_decode(xdr, 8);
5485 opnum = be32_to_cpup(p++);
5486 if (opnum != OP_SETCLIENTID) {
5487 dprintk("nfs: decode_setclientid: Server returned operation"
5491 nfserr = be32_to_cpup(p);
5492 if (nfserr == NFS_OK) {
5493 p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
5496 p = xdr_decode_hyper(p, &res->clientid);
5497 memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
5498 } else if (nfserr == NFSERR_CLID_INUSE) {
5501 /* skip netid string */
5502 p = xdr_inline_decode(xdr, 4);
5505 len = be32_to_cpup(p);
5506 p = xdr_inline_decode(xdr, len);
5510 /* skip uaddr string */
5511 p = xdr_inline_decode(xdr, 4);
5514 len = be32_to_cpup(p);
5515 p = xdr_inline_decode(xdr, len);
5518 return -NFSERR_CLID_INUSE;
5520 return nfs4_stat_to_errno(nfserr);
5524 print_overflow_msg(__func__, xdr);
5528 static int decode_setclientid_confirm(struct xdr_stream *xdr)
5530 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
5533 static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res)
5538 status = decode_op_hdr(xdr, OP_WRITE);
5542 p = xdr_inline_decode(xdr, 8);
5545 res->count = be32_to_cpup(p++);
5546 res->verf->committed = be32_to_cpup(p++);
5547 return decode_write_verifier(xdr, &res->verf->verifier);
5549 print_overflow_msg(__func__, xdr);
5553 static int decode_delegreturn(struct xdr_stream *xdr)
5555 return decode_op_hdr(xdr, OP_DELEGRETURN);
5558 static int decode_secinfo_gss(struct xdr_stream *xdr,
5559 struct nfs4_secinfo4 *flavor)
5564 p = xdr_inline_decode(xdr, 4);
5567 oid_len = be32_to_cpup(p);
5568 if (oid_len > GSS_OID_MAX_LEN)
5571 p = xdr_inline_decode(xdr, oid_len);
5574 memcpy(flavor->flavor_info.oid.data, p, oid_len);
5575 flavor->flavor_info.oid.len = oid_len;
5577 p = xdr_inline_decode(xdr, 8);
5580 flavor->flavor_info.qop = be32_to_cpup(p++);
5581 flavor->flavor_info.service = be32_to_cpup(p);
5586 print_overflow_msg(__func__, xdr);
5592 static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5594 struct nfs4_secinfo4 *sec_flavor;
5595 unsigned int i, num_flavors;
5599 p = xdr_inline_decode(xdr, 4);
5603 res->flavors->num_flavors = 0;
5604 num_flavors = be32_to_cpup(p);
5606 for (i = 0; i < num_flavors; i++) {
5607 sec_flavor = &res->flavors->flavors[i];
5608 if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE)
5611 p = xdr_inline_decode(xdr, 4);
5614 sec_flavor->flavor = be32_to_cpup(p);
5616 if (sec_flavor->flavor == RPC_AUTH_GSS) {
5617 status = decode_secinfo_gss(xdr, sec_flavor);
5621 res->flavors->num_flavors++;
5628 print_overflow_msg(__func__, xdr);
5632 static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5634 int status = decode_op_hdr(xdr, OP_SECINFO);
5637 return decode_secinfo_common(xdr, res);
5640 #if defined(CONFIG_NFS_V4_1)
5641 static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5643 int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME);
5646 return decode_secinfo_common(xdr, res);
5649 static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map)
5652 uint32_t bitmap_words;
5655 p = xdr_inline_decode(xdr, 4);
5658 bitmap_words = be32_to_cpup(p++);
5659 if (bitmap_words > NFS4_OP_MAP_NUM_WORDS)
5661 p = xdr_inline_decode(xdr, 4 * bitmap_words);
5662 for (i = 0; i < bitmap_words; i++)
5663 op_map->u.words[i] = be32_to_cpup(p++);
5668 static int decode_exchange_id(struct xdr_stream *xdr,
5669 struct nfs41_exchange_id_res *res)
5675 uint32_t impl_id_count;
5677 status = decode_op_hdr(xdr, OP_EXCHANGE_ID);
5681 p = xdr_inline_decode(xdr, 8);
5684 xdr_decode_hyper(p, &res->clientid);
5685 p = xdr_inline_decode(xdr, 12);
5688 res->seqid = be32_to_cpup(p++);
5689 res->flags = be32_to_cpup(p++);
5691 res->state_protect.how = be32_to_cpup(p);
5692 switch (res->state_protect.how) {
5696 status = decode_op_map(xdr, &res->state_protect.enforce);
5699 status = decode_op_map(xdr, &res->state_protect.allow);
5708 /* server_owner4.so_minor_id */
5709 p = xdr_inline_decode(xdr, 8);
5712 p = xdr_decode_hyper(p, &res->server_owner->minor_id);
5714 /* server_owner4.so_major_id */
5715 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5716 if (unlikely(status))
5718 memcpy(res->server_owner->major_id, dummy_str, dummy);
5719 res->server_owner->major_id_sz = dummy;
5722 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5723 if (unlikely(status))
5725 memcpy(res->server_scope->server_scope, dummy_str, dummy);
5726 res->server_scope->server_scope_sz = dummy;
5728 /* Implementation Id */
5729 p = xdr_inline_decode(xdr, 4);
5732 impl_id_count = be32_to_cpup(p++);
5734 if (impl_id_count) {
5736 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5737 if (unlikely(status))
5739 memcpy(res->impl_id->domain, dummy_str, dummy);
5742 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5743 if (unlikely(status))
5745 memcpy(res->impl_id->name, dummy_str, dummy);
5748 p = xdr_inline_decode(xdr, 12);
5751 p = xdr_decode_hyper(p, &res->impl_id->date.seconds);
5752 res->impl_id->date.nseconds = be32_to_cpup(p);
5754 /* if there's more than one entry, ignore the rest */
5758 print_overflow_msg(__func__, xdr);
5762 static int decode_chan_attrs(struct xdr_stream *xdr,
5763 struct nfs4_channel_attrs *attrs)
5768 p = xdr_inline_decode(xdr, 28);
5771 val = be32_to_cpup(p++); /* headerpadsz */
5773 return -EINVAL; /* no support for header padding yet */
5774 attrs->max_rqst_sz = be32_to_cpup(p++);
5775 attrs->max_resp_sz = be32_to_cpup(p++);
5776 attrs->max_resp_sz_cached = be32_to_cpup(p++);
5777 attrs->max_ops = be32_to_cpup(p++);
5778 attrs->max_reqs = be32_to_cpup(p++);
5779 nr_attrs = be32_to_cpup(p);
5780 if (unlikely(nr_attrs > 1)) {
5781 printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs "
5782 "count %u\n", __func__, nr_attrs);
5785 if (nr_attrs == 1) {
5786 p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
5792 print_overflow_msg(__func__, xdr);
5796 static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
5798 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
5801 static int decode_bind_conn_to_session(struct xdr_stream *xdr,
5802 struct nfs41_bind_conn_to_session_res *res)
5807 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
5809 status = decode_sessionid(xdr, &res->sessionid);
5810 if (unlikely(status))
5813 /* dir flags, rdma mode bool */
5814 p = xdr_inline_decode(xdr, 8);
5818 res->dir = be32_to_cpup(p++);
5819 if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
5821 if (be32_to_cpup(p) == 0)
5822 res->use_conn_in_rdma_mode = false;
5824 res->use_conn_in_rdma_mode = true;
5828 print_overflow_msg(__func__, xdr);
5832 static int decode_create_session(struct xdr_stream *xdr,
5833 struct nfs41_create_session_res *res)
5838 status = decode_op_hdr(xdr, OP_CREATE_SESSION);
5840 status = decode_sessionid(xdr, &res->sessionid);
5841 if (unlikely(status))
5845 p = xdr_inline_decode(xdr, 8);
5848 res->seqid = be32_to_cpup(p++);
5849 res->flags = be32_to_cpup(p);
5851 /* Channel attributes */
5852 status = decode_chan_attrs(xdr, &res->fc_attrs);
5854 status = decode_chan_attrs(xdr, &res->bc_attrs);
5857 print_overflow_msg(__func__, xdr);
5861 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
5863 return decode_op_hdr(xdr, OP_DESTROY_SESSION);
5866 static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy)
5868 return decode_op_hdr(xdr, OP_DESTROY_CLIENTID);
5871 static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
5873 return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
5875 #endif /* CONFIG_NFS_V4_1 */
5877 static int decode_sequence(struct xdr_stream *xdr,
5878 struct nfs4_sequence_res *res,
5879 struct rpc_rqst *rqstp)
5881 #if defined(CONFIG_NFS_V4_1)
5882 struct nfs4_session *session;
5883 struct nfs4_sessionid id;
5888 if (res->sr_slot == NULL)
5890 if (!res->sr_slot->table->session)
5893 status = decode_op_hdr(xdr, OP_SEQUENCE);
5895 status = decode_sessionid(xdr, &id);
5896 if (unlikely(status))
5900 * If the server returns different values for sessionID, slotID or
5901 * sequence number, the server is looney tunes.
5903 status = -EREMOTEIO;
5904 session = res->sr_slot->table->session;
5906 if (memcmp(id.data, session->sess_id.data,
5907 NFS4_MAX_SESSIONID_LEN)) {
5908 dprintk("%s Invalid session id\n", __func__);
5912 p = xdr_inline_decode(xdr, 20);
5917 dummy = be32_to_cpup(p++);
5918 if (dummy != res->sr_slot->seq_nr) {
5919 dprintk("%s Invalid sequence number\n", __func__);
5923 dummy = be32_to_cpup(p++);
5924 if (dummy != res->sr_slot->slot_nr) {
5925 dprintk("%s Invalid slot id\n", __func__);
5928 /* highest slot id */
5929 res->sr_highest_slotid = be32_to_cpup(p++);
5930 /* target highest slot id */
5931 res->sr_target_highest_slotid = be32_to_cpup(p++);
5933 res->sr_status_flags = be32_to_cpup(p);
5936 res->sr_status = status;
5939 print_overflow_msg(__func__, xdr);
5942 #else /* CONFIG_NFS_V4_1 */
5944 #endif /* CONFIG_NFS_V4_1 */
5947 #if defined(CONFIG_NFS_V4_1)
5948 static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
5950 stateid->type = NFS4_LAYOUT_STATEID_TYPE;
5951 return decode_stateid(xdr, stateid);
5954 static int decode_getdeviceinfo(struct xdr_stream *xdr,
5955 struct nfs4_getdeviceinfo_res *res)
5957 struct pnfs_device *pdev = res->pdev;
5962 status = decode_op_hdr(xdr, OP_GETDEVICEINFO);
5964 if (status == -ETOOSMALL) {
5965 p = xdr_inline_decode(xdr, 4);
5968 pdev->mincount = be32_to_cpup(p);
5969 dprintk("%s: Min count too small. mincnt = %u\n",
5970 __func__, pdev->mincount);
5975 p = xdr_inline_decode(xdr, 8);
5978 type = be32_to_cpup(p++);
5979 if (type != pdev->layout_type) {
5980 dprintk("%s: layout mismatch req: %u pdev: %u\n",
5981 __func__, pdev->layout_type, type);
5985 * Get the length of the opaque device_addr4. xdr_read_pages places
5986 * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages)
5987 * and places the remaining xdr data in xdr_buf->tail
5989 pdev->mincount = be32_to_cpup(p);
5990 if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount)
5993 /* Parse notification bitmap, verifying that it is zero. */
5994 p = xdr_inline_decode(xdr, 4);
5997 len = be32_to_cpup(p);
6001 p = xdr_inline_decode(xdr, 4 * len);
6005 res->notification = be32_to_cpup(p++);
6006 for (i = 1; i < len; i++) {
6007 if (be32_to_cpup(p++)) {
6008 dprintk("%s: unsupported notification\n",
6016 print_overflow_msg(__func__, xdr);
6020 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
6021 struct nfs4_layoutget_res *res)
6028 status = decode_op_hdr(xdr, OP_LAYOUTGET);
6031 p = xdr_inline_decode(xdr, 4);
6034 res->return_on_close = be32_to_cpup(p);
6035 decode_layout_stateid(xdr, &res->stateid);
6036 p = xdr_inline_decode(xdr, 4);
6039 layout_count = be32_to_cpup(p);
6040 if (!layout_count) {
6041 dprintk("%s: server responded with empty layout array\n",
6046 p = xdr_inline_decode(xdr, 28);
6049 p = xdr_decode_hyper(p, &res->range.offset);
6050 p = xdr_decode_hyper(p, &res->range.length);
6051 res->range.iomode = be32_to_cpup(p++);
6052 res->type = be32_to_cpup(p++);
6053 res->layoutp->len = be32_to_cpup(p);
6055 dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n",
6057 (unsigned long)res->range.offset,
6058 (unsigned long)res->range.length,
6063 recvd = xdr_read_pages(xdr, res->layoutp->len);
6064 if (res->layoutp->len > recvd) {
6065 dprintk("NFS: server cheating in layoutget reply: "
6066 "layout len %u > recvd %u\n",
6067 res->layoutp->len, recvd);
6071 if (layout_count > 1) {
6072 /* We only handle a length one array at the moment. Any
6073 * further entries are just ignored. Note that this means
6074 * the client may see a response that is less than the
6075 * minimum it requested.
6077 dprintk("%s: server responded with %d layouts, dropping tail\n",
6078 __func__, layout_count);
6083 print_overflow_msg(__func__, xdr);
6087 static int decode_layoutreturn(struct xdr_stream *xdr,
6088 struct nfs4_layoutreturn_res *res)
6093 status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
6096 p = xdr_inline_decode(xdr, 4);
6099 res->lrs_present = be32_to_cpup(p);
6100 if (res->lrs_present)
6101 status = decode_layout_stateid(xdr, &res->stateid);
6103 nfs4_stateid_copy(&res->stateid, &invalid_stateid);
6106 print_overflow_msg(__func__, xdr);
6110 static int decode_layoutcommit(struct xdr_stream *xdr,
6111 struct rpc_rqst *req,
6112 struct nfs4_layoutcommit_res *res)
6118 status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT);
6119 res->status = status;
6123 p = xdr_inline_decode(xdr, 4);
6126 sizechanged = be32_to_cpup(p);
6129 /* throw away new size */
6130 p = xdr_inline_decode(xdr, 8);
6136 print_overflow_msg(__func__, xdr);
6140 static int decode_test_stateid(struct xdr_stream *xdr,
6141 struct nfs41_test_stateid_res *res)
6147 status = decode_op_hdr(xdr, OP_TEST_STATEID);
6151 p = xdr_inline_decode(xdr, 4);
6154 num_res = be32_to_cpup(p++);
6158 p = xdr_inline_decode(xdr, 4);
6161 res->status = be32_to_cpup(p++);
6165 print_overflow_msg(__func__, xdr);
6170 static int decode_free_stateid(struct xdr_stream *xdr,
6171 struct nfs41_free_stateid_res *res)
6173 res->status = decode_op_hdr(xdr, OP_FREE_STATEID);
6178 int decode_layoutreturn(struct xdr_stream *xdr,
6179 struct nfs4_layoutreturn_res *res)
6183 #endif /* CONFIG_NFS_V4_1 */
6186 * END OF "GENERIC" DECODE ROUTINES.
6190 * Decode OPEN_DOWNGRADE response
6192 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp,
6193 struct xdr_stream *xdr,
6196 struct nfs_closeres *res = data;
6197 struct compound_hdr hdr;
6200 status = decode_compound_hdr(xdr, &hdr);
6203 status = decode_sequence(xdr, &res->seq_res, rqstp);
6206 status = decode_putfh(xdr);
6210 status = decode_layoutreturn(xdr, res->lr_res);
6211 res->lr_ret = status;
6215 status = decode_open_downgrade(xdr, res);
6221 * Decode ACCESS response
6223 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6226 struct nfs4_accessres *res = data;
6227 struct compound_hdr hdr;
6230 status = decode_compound_hdr(xdr, &hdr);
6233 status = decode_sequence(xdr, &res->seq_res, rqstp);
6236 status = decode_putfh(xdr);
6239 status = decode_access(xdr, &res->supported, &res->access);
6243 decode_getfattr(xdr, res->fattr, res->server);
6249 * Decode LOOKUP response
6251 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6254 struct nfs4_lookup_res *res = data;
6255 struct compound_hdr hdr;
6258 status = decode_compound_hdr(xdr, &hdr);
6261 status = decode_sequence(xdr, &res->seq_res, rqstp);
6264 status = decode_putfh(xdr);
6267 status = decode_lookup(xdr);
6270 status = decode_getfh(xdr, res->fh);
6273 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6279 * Decode LOOKUPP response
6281 static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6284 struct nfs4_lookupp_res *res = data;
6285 struct compound_hdr hdr;
6288 status = decode_compound_hdr(xdr, &hdr);
6291 status = decode_sequence(xdr, &res->seq_res, rqstp);
6294 status = decode_putfh(xdr);
6297 status = decode_lookupp(xdr);
6300 status = decode_getfh(xdr, res->fh);
6303 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6309 * Decode LOOKUP_ROOT response
6311 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp,
6312 struct xdr_stream *xdr,
6315 struct nfs4_lookup_res *res = data;
6316 struct compound_hdr hdr;
6319 status = decode_compound_hdr(xdr, &hdr);
6322 status = decode_sequence(xdr, &res->seq_res, rqstp);
6325 status = decode_putrootfh(xdr);
6328 status = decode_getfh(xdr, res->fh);
6330 status = decode_getfattr_label(xdr, res->fattr,
6331 res->label, res->server);
6337 * Decode REMOVE response
6339 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6342 struct nfs_removeres *res = data;
6343 struct compound_hdr hdr;
6346 status = decode_compound_hdr(xdr, &hdr);
6349 status = decode_sequence(xdr, &res->seq_res, rqstp);
6352 status = decode_putfh(xdr);
6355 status = decode_remove(xdr, &res->cinfo);
6361 * Decode RENAME response
6363 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6366 struct nfs_renameres *res = data;
6367 struct compound_hdr hdr;
6370 status = decode_compound_hdr(xdr, &hdr);
6373 status = decode_sequence(xdr, &res->seq_res, rqstp);
6376 status = decode_putfh(xdr);
6379 status = decode_savefh(xdr);
6382 status = decode_putfh(xdr);
6385 status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo);
6391 * Decode LINK response
6393 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6396 struct nfs4_link_res *res = data;
6397 struct compound_hdr hdr;
6400 status = decode_compound_hdr(xdr, &hdr);
6403 status = decode_sequence(xdr, &res->seq_res, rqstp);
6406 status = decode_putfh(xdr);
6409 status = decode_savefh(xdr);
6412 status = decode_putfh(xdr);
6415 status = decode_link(xdr, &res->cinfo);
6419 * Note order: OP_LINK leaves the directory as the current
6422 status = decode_restorefh(xdr);
6425 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6431 * Decode CREATE response
6433 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6436 struct nfs4_create_res *res = data;
6437 struct compound_hdr hdr;
6440 status = decode_compound_hdr(xdr, &hdr);
6443 status = decode_sequence(xdr, &res->seq_res, rqstp);
6446 status = decode_putfh(xdr);
6449 status = decode_create(xdr, &res->dir_cinfo);
6452 status = decode_getfh(xdr, res->fh);
6455 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6461 * Decode SYMLINK response
6463 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6466 return nfs4_xdr_dec_create(rqstp, xdr, res);
6470 * Decode GETATTR response
6472 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6475 struct nfs4_getattr_res *res = data;
6476 struct compound_hdr hdr;
6479 status = decode_compound_hdr(xdr, &hdr);
6482 status = decode_sequence(xdr, &res->seq_res, rqstp);
6485 status = decode_putfh(xdr);
6488 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6494 * Encode an SETACL request
6496 static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr,
6499 const struct nfs_setaclargs *args = data;
6500 struct compound_hdr hdr = {
6501 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
6504 encode_compound_hdr(xdr, req, &hdr);
6505 encode_sequence(xdr, &args->seq_args, &hdr);
6506 encode_putfh(xdr, args->fh, &hdr);
6507 encode_setacl(xdr, args, &hdr);
6512 * Decode SETACL response
6515 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6518 struct nfs_setaclres *res = data;
6519 struct compound_hdr hdr;
6522 status = decode_compound_hdr(xdr, &hdr);
6525 status = decode_sequence(xdr, &res->seq_res, rqstp);
6528 status = decode_putfh(xdr);
6531 status = decode_setattr(xdr);
6537 * Decode GETACL response
6540 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6543 struct nfs_getaclres *res = data;
6544 struct compound_hdr hdr;
6547 if (res->acl_scratch != NULL) {
6548 void *p = page_address(res->acl_scratch);
6549 xdr_set_scratch_buffer(xdr, p, PAGE_SIZE);
6551 status = decode_compound_hdr(xdr, &hdr);
6554 status = decode_sequence(xdr, &res->seq_res, rqstp);
6557 status = decode_putfh(xdr);
6560 status = decode_getacl(xdr, rqstp, res);
6567 * Decode CLOSE response
6569 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6572 struct nfs_closeres *res = data;
6573 struct compound_hdr hdr;
6576 status = decode_compound_hdr(xdr, &hdr);
6579 status = decode_sequence(xdr, &res->seq_res, rqstp);
6582 status = decode_putfh(xdr);
6586 status = decode_layoutreturn(xdr, res->lr_res);
6587 res->lr_ret = status;
6591 if (res->fattr != NULL) {
6592 status = decode_getfattr(xdr, res->fattr, res->server);
6596 status = decode_close(xdr, res);
6602 * Decode OPEN response
6604 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6607 struct nfs_openres *res = data;
6608 struct compound_hdr hdr;
6611 status = decode_compound_hdr(xdr, &hdr);
6614 status = decode_sequence(xdr, &res->seq_res, rqstp);
6617 status = decode_putfh(xdr);
6620 status = decode_open(xdr, res);
6623 status = decode_getfh(xdr, &res->fh);
6626 if (res->access_request)
6627 decode_access(xdr, &res->access_supported, &res->access_result);
6628 decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server);
6634 * Decode OPEN_CONFIRM response
6636 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp,
6637 struct xdr_stream *xdr,
6640 struct nfs_open_confirmres *res = data;
6641 struct compound_hdr hdr;
6644 status = decode_compound_hdr(xdr, &hdr);
6647 status = decode_putfh(xdr);
6650 status = decode_open_confirm(xdr, res);
6656 * Decode OPEN response
6658 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp,
6659 struct xdr_stream *xdr,
6662 struct nfs_openres *res = data;
6663 struct compound_hdr hdr;
6666 status = decode_compound_hdr(xdr, &hdr);
6669 status = decode_sequence(xdr, &res->seq_res, rqstp);
6672 status = decode_putfh(xdr);
6675 status = decode_open(xdr, res);
6678 if (res->access_request)
6679 decode_access(xdr, &res->access_supported, &res->access_result);
6680 decode_getfattr(xdr, res->f_attr, res->server);
6686 * Decode SETATTR response
6688 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp,
6689 struct xdr_stream *xdr,
6692 struct nfs_setattrres *res = data;
6693 struct compound_hdr hdr;
6696 status = decode_compound_hdr(xdr, &hdr);
6699 status = decode_sequence(xdr, &res->seq_res, rqstp);
6702 status = decode_putfh(xdr);
6705 status = decode_setattr(xdr);
6708 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6714 * Decode LOCK response
6716 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6719 struct nfs_lock_res *res = data;
6720 struct compound_hdr hdr;
6723 status = decode_compound_hdr(xdr, &hdr);
6726 status = decode_sequence(xdr, &res->seq_res, rqstp);
6729 status = decode_putfh(xdr);
6732 status = decode_lock(xdr, res);
6738 * Decode LOCKT response
6740 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6743 struct nfs_lockt_res *res = data;
6744 struct compound_hdr hdr;
6747 status = decode_compound_hdr(xdr, &hdr);
6750 status = decode_sequence(xdr, &res->seq_res, rqstp);
6753 status = decode_putfh(xdr);
6756 status = decode_lockt(xdr, res);
6762 * Decode LOCKU response
6764 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6767 struct nfs_locku_res *res = data;
6768 struct compound_hdr hdr;
6771 status = decode_compound_hdr(xdr, &hdr);
6774 status = decode_sequence(xdr, &res->seq_res, rqstp);
6777 status = decode_putfh(xdr);
6780 status = decode_locku(xdr, res);
6785 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
6786 struct xdr_stream *xdr, void *dummy)
6788 struct compound_hdr hdr;
6791 status = decode_compound_hdr(xdr, &hdr);
6793 status = decode_release_lockowner(xdr);
6798 * Decode READLINK response
6800 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp,
6801 struct xdr_stream *xdr,
6804 struct nfs4_readlink_res *res = data;
6805 struct compound_hdr hdr;
6808 status = decode_compound_hdr(xdr, &hdr);
6811 status = decode_sequence(xdr, &res->seq_res, rqstp);
6814 status = decode_putfh(xdr);
6817 status = decode_readlink(xdr, rqstp);
6823 * Decode READDIR response
6825 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6828 struct nfs4_readdir_res *res = data;
6829 struct compound_hdr hdr;
6832 status = decode_compound_hdr(xdr, &hdr);
6835 status = decode_sequence(xdr, &res->seq_res, rqstp);
6838 status = decode_putfh(xdr);
6841 status = decode_readdir(xdr, rqstp, res);
6847 * Decode Read response
6849 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6852 struct nfs_pgio_res *res = data;
6853 struct compound_hdr hdr;
6856 status = decode_compound_hdr(xdr, &hdr);
6857 res->op_status = hdr.status;
6860 status = decode_sequence(xdr, &res->seq_res, rqstp);
6863 status = decode_putfh(xdr);
6866 status = decode_read(xdr, rqstp, res);
6868 status = res->count;
6874 * Decode WRITE response
6876 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6879 struct nfs_pgio_res *res = data;
6880 struct compound_hdr hdr;
6883 status = decode_compound_hdr(xdr, &hdr);
6884 res->op_status = hdr.status;
6887 status = decode_sequence(xdr, &res->seq_res, rqstp);
6890 status = decode_putfh(xdr);
6893 status = decode_write(xdr, res);
6897 decode_getfattr(xdr, res->fattr, res->server);
6899 status = res->count;
6905 * Decode COMMIT response
6907 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6910 struct nfs_commitres *res = data;
6911 struct compound_hdr hdr;
6914 status = decode_compound_hdr(xdr, &hdr);
6915 res->op_status = hdr.status;
6918 status = decode_sequence(xdr, &res->seq_res, rqstp);
6921 status = decode_putfh(xdr);
6924 status = decode_commit(xdr, res);
6930 * Decode FSINFO response
6932 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
6935 struct nfs4_fsinfo_res *res = data;
6936 struct compound_hdr hdr;
6939 status = decode_compound_hdr(xdr, &hdr);
6941 status = decode_sequence(xdr, &res->seq_res, req);
6943 status = decode_putfh(xdr);
6945 status = decode_fsinfo(xdr, res->fsinfo);
6950 * Decode PATHCONF response
6952 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
6955 struct nfs4_pathconf_res *res = data;
6956 struct compound_hdr hdr;
6959 status = decode_compound_hdr(xdr, &hdr);
6961 status = decode_sequence(xdr, &res->seq_res, req);
6963 status = decode_putfh(xdr);
6965 status = decode_pathconf(xdr, res->pathconf);
6970 * Decode STATFS response
6972 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
6975 struct nfs4_statfs_res *res = data;
6976 struct compound_hdr hdr;
6979 status = decode_compound_hdr(xdr, &hdr);
6981 status = decode_sequence(xdr, &res->seq_res, req);
6983 status = decode_putfh(xdr);
6985 status = decode_statfs(xdr, res->fsstat);
6990 * Decode GETATTR_BITMAP response
6992 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req,
6993 struct xdr_stream *xdr,
6996 struct nfs4_server_caps_res *res = data;
6997 struct compound_hdr hdr;
7000 status = decode_compound_hdr(xdr, &hdr);
7003 status = decode_sequence(xdr, &res->seq_res, req);
7006 status = decode_putfh(xdr);
7009 status = decode_server_caps(xdr, res);
7015 * Decode RENEW response
7017 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
7020 struct compound_hdr hdr;
7023 status = decode_compound_hdr(xdr, &hdr);
7025 status = decode_renew(xdr);
7030 * Decode SETCLIENTID response
7032 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req,
7033 struct xdr_stream *xdr,
7036 struct nfs4_setclientid_res *res = data;
7037 struct compound_hdr hdr;
7040 status = decode_compound_hdr(xdr, &hdr);
7042 status = decode_setclientid(xdr, res);
7047 * Decode SETCLIENTID_CONFIRM response
7049 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
7050 struct xdr_stream *xdr,
7053 struct compound_hdr hdr;
7056 status = decode_compound_hdr(xdr, &hdr);
7058 status = decode_setclientid_confirm(xdr);
7063 * Decode DELEGRETURN response
7065 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp,
7066 struct xdr_stream *xdr,
7069 struct nfs4_delegreturnres *res = data;
7070 struct compound_hdr hdr;
7073 status = decode_compound_hdr(xdr, &hdr);
7076 status = decode_sequence(xdr, &res->seq_res, rqstp);
7079 status = decode_putfh(xdr);
7083 status = decode_layoutreturn(xdr, res->lr_res);
7084 res->lr_ret = status;
7089 status = decode_getfattr(xdr, res->fattr, res->server);
7093 status = decode_delegreturn(xdr);
7099 * Decode FS_LOCATIONS response
7101 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req,
7102 struct xdr_stream *xdr,
7105 struct nfs4_fs_locations_res *res = data;
7106 struct compound_hdr hdr;
7109 status = decode_compound_hdr(xdr, &hdr);
7112 status = decode_sequence(xdr, &res->seq_res, req);
7115 status = decode_putfh(xdr);
7118 if (res->migration) {
7119 xdr_enter_page(xdr, PAGE_SIZE);
7120 status = decode_getfattr_generic(xdr,
7121 &res->fs_locations->fattr,
7122 NULL, res->fs_locations,
7123 NULL, res->fs_locations->server);
7127 status = decode_renew(xdr);
7129 status = decode_lookup(xdr);
7132 xdr_enter_page(xdr, PAGE_SIZE);
7133 status = decode_getfattr_generic(xdr,
7134 &res->fs_locations->fattr,
7135 NULL, res->fs_locations,
7136 NULL, res->fs_locations->server);
7143 * Decode SECINFO response
7145 static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp,
7146 struct xdr_stream *xdr,
7149 struct nfs4_secinfo_res *res = data;
7150 struct compound_hdr hdr;
7153 status = decode_compound_hdr(xdr, &hdr);
7156 status = decode_sequence(xdr, &res->seq_res, rqstp);
7159 status = decode_putfh(xdr);
7162 status = decode_secinfo(xdr, res);
7168 * Decode FSID_PRESENT response
7170 static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp,
7171 struct xdr_stream *xdr,
7174 struct nfs4_fsid_present_res *res = data;
7175 struct compound_hdr hdr;
7178 status = decode_compound_hdr(xdr, &hdr);
7181 status = decode_sequence(xdr, &res->seq_res, rqstp);
7184 status = decode_putfh(xdr);
7187 status = decode_getfh(xdr, res->fh);
7191 status = decode_renew(xdr);
7196 #if defined(CONFIG_NFS_V4_1)
7198 * Decode BIND_CONN_TO_SESSION response
7200 static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp,
7201 struct xdr_stream *xdr,
7204 struct compound_hdr hdr;
7207 status = decode_compound_hdr(xdr, &hdr);
7209 status = decode_bind_conn_to_session(xdr, res);
7214 * Decode EXCHANGE_ID response
7216 static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp,
7217 struct xdr_stream *xdr,
7220 struct compound_hdr hdr;
7223 status = decode_compound_hdr(xdr, &hdr);
7225 status = decode_exchange_id(xdr, res);
7230 * Decode CREATE_SESSION response
7232 static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp,
7233 struct xdr_stream *xdr,
7236 struct compound_hdr hdr;
7239 status = decode_compound_hdr(xdr, &hdr);
7241 status = decode_create_session(xdr, res);
7246 * Decode DESTROY_SESSION response
7248 static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp,
7249 struct xdr_stream *xdr,
7252 struct compound_hdr hdr;
7255 status = decode_compound_hdr(xdr, &hdr);
7257 status = decode_destroy_session(xdr, res);
7262 * Decode DESTROY_CLIENTID response
7264 static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp,
7265 struct xdr_stream *xdr,
7268 struct compound_hdr hdr;
7271 status = decode_compound_hdr(xdr, &hdr);
7273 status = decode_destroy_clientid(xdr, res);
7278 * Decode SEQUENCE response
7280 static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp,
7281 struct xdr_stream *xdr,
7284 struct compound_hdr hdr;
7287 status = decode_compound_hdr(xdr, &hdr);
7289 status = decode_sequence(xdr, res, rqstp);
7294 * Decode GET_LEASE_TIME response
7296 static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp,
7297 struct xdr_stream *xdr,
7300 struct nfs4_get_lease_time_res *res = data;
7301 struct compound_hdr hdr;
7304 status = decode_compound_hdr(xdr, &hdr);
7306 status = decode_sequence(xdr, &res->lr_seq_res, rqstp);
7308 status = decode_putrootfh(xdr);
7310 status = decode_fsinfo(xdr, res->lr_fsinfo);
7315 * Decode RECLAIM_COMPLETE response
7317 static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp,
7318 struct xdr_stream *xdr,
7321 struct nfs41_reclaim_complete_res *res = data;
7322 struct compound_hdr hdr;
7325 status = decode_compound_hdr(xdr, &hdr);
7327 status = decode_sequence(xdr, &res->seq_res, rqstp);
7329 status = decode_reclaim_complete(xdr, NULL);
7334 * Decode GETDEVINFO response
7336 static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp,
7337 struct xdr_stream *xdr,
7340 struct nfs4_getdeviceinfo_res *res = data;
7341 struct compound_hdr hdr;
7344 status = decode_compound_hdr(xdr, &hdr);
7347 status = decode_sequence(xdr, &res->seq_res, rqstp);
7350 status = decode_getdeviceinfo(xdr, res);
7356 * Decode LAYOUTGET response
7358 static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp,
7359 struct xdr_stream *xdr,
7362 struct nfs4_layoutget_res *res = data;
7363 struct compound_hdr hdr;
7366 status = decode_compound_hdr(xdr, &hdr);
7369 status = decode_sequence(xdr, &res->seq_res, rqstp);
7372 status = decode_putfh(xdr);
7375 status = decode_layoutget(xdr, rqstp, res);
7381 * Decode LAYOUTRETURN response
7383 static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp,
7384 struct xdr_stream *xdr,
7387 struct nfs4_layoutreturn_res *res = data;
7388 struct compound_hdr hdr;
7391 status = decode_compound_hdr(xdr, &hdr);
7394 status = decode_sequence(xdr, &res->seq_res, rqstp);
7397 status = decode_putfh(xdr);
7400 status = decode_layoutreturn(xdr, res);
7406 * Decode LAYOUTCOMMIT response
7408 static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp,
7409 struct xdr_stream *xdr,
7412 struct nfs4_layoutcommit_res *res = data;
7413 struct compound_hdr hdr;
7416 status = decode_compound_hdr(xdr, &hdr);
7419 status = decode_sequence(xdr, &res->seq_res, rqstp);
7422 status = decode_putfh(xdr);
7425 status = decode_layoutcommit(xdr, rqstp, res);
7428 decode_getfattr(xdr, res->fattr, res->server);
7434 * Decode SECINFO_NO_NAME response
7436 static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp,
7437 struct xdr_stream *xdr,
7440 struct nfs4_secinfo_res *res = data;
7441 struct compound_hdr hdr;
7444 status = decode_compound_hdr(xdr, &hdr);
7447 status = decode_sequence(xdr, &res->seq_res, rqstp);
7450 status = decode_putrootfh(xdr);
7453 status = decode_secinfo_no_name(xdr, res);
7459 * Decode TEST_STATEID response
7461 static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp,
7462 struct xdr_stream *xdr,
7465 struct nfs41_test_stateid_res *res = data;
7466 struct compound_hdr hdr;
7469 status = decode_compound_hdr(xdr, &hdr);
7472 status = decode_sequence(xdr, &res->seq_res, rqstp);
7475 status = decode_test_stateid(xdr, res);
7481 * Decode FREE_STATEID response
7483 static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp,
7484 struct xdr_stream *xdr,
7487 struct nfs41_free_stateid_res *res = data;
7488 struct compound_hdr hdr;
7491 status = decode_compound_hdr(xdr, &hdr);
7494 status = decode_sequence(xdr, &res->seq_res, rqstp);
7497 status = decode_free_stateid(xdr, res);
7501 #endif /* CONFIG_NFS_V4_1 */
7504 * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in
7505 * the local page cache.
7506 * @xdr: XDR stream where entry resides
7507 * @entry: buffer to fill in with entry data
7508 * @plus: boolean indicating whether this should be a readdirplus entry
7510 * Returns zero if successful, otherwise a negative errno value is
7513 * This function is not invoked during READDIR reply decoding, but
7514 * rather whenever an application invokes the getdents(2) system call
7515 * on a directory already in our cache.
7517 int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
7521 uint32_t bitmap[3] = {0};
7523 uint64_t new_cookie;
7524 __be32 *p = xdr_inline_decode(xdr, 4);
7527 if (*p == xdr_zero) {
7528 p = xdr_inline_decode(xdr, 4);
7537 p = xdr_inline_decode(xdr, 12);
7540 p = xdr_decode_hyper(p, &new_cookie);
7541 entry->len = be32_to_cpup(p);
7543 p = xdr_inline_decode(xdr, entry->len);
7546 entry->name = (const char *) p;
7549 * In case the server doesn't return an inode number,
7550 * we fake one here. (We don't use inode number 0,
7551 * since glibc seems to choke on it...)
7554 entry->fattr->valid = 0;
7556 if (decode_attr_bitmap(xdr, bitmap) < 0)
7559 if (decode_attr_length(xdr, &len, &savep) < 0)
7562 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,
7563 NULL, entry->label, entry->server) < 0)
7565 if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
7566 entry->ino = entry->fattr->mounted_on_fileid;
7567 else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
7568 entry->ino = entry->fattr->fileid;
7570 entry->d_type = DT_UNKNOWN;
7571 if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
7572 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
7574 entry->prev_cookie = entry->cookie;
7575 entry->cookie = new_cookie;
7580 print_overflow_msg(__func__, xdr);
7585 * We need to translate between nfs status return values and
7586 * the local errno values which may not be the same.
7593 { NFS4ERR_PERM, -EPERM },
7594 { NFS4ERR_NOENT, -ENOENT },
7595 { NFS4ERR_IO, -errno_NFSERR_IO},
7596 { NFS4ERR_NXIO, -ENXIO },
7597 { NFS4ERR_ACCESS, -EACCES },
7598 { NFS4ERR_EXIST, -EEXIST },
7599 { NFS4ERR_XDEV, -EXDEV },
7600 { NFS4ERR_NOTDIR, -ENOTDIR },
7601 { NFS4ERR_ISDIR, -EISDIR },
7602 { NFS4ERR_INVAL, -EINVAL },
7603 { NFS4ERR_FBIG, -EFBIG },
7604 { NFS4ERR_NOSPC, -ENOSPC },
7605 { NFS4ERR_ROFS, -EROFS },
7606 { NFS4ERR_MLINK, -EMLINK },
7607 { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
7608 { NFS4ERR_NOTEMPTY, -ENOTEMPTY },
7609 { NFS4ERR_DQUOT, -EDQUOT },
7610 { NFS4ERR_STALE, -ESTALE },
7611 { NFS4ERR_BADHANDLE, -EBADHANDLE },
7612 { NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
7613 { NFS4ERR_NOTSUPP, -ENOTSUPP },
7614 { NFS4ERR_TOOSMALL, -ETOOSMALL },
7615 { NFS4ERR_SERVERFAULT, -EREMOTEIO },
7616 { NFS4ERR_BADTYPE, -EBADTYPE },
7617 { NFS4ERR_LOCKED, -EAGAIN },
7618 { NFS4ERR_SYMLINK, -ELOOP },
7619 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
7620 { NFS4ERR_DEADLOCK, -EDEADLK },
7625 * Convert an NFS error code to a local one.
7626 * This one is used jointly by NFSv2 and NFSv3.
7629 nfs4_stat_to_errno(int stat)
7632 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
7633 if (nfs_errtbl[i].stat == stat)
7634 return nfs_errtbl[i].errno;
7636 if (stat <= 10000 || stat > 10100) {
7637 /* The server is looney tunes. */
7640 /* If we cannot translate the error, the recovery routines should
7642 * Note: remaining NFSv4 error codes have values > 10000, so should
7643 * not conflict with native Linux error codes.
7648 #ifdef CONFIG_NFS_V4_2
7649 #include "nfs42xdr.c"
7650 #endif /* CONFIG_NFS_V4_2 */
7652 #define PROC(proc, argtype, restype) \
7653 [NFSPROC4_CLNT_##proc] = { \
7654 .p_proc = NFSPROC4_COMPOUND, \
7655 .p_encode = nfs4_xdr_##argtype, \
7656 .p_decode = nfs4_xdr_##restype, \
7657 .p_arglen = NFS4_##argtype##_sz, \
7658 .p_replen = NFS4_##restype##_sz, \
7659 .p_statidx = NFSPROC4_CLNT_##proc, \
7663 #define STUB(proc) \
7664 [NFSPROC4_CLNT_##proc] = { \
7668 #if defined(CONFIG_NFS_V4_1)
7669 #define PROC41(proc, argtype, restype) \
7670 PROC(proc, argtype, restype)
7672 #define PROC41(proc, argtype, restype) \
7676 #if defined(CONFIG_NFS_V4_2)
7677 #define PROC42(proc, argtype, restype) \
7678 PROC(proc, argtype, restype)
7680 #define PROC42(proc, argtype, restype) \
7684 const struct rpc_procinfo nfs4_procedures[] = {
7685 PROC(READ, enc_read, dec_read),
7686 PROC(WRITE, enc_write, dec_write),
7687 PROC(COMMIT, enc_commit, dec_commit),
7688 PROC(OPEN, enc_open, dec_open),
7689 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
7690 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
7691 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
7692 PROC(CLOSE, enc_close, dec_close),
7693 PROC(SETATTR, enc_setattr, dec_setattr),
7694 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
7695 PROC(RENEW, enc_renew, dec_renew),
7696 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
7697 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
7698 PROC(LOCK, enc_lock, dec_lock),
7699 PROC(LOCKT, enc_lockt, dec_lockt),
7700 PROC(LOCKU, enc_locku, dec_locku),
7701 PROC(ACCESS, enc_access, dec_access),
7702 PROC(GETATTR, enc_getattr, dec_getattr),
7703 PROC(LOOKUP, enc_lookup, dec_lookup),
7704 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
7705 PROC(REMOVE, enc_remove, dec_remove),
7706 PROC(RENAME, enc_rename, dec_rename),
7707 PROC(LINK, enc_link, dec_link),
7708 PROC(SYMLINK, enc_symlink, dec_symlink),
7709 PROC(CREATE, enc_create, dec_create),
7710 PROC(PATHCONF, enc_pathconf, dec_pathconf),
7711 PROC(STATFS, enc_statfs, dec_statfs),
7712 PROC(READLINK, enc_readlink, dec_readlink),
7713 PROC(READDIR, enc_readdir, dec_readdir),
7714 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
7715 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
7716 PROC(GETACL, enc_getacl, dec_getacl),
7717 PROC(SETACL, enc_setacl, dec_setacl),
7718 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
7719 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
7720 PROC(SECINFO, enc_secinfo, dec_secinfo),
7721 PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present),
7722 PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
7723 PROC41(CREATE_SESSION, enc_create_session, dec_create_session),
7724 PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
7725 PROC41(SEQUENCE, enc_sequence, dec_sequence),
7726 PROC41(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time),
7727 PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete),
7728 PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo),
7729 PROC41(LAYOUTGET, enc_layoutget, dec_layoutget),
7730 PROC41(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit),
7731 PROC41(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn),
7732 PROC41(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name),
7733 PROC41(TEST_STATEID, enc_test_stateid, dec_test_stateid),
7734 PROC41(FREE_STATEID, enc_free_stateid, dec_free_stateid),
7735 STUB(GETDEVICELIST),
7736 PROC41(BIND_CONN_TO_SESSION,
7737 enc_bind_conn_to_session, dec_bind_conn_to_session),
7738 PROC41(DESTROY_CLIENTID,enc_destroy_clientid, dec_destroy_clientid),
7739 PROC42(SEEK, enc_seek, dec_seek),
7740 PROC42(ALLOCATE, enc_allocate, dec_allocate),
7741 PROC42(DEALLOCATE, enc_deallocate, dec_deallocate),
7742 PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats),
7743 PROC42(CLONE, enc_clone, dec_clone),
7744 PROC42(COPY, enc_copy, dec_copy),
7745 PROC(LOOKUPP, enc_lookupp, dec_lookupp),
7748 static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
7749 const struct rpc_version nfs_version4 = {
7751 .nrprocs = ARRAY_SIZE(nfs4_procedures),
7752 .procs = nfs4_procedures,
7753 .counts = nfs_version4_counts,