4 * Client-side XDR for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
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[])
1060 char owner_name[IDMAP_NAMESZ];
1061 char owner_group[IDMAP_NAMESZ];
1062 int owner_namelen = 0;
1063 int owner_grouplen = 0;
1066 uint32_t bmval[3] = { 0 };
1069 * We reserve enough space to write the entire attribute buffer at once.
1071 if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) {
1072 bmval[0] |= FATTR4_WORD0_SIZE;
1075 if (iap->ia_valid & ATTR_MODE) {
1076 if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) {
1077 bmval[2] |= FATTR4_WORD2_MODE_UMASK;
1079 } else if (attrmask[1] & FATTR4_WORD1_MODE) {
1080 bmval[1] |= FATTR4_WORD1_MODE;
1084 if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) {
1085 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
1086 if (owner_namelen < 0) {
1087 dprintk("nfs: couldn't resolve uid %d to string\n",
1088 from_kuid(&init_user_ns, iap->ia_uid));
1090 strcpy(owner_name, "nobody");
1091 owner_namelen = sizeof("nobody") - 1;
1094 bmval[1] |= FATTR4_WORD1_OWNER;
1095 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
1097 if ((iap->ia_valid & ATTR_GID) &&
1098 (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) {
1099 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
1100 if (owner_grouplen < 0) {
1101 dprintk("nfs: couldn't resolve gid %d to string\n",
1102 from_kgid(&init_user_ns, iap->ia_gid));
1103 strcpy(owner_group, "nobody");
1104 owner_grouplen = sizeof("nobody") - 1;
1107 bmval[1] |= FATTR4_WORD1_OWNER_GROUP;
1108 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
1110 if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1111 if (iap->ia_valid & ATTR_ATIME_SET) {
1112 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1113 len += 4 + (nfstime4_maxsz << 2);
1114 } else if (iap->ia_valid & ATTR_ATIME) {
1115 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1119 if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1120 if (iap->ia_valid & ATTR_MTIME_SET) {
1121 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1122 len += 4 + (nfstime4_maxsz << 2);
1123 } else if (iap->ia_valid & ATTR_MTIME) {
1124 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1129 if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) {
1130 len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
1131 bmval[2] |= FATTR4_WORD2_SECURITY_LABEL;
1134 xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval));
1135 xdr_stream_encode_opaque_inline(xdr, (void **)&p, len);
1137 if (bmval[0] & FATTR4_WORD0_SIZE)
1138 p = xdr_encode_hyper(p, iap->ia_size);
1139 if (bmval[1] & FATTR4_WORD1_MODE)
1140 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1141 if (bmval[1] & FATTR4_WORD1_OWNER)
1142 p = xdr_encode_opaque(p, owner_name, owner_namelen);
1143 if (bmval[1] & FATTR4_WORD1_OWNER_GROUP)
1144 p = xdr_encode_opaque(p, owner_group, owner_grouplen);
1145 if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1146 if (iap->ia_valid & ATTR_ATIME_SET) {
1147 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1148 p = xdr_encode_nfstime4(p, &iap->ia_atime);
1150 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1152 if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1153 if (iap->ia_valid & ATTR_MTIME_SET) {
1154 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1155 p = xdr_encode_nfstime4(p, &iap->ia_mtime);
1157 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1159 if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) {
1160 *p++ = cpu_to_be32(label->lfs);
1161 *p++ = cpu_to_be32(label->pi);
1162 *p++ = cpu_to_be32(label->len);
1163 p = xdr_encode_opaque_fixed(p, label->label, label->len);
1165 if (bmval[2] & FATTR4_WORD2_MODE_UMASK) {
1166 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1167 *p++ = cpu_to_be32(*umask);
1173 static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
1175 encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr);
1176 encode_uint32(xdr, access);
1179 static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1181 encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr);
1182 encode_nfs4_seqid(xdr, arg->seqid);
1183 encode_nfs4_stateid(xdr, &arg->stateid);
1186 static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr)
1190 encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
1191 p = reserve_space(xdr, 12);
1192 p = xdr_encode_hyper(p, args->offset);
1193 *p = cpu_to_be32(args->count);
1196 static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
1200 encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr);
1201 encode_uint32(xdr, create->ftype);
1203 switch (create->ftype) {
1205 p = reserve_space(xdr, 4);
1206 *p = cpu_to_be32(create->u.symlink.len);
1207 xdr_write_pages(xdr, create->u.symlink.pages, 0,
1208 create->u.symlink.len);
1209 xdr->buf->flags |= XDRBUF_WRITE;
1212 case NF4BLK: case NF4CHR:
1213 p = reserve_space(xdr, 8);
1214 *p++ = cpu_to_be32(create->u.device.specdata1);
1215 *p = cpu_to_be32(create->u.device.specdata2);
1222 encode_string(xdr, create->name->len, create->name->name);
1223 encode_attrs(xdr, create->attrs, create->label, &create->umask,
1224 create->server, create->server->attr_bitmask);
1227 static void encode_getattr(struct xdr_stream *xdr,
1228 const __u32 *bitmap, const __u32 *mask, size_t len,
1229 struct compound_hdr *hdr)
1231 __u32 masked_bitmap[nfs4_fattr_bitmap_maxsz];
1233 encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr);
1235 if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap)))
1236 len = ARRAY_SIZE(masked_bitmap);
1237 len = mask_bitmap4(bitmap, mask, masked_bitmap, len);
1238 bitmap = masked_bitmap;
1240 xdr_encode_bitmap4(xdr, bitmap, len);
1243 static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1245 encode_getattr(xdr, nfs4_fattr_bitmap, bitmask,
1246 ARRAY_SIZE(nfs4_fattr_bitmap), hdr);
1249 static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask,
1250 const u32 *open_bitmap,
1251 struct compound_hdr *hdr)
1253 encode_getattr(xdr, open_bitmap, bitmask, 3, hdr);
1256 static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1258 encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask,
1259 ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr);
1262 static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1264 encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask,
1265 ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr);
1268 static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1270 encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr);
1273 static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1275 encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr);
1276 encode_string(xdr, name->len, name->name);
1279 static inline int nfs4_lock_type(struct file_lock *fl, int block)
1281 if (fl->fl_type == F_RDLCK)
1282 return block ? NFS4_READW_LT : NFS4_READ_LT;
1283 return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
1286 static inline uint64_t nfs4_lock_length(struct file_lock *fl)
1288 if (fl->fl_end == OFFSET_MAX)
1289 return ~(uint64_t)0;
1290 return fl->fl_end - fl->fl_start + 1;
1293 static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner)
1297 p = reserve_space(xdr, 32);
1298 p = xdr_encode_hyper(p, lowner->clientid);
1299 *p++ = cpu_to_be32(20);
1300 p = xdr_encode_opaque_fixed(p, "lock id:", 8);
1301 *p++ = cpu_to_be32(lowner->s_dev);
1302 xdr_encode_hyper(p, lowner->id);
1306 * opcode,type,reclaim,offset,length,new_lock_owner = 32
1307 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
1309 static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
1313 encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr);
1314 p = reserve_space(xdr, 28);
1315 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
1316 *p++ = cpu_to_be32(args->reclaim);
1317 p = xdr_encode_hyper(p, args->fl->fl_start);
1318 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1319 *p = cpu_to_be32(args->new_lock_owner);
1320 if (args->new_lock_owner){
1321 encode_nfs4_seqid(xdr, args->open_seqid);
1322 encode_nfs4_stateid(xdr, &args->open_stateid);
1323 encode_nfs4_seqid(xdr, args->lock_seqid);
1324 encode_lockowner(xdr, &args->lock_owner);
1327 encode_nfs4_stateid(xdr, &args->lock_stateid);
1328 encode_nfs4_seqid(xdr, args->lock_seqid);
1332 static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
1336 encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr);
1337 p = reserve_space(xdr, 20);
1338 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1339 p = xdr_encode_hyper(p, args->fl->fl_start);
1340 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1341 encode_lockowner(xdr, &args->lock_owner);
1344 static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
1348 encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr);
1349 encode_uint32(xdr, nfs4_lock_type(args->fl, 0));
1350 encode_nfs4_seqid(xdr, args->seqid);
1351 encode_nfs4_stateid(xdr, &args->stateid);
1352 p = reserve_space(xdr, 16);
1353 p = xdr_encode_hyper(p, args->fl->fl_start);
1354 xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1357 static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
1359 encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr);
1360 encode_lockowner(xdr, lowner);
1363 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1365 encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr);
1366 encode_string(xdr, name->len, name->name);
1369 static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr)
1371 encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr);
1374 static void encode_share_access(struct xdr_stream *xdr, u32 share_access)
1378 p = reserve_space(xdr, 8);
1379 *p++ = cpu_to_be32(share_access);
1380 *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */
1383 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1387 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1390 encode_nfs4_seqid(xdr, arg->seqid);
1391 encode_share_access(xdr, arg->share_access);
1392 p = reserve_space(xdr, 36);
1393 p = xdr_encode_hyper(p, arg->clientid);
1394 *p++ = cpu_to_be32(24);
1395 p = xdr_encode_opaque_fixed(p, "open id:", 8);
1396 *p++ = cpu_to_be32(arg->server->s_dev);
1397 *p++ = cpu_to_be32(arg->id.uniquifier);
1398 xdr_encode_hyper(p, arg->id.create_time);
1401 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1405 p = reserve_space(xdr, 4);
1406 switch(arg->createmode) {
1407 case NFS4_CREATE_UNCHECKED:
1408 *p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
1409 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1410 arg->server, arg->server->attr_bitmask);
1412 case NFS4_CREATE_GUARDED:
1413 *p = cpu_to_be32(NFS4_CREATE_GUARDED);
1414 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1415 arg->server, arg->server->attr_bitmask);
1417 case NFS4_CREATE_EXCLUSIVE:
1418 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
1419 encode_nfs4_verifier(xdr, &arg->u.verifier);
1421 case NFS4_CREATE_EXCLUSIVE4_1:
1422 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
1423 encode_nfs4_verifier(xdr, &arg->u.verifier);
1424 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1425 arg->server, arg->server->exclcreat_bitmask);
1429 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1433 p = reserve_space(xdr, 4);
1434 switch (arg->open_flags & O_CREAT) {
1436 *p = cpu_to_be32(NFS4_OPEN_NOCREATE);
1439 *p = cpu_to_be32(NFS4_OPEN_CREATE);
1440 encode_createmode(xdr, arg);
1444 static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
1448 p = reserve_space(xdr, 4);
1449 switch (delegation_type) {
1451 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
1454 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ);
1456 case FMODE_WRITE|FMODE_READ:
1457 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE);
1464 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
1468 p = reserve_space(xdr, 4);
1469 *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
1470 encode_string(xdr, name->len, name->name);
1473 static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1477 p = reserve_space(xdr, 4);
1478 *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
1479 encode_delegation_type(xdr, type);
1482 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
1486 p = reserve_space(xdr, 4);
1487 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1488 encode_nfs4_stateid(xdr, stateid);
1489 encode_string(xdr, name->len, name->name);
1492 static inline void encode_claim_fh(struct xdr_stream *xdr)
1496 p = reserve_space(xdr, 4);
1497 *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH);
1500 static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1504 p = reserve_space(xdr, 4);
1505 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
1506 encode_nfs4_stateid(xdr, stateid);
1509 static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
1511 encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr);
1512 encode_openhdr(xdr, arg);
1513 encode_opentype(xdr, arg);
1514 switch (arg->claim) {
1515 case NFS4_OPEN_CLAIM_NULL:
1516 encode_claim_null(xdr, arg->name);
1518 case NFS4_OPEN_CLAIM_PREVIOUS:
1519 encode_claim_previous(xdr, arg->u.delegation_type);
1521 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
1522 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
1524 case NFS4_OPEN_CLAIM_FH:
1525 encode_claim_fh(xdr);
1527 case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
1528 encode_claim_delegate_cur_fh(xdr, &arg->u.delegation);
1535 static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
1537 encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr);
1538 encode_nfs4_stateid(xdr, arg->stateid);
1539 encode_nfs4_seqid(xdr, arg->seqid);
1542 static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1544 encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr);
1545 encode_nfs4_stateid(xdr, &arg->stateid);
1546 encode_nfs4_seqid(xdr, arg->seqid);
1547 encode_share_access(xdr, arg->share_access);
1551 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1553 encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr);
1554 encode_string(xdr, fh->size, fh->data);
1557 static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1559 encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
1562 static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1563 struct compound_hdr *hdr)
1567 encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
1568 encode_nfs4_stateid(xdr, &args->stateid);
1570 p = reserve_space(xdr, 12);
1571 p = xdr_encode_hyper(p, args->offset);
1572 *p = cpu_to_be32(args->count);
1575 static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
1577 uint32_t attrs[3] = {
1578 FATTR4_WORD0_RDATTR_ERROR,
1579 FATTR4_WORD1_MOUNTED_ON_FILEID,
1581 uint32_t dircount = readdir->count >> 1;
1583 uint32_t attrlen = 0;
1586 if (readdir->plus) {
1587 attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
1588 FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID;
1589 attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
1590 FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
1591 FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
1592 FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
1593 attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
1596 /* Use mounted_on_fileid only if the server supports it */
1597 if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID))
1598 attrs[0] |= FATTR4_WORD0_FILEID;
1599 for (i = 0; i < ARRAY_SIZE(attrs); i++) {
1600 attrs[i] &= readdir->bitmask[i];
1605 encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr);
1606 encode_uint64(xdr, readdir->cookie);
1607 encode_nfs4_verifier(xdr, &readdir->verifier);
1608 p = reserve_space(xdr, 12 + (attrlen << 2));
1609 *p++ = cpu_to_be32(dircount);
1610 *p++ = cpu_to_be32(readdir->count);
1611 *p++ = cpu_to_be32(attrlen);
1612 for (i = 0; i < attrlen; i++)
1613 *p++ = cpu_to_be32(attrs[i]);
1614 memcpy(verf, readdir->verifier.data, sizeof(verf));
1616 dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n",
1618 (unsigned long long)readdir->cookie,
1620 attrs[0] & readdir->bitmask[0],
1621 attrs[1] & readdir->bitmask[1],
1622 attrs[2] & readdir->bitmask[2]);
1625 static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
1627 encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr);
1630 static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1632 encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr);
1633 encode_string(xdr, name->len, name->name);
1636 static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
1638 encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr);
1639 encode_string(xdr, oldname->len, oldname->name);
1640 encode_string(xdr, newname->len, newname->name);
1643 static void encode_renew(struct xdr_stream *xdr, clientid4 clid,
1644 struct compound_hdr *hdr)
1646 encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr);
1647 encode_uint64(xdr, clid);
1651 encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1653 encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr);
1657 encode_setacl(struct xdr_stream *xdr, const struct nfs_setaclargs *arg,
1658 struct compound_hdr *hdr)
1662 encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr);
1663 encode_nfs4_stateid(xdr, &zero_stateid);
1664 p = reserve_space(xdr, 2*4);
1665 *p++ = cpu_to_be32(1);
1666 *p = cpu_to_be32(FATTR4_WORD0_ACL);
1667 p = reserve_space(xdr, 4);
1668 *p = cpu_to_be32(arg->acl_len);
1669 xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len);
1673 encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1675 encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr);
1678 static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
1680 encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr);
1681 encode_nfs4_stateid(xdr, &arg->stateid);
1682 encode_attrs(xdr, arg->iap, arg->label, NULL, server,
1683 server->attr_bitmask);
1686 static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
1690 encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr);
1691 encode_nfs4_verifier(xdr, setclientid->sc_verifier);
1693 encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id),
1694 setclientid->sc_clnt->cl_owner_id);
1695 p = reserve_space(xdr, 4);
1696 *p = cpu_to_be32(setclientid->sc_prog);
1697 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1698 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1699 p = reserve_space(xdr, 4);
1700 *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident);
1703 static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
1705 encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM,
1706 decode_setclientid_confirm_maxsz, hdr);
1707 encode_uint64(xdr, arg->clientid);
1708 encode_nfs4_verifier(xdr, &arg->confirm);
1711 static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1712 struct compound_hdr *hdr)
1716 encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
1717 encode_nfs4_stateid(xdr, &args->stateid);
1719 p = reserve_space(xdr, 16);
1720 p = xdr_encode_hyper(p, args->offset);
1721 *p++ = cpu_to_be32(args->stable);
1722 *p = cpu_to_be32(args->count);
1724 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1727 static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
1729 encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr);
1730 encode_nfs4_stateid(xdr, stateid);
1733 static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1735 encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr);
1736 encode_string(xdr, name->len, name->name);
1739 #if defined(CONFIG_NFS_V4_1)
1740 /* NFSv4.1 operations */
1741 static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1742 const struct nfs41_bind_conn_to_session_args *args,
1743 struct compound_hdr *hdr)
1747 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
1748 decode_bind_conn_to_session_maxsz, hdr);
1749 encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
1750 p = xdr_reserve_space(xdr, 8);
1751 *p++ = cpu_to_be32(args->dir);
1752 *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
1755 static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map)
1758 encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS);
1759 for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++)
1760 encode_uint32(xdr, op_map->u.words[i]);
1763 static void encode_exchange_id(struct xdr_stream *xdr,
1764 const struct nfs41_exchange_id_args *args,
1765 struct compound_hdr *hdr)
1768 char impl_name[IMPL_NAME_LIMIT];
1771 encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
1772 encode_nfs4_verifier(xdr, &args->verifier);
1774 encode_string(xdr, strlen(args->client->cl_owner_id),
1775 args->client->cl_owner_id);
1777 encode_uint32(xdr, args->flags);
1778 encode_uint32(xdr, args->state_protect.how);
1780 switch (args->state_protect.how) {
1784 encode_op_map(xdr, &args->state_protect.enforce);
1785 encode_op_map(xdr, &args->state_protect.allow);
1792 if (send_implementation_id &&
1793 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 &&
1794 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN)
1795 <= sizeof(impl_name) + 1)
1796 len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s",
1797 utsname()->sysname, utsname()->release,
1798 utsname()->version, utsname()->machine);
1801 encode_uint32(xdr, 1); /* implementation id array length=1 */
1804 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1,
1805 CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN);
1806 encode_string(xdr, len, impl_name);
1807 /* just send zeros for nii_date - the date is in nii_name */
1808 p = reserve_space(xdr, 12);
1809 p = xdr_encode_hyper(p, 0);
1810 *p = cpu_to_be32(0);
1812 encode_uint32(xdr, 0); /* implementation id array length=0 */
1815 static void encode_create_session(struct xdr_stream *xdr,
1816 const struct nfs41_create_session_args *args,
1817 struct compound_hdr *hdr)
1820 struct nfs_client *clp = args->client;
1821 struct rpc_clnt *clnt = clp->cl_rpcclient;
1822 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
1823 u32 max_resp_sz_cached;
1826 * Assumes OPEN is the biggest non-idempotent compound.
1827 * 2 is the verifier.
1829 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
1830 * XDR_UNIT + RPC_MAX_AUTH_SIZE;
1832 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
1833 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
1834 p = xdr_encode_hyper(p, args->clientid);
1835 *p++ = cpu_to_be32(args->seqid); /*Sequence id */
1836 *p++ = cpu_to_be32(args->flags); /*flags */
1839 *p++ = cpu_to_be32(0); /* header padding size */
1840 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */
1841 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */
1842 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */
1843 *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */
1844 *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */
1845 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1848 *p++ = cpu_to_be32(0); /* header padding size */
1849 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */
1850 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */
1851 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */
1852 *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */
1853 *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */
1854 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1856 *p++ = cpu_to_be32(args->cb_program); /* cb_program */
1857 *p++ = cpu_to_be32(1);
1858 *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
1860 /* authsys_parms rfc1831 */
1861 *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
1862 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
1863 *p++ = cpu_to_be32(0); /* UID */
1864 *p++ = cpu_to_be32(0); /* GID */
1865 *p = cpu_to_be32(0); /* No more gids */
1868 static void encode_destroy_session(struct xdr_stream *xdr,
1869 const struct nfs4_session *session,
1870 struct compound_hdr *hdr)
1872 encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr);
1873 encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1876 static void encode_destroy_clientid(struct xdr_stream *xdr,
1878 struct compound_hdr *hdr)
1880 encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr);
1881 encode_uint64(xdr, clientid);
1884 static void encode_reclaim_complete(struct xdr_stream *xdr,
1885 const struct nfs41_reclaim_complete_args *args,
1886 struct compound_hdr *hdr)
1888 encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr);
1889 encode_uint32(xdr, args->one_fs);
1891 #endif /* CONFIG_NFS_V4_1 */
1893 static void encode_sequence(struct xdr_stream *xdr,
1894 const struct nfs4_sequence_args *args,
1895 struct compound_hdr *hdr)
1897 #if defined(CONFIG_NFS_V4_1)
1898 struct nfs4_session *session;
1899 struct nfs4_slot_table *tp;
1900 struct nfs4_slot *slot = args->sa_slot;
1904 session = tp->session;
1908 encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr);
1911 * Sessionid + seqid + slotid + max slotid + cache_this
1913 dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
1914 "max_slotid=%d cache_this=%d\n",
1916 ((u32 *)session->sess_id.data)[0],
1917 ((u32 *)session->sess_id.data)[1],
1918 ((u32 *)session->sess_id.data)[2],
1919 ((u32 *)session->sess_id.data)[3],
1920 slot->seq_nr, slot->slot_nr,
1921 tp->highest_used_slotid, args->sa_cache_this);
1922 p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16);
1923 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1924 *p++ = cpu_to_be32(slot->seq_nr);
1925 *p++ = cpu_to_be32(slot->slot_nr);
1926 *p++ = cpu_to_be32(tp->highest_used_slotid);
1927 *p = cpu_to_be32(args->sa_cache_this);
1928 #endif /* CONFIG_NFS_V4_1 */
1931 #ifdef CONFIG_NFS_V4_1
1933 encode_getdeviceinfo(struct xdr_stream *xdr,
1934 const struct nfs4_getdeviceinfo_args *args,
1935 struct compound_hdr *hdr)
1939 encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr);
1940 p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4);
1941 p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data,
1942 NFS4_DEVICEID4_SIZE);
1943 *p++ = cpu_to_be32(args->pdev->layout_type);
1944 *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */
1946 p = reserve_space(xdr, 4 + 4);
1947 *p++ = cpu_to_be32(1); /* bitmap length */
1948 *p++ = cpu_to_be32(args->notify_types);
1952 encode_layoutget(struct xdr_stream *xdr,
1953 const struct nfs4_layoutget_args *args,
1954 struct compound_hdr *hdr)
1958 encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr);
1959 p = reserve_space(xdr, 36);
1960 *p++ = cpu_to_be32(0); /* Signal layout available */
1961 *p++ = cpu_to_be32(args->type);
1962 *p++ = cpu_to_be32(args->range.iomode);
1963 p = xdr_encode_hyper(p, args->range.offset);
1964 p = xdr_encode_hyper(p, args->range.length);
1965 p = xdr_encode_hyper(p, args->minlength);
1966 encode_nfs4_stateid(xdr, &args->stateid);
1967 encode_uint32(xdr, args->maxcount);
1969 dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n",
1973 (unsigned long)args->range.offset,
1974 (unsigned long)args->range.length,
1979 encode_layoutcommit(struct xdr_stream *xdr,
1980 struct inode *inode,
1981 const struct nfs4_layoutcommit_args *args,
1982 struct compound_hdr *hdr)
1986 dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten,
1987 NFS_SERVER(args->inode)->pnfs_curr_ld->id);
1989 encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr);
1990 p = reserve_space(xdr, 20);
1991 /* Only whole file layouts */
1992 p = xdr_encode_hyper(p, 0); /* offset */
1993 p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */
1994 *p = cpu_to_be32(0); /* reclaim */
1995 encode_nfs4_stateid(xdr, &args->stateid);
1996 if (args->lastbytewritten != U64_MAX) {
1997 p = reserve_space(xdr, 20);
1998 *p++ = cpu_to_be32(1); /* newoffset = TRUE */
1999 p = xdr_encode_hyper(p, args->lastbytewritten);
2001 p = reserve_space(xdr, 12);
2002 *p++ = cpu_to_be32(0); /* newoffset = FALSE */
2004 *p++ = cpu_to_be32(0); /* Never send time_modify_changed */
2005 *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
2007 encode_uint32(xdr, args->layoutupdate_len);
2008 if (args->layoutupdate_pages)
2009 xdr_write_pages(xdr, args->layoutupdate_pages, 0,
2010 args->layoutupdate_len);
2016 encode_layoutreturn(struct xdr_stream *xdr,
2017 const struct nfs4_layoutreturn_args *args,
2018 struct compound_hdr *hdr)
2022 encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr);
2023 p = reserve_space(xdr, 16);
2024 *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */
2025 *p++ = cpu_to_be32(args->layout_type);
2026 *p++ = cpu_to_be32(args->range.iomode);
2027 *p = cpu_to_be32(RETURN_FILE);
2028 p = reserve_space(xdr, 16);
2029 p = xdr_encode_hyper(p, args->range.offset);
2030 p = xdr_encode_hyper(p, args->range.length);
2031 spin_lock(&args->inode->i_lock);
2032 encode_nfs4_stateid(xdr, &args->stateid);
2033 spin_unlock(&args->inode->i_lock);
2034 if (args->ld_private->ops && args->ld_private->ops->encode)
2035 args->ld_private->ops->encode(xdr, args, args->ld_private);
2037 encode_uint32(xdr, 0);
2041 encode_secinfo_no_name(struct xdr_stream *xdr,
2042 const struct nfs41_secinfo_no_name_args *args,
2043 struct compound_hdr *hdr)
2045 encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr);
2046 encode_uint32(xdr, args->style);
2050 static void encode_test_stateid(struct xdr_stream *xdr,
2051 const struct nfs41_test_stateid_args *args,
2052 struct compound_hdr *hdr)
2054 encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr);
2055 encode_uint32(xdr, 1);
2056 encode_nfs4_stateid(xdr, args->stateid);
2059 static void encode_free_stateid(struct xdr_stream *xdr,
2060 const struct nfs41_free_stateid_args *args,
2061 struct compound_hdr *hdr)
2063 encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr);
2064 encode_nfs4_stateid(xdr, &args->stateid);
2068 encode_layoutreturn(struct xdr_stream *xdr,
2069 const struct nfs4_layoutreturn_args *args,
2070 struct compound_hdr *hdr)
2073 #endif /* CONFIG_NFS_V4_1 */
2076 * END OF "GENERIC" ENCODE ROUTINES.
2079 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
2081 #if defined(CONFIG_NFS_V4_1)
2082 struct nfs4_session *session = args->sa_slot->table->session;
2084 return session->clp->cl_mvops->minor_version;
2085 #endif /* CONFIG_NFS_V4_1 */
2090 * Encode an ACCESS request
2092 static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr,
2095 const struct nfs4_accessargs *args = data;
2096 struct compound_hdr hdr = {
2097 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2100 encode_compound_hdr(xdr, req, &hdr);
2101 encode_sequence(xdr, &args->seq_args, &hdr);
2102 encode_putfh(xdr, args->fh, &hdr);
2103 encode_access(xdr, args->access, &hdr);
2105 encode_getfattr(xdr, args->bitmask, &hdr);
2110 * Encode LOOKUP request
2112 static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr,
2115 const struct nfs4_lookup_arg *args = data;
2116 struct compound_hdr hdr = {
2117 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2120 encode_compound_hdr(xdr, req, &hdr);
2121 encode_sequence(xdr, &args->seq_args, &hdr);
2122 encode_putfh(xdr, args->dir_fh, &hdr);
2123 encode_lookup(xdr, args->name, &hdr);
2124 encode_getfh(xdr, &hdr);
2125 encode_getfattr(xdr, args->bitmask, &hdr);
2130 * Encode LOOKUPP request
2132 static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr,
2135 const struct nfs4_lookupp_arg *args = data;
2136 struct compound_hdr hdr = {
2137 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2140 encode_compound_hdr(xdr, req, &hdr);
2141 encode_sequence(xdr, &args->seq_args, &hdr);
2142 encode_putfh(xdr, args->fh, &hdr);
2143 encode_lookupp(xdr, &hdr);
2144 encode_getfh(xdr, &hdr);
2145 encode_getfattr(xdr, args->bitmask, &hdr);
2150 * Encode LOOKUP_ROOT request
2152 static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req,
2153 struct xdr_stream *xdr,
2156 const struct nfs4_lookup_root_arg *args = data;
2157 struct compound_hdr hdr = {
2158 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2161 encode_compound_hdr(xdr, req, &hdr);
2162 encode_sequence(xdr, &args->seq_args, &hdr);
2163 encode_putrootfh(xdr, &hdr);
2164 encode_getfh(xdr, &hdr);
2165 encode_getfattr(xdr, args->bitmask, &hdr);
2170 * Encode REMOVE request
2172 static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
2175 const struct nfs_removeargs *args = data;
2176 struct compound_hdr hdr = {
2177 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2180 encode_compound_hdr(xdr, req, &hdr);
2181 encode_sequence(xdr, &args->seq_args, &hdr);
2182 encode_putfh(xdr, args->fh, &hdr);
2183 encode_remove(xdr, &args->name, &hdr);
2188 * Encode RENAME request
2190 static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
2193 const struct nfs_renameargs *args = data;
2194 struct compound_hdr hdr = {
2195 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2198 encode_compound_hdr(xdr, req, &hdr);
2199 encode_sequence(xdr, &args->seq_args, &hdr);
2200 encode_putfh(xdr, args->old_dir, &hdr);
2201 encode_savefh(xdr, &hdr);
2202 encode_putfh(xdr, args->new_dir, &hdr);
2203 encode_rename(xdr, args->old_name, args->new_name, &hdr);
2208 * Encode LINK request
2210 static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
2213 const struct nfs4_link_arg *args = data;
2214 struct compound_hdr hdr = {
2215 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2218 encode_compound_hdr(xdr, req, &hdr);
2219 encode_sequence(xdr, &args->seq_args, &hdr);
2220 encode_putfh(xdr, args->fh, &hdr);
2221 encode_savefh(xdr, &hdr);
2222 encode_putfh(xdr, args->dir_fh, &hdr);
2223 encode_link(xdr, args->name, &hdr);
2224 encode_restorefh(xdr, &hdr);
2225 encode_getfattr(xdr, args->bitmask, &hdr);
2230 * Encode CREATE request
2232 static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr,
2235 const struct nfs4_create_arg *args = data;
2236 struct compound_hdr hdr = {
2237 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2240 encode_compound_hdr(xdr, req, &hdr);
2241 encode_sequence(xdr, &args->seq_args, &hdr);
2242 encode_putfh(xdr, args->dir_fh, &hdr);
2243 encode_create(xdr, args, &hdr);
2244 encode_getfh(xdr, &hdr);
2245 encode_getfattr(xdr, args->bitmask, &hdr);
2250 * Encode SYMLINK request
2252 static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2255 const struct nfs4_create_arg *args = data;
2257 nfs4_xdr_enc_create(req, xdr, args);
2261 * Encode GETATTR request
2263 static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2266 const struct nfs4_getattr_arg *args = data;
2267 struct compound_hdr hdr = {
2268 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2271 encode_compound_hdr(xdr, req, &hdr);
2272 encode_sequence(xdr, &args->seq_args, &hdr);
2273 encode_putfh(xdr, args->fh, &hdr);
2274 encode_getfattr(xdr, args->bitmask, &hdr);
2279 * Encode a CLOSE request
2281 static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
2284 const struct nfs_closeargs *args = data;
2285 struct compound_hdr hdr = {
2286 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2289 encode_compound_hdr(xdr, req, &hdr);
2290 encode_sequence(xdr, &args->seq_args, &hdr);
2291 encode_putfh(xdr, args->fh, &hdr);
2293 encode_layoutreturn(xdr, args->lr_args, &hdr);
2294 if (args->bitmask != NULL)
2295 encode_getfattr(xdr, args->bitmask, &hdr);
2296 encode_close(xdr, args, &hdr);
2301 * Encode an OPEN request
2303 static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
2306 const struct nfs_openargs *args = data;
2307 struct compound_hdr hdr = {
2308 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2311 encode_compound_hdr(xdr, req, &hdr);
2312 encode_sequence(xdr, &args->seq_args, &hdr);
2313 encode_putfh(xdr, args->fh, &hdr);
2314 encode_open(xdr, args, &hdr);
2315 encode_getfh(xdr, &hdr);
2317 encode_access(xdr, args->access, &hdr);
2318 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2323 * Encode an OPEN_CONFIRM request
2325 static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req,
2326 struct xdr_stream *xdr,
2329 const struct nfs_open_confirmargs *args = data;
2330 struct compound_hdr hdr = {
2334 encode_compound_hdr(xdr, req, &hdr);
2335 encode_putfh(xdr, args->fh, &hdr);
2336 encode_open_confirm(xdr, args, &hdr);
2341 * Encode an OPEN request with no attributes.
2343 static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
2344 struct xdr_stream *xdr,
2347 const struct nfs_openargs *args = data;
2348 struct compound_hdr hdr = {
2349 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2352 encode_compound_hdr(xdr, req, &hdr);
2353 encode_sequence(xdr, &args->seq_args, &hdr);
2354 encode_putfh(xdr, args->fh, &hdr);
2355 encode_open(xdr, args, &hdr);
2357 encode_access(xdr, args->access, &hdr);
2358 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2363 * Encode an OPEN_DOWNGRADE request
2365 static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req,
2366 struct xdr_stream *xdr,
2369 const struct nfs_closeargs *args = data;
2370 struct compound_hdr hdr = {
2371 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2374 encode_compound_hdr(xdr, req, &hdr);
2375 encode_sequence(xdr, &args->seq_args, &hdr);
2376 encode_putfh(xdr, args->fh, &hdr);
2378 encode_layoutreturn(xdr, args->lr_args, &hdr);
2379 encode_open_downgrade(xdr, args, &hdr);
2384 * Encode a LOCK request
2386 static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr,
2389 const struct nfs_lock_args *args = data;
2390 struct compound_hdr hdr = {
2391 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2394 encode_compound_hdr(xdr, req, &hdr);
2395 encode_sequence(xdr, &args->seq_args, &hdr);
2396 encode_putfh(xdr, args->fh, &hdr);
2397 encode_lock(xdr, args, &hdr);
2402 * Encode a LOCKT request
2404 static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr,
2407 const struct nfs_lockt_args *args = data;
2408 struct compound_hdr hdr = {
2409 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2412 encode_compound_hdr(xdr, req, &hdr);
2413 encode_sequence(xdr, &args->seq_args, &hdr);
2414 encode_putfh(xdr, args->fh, &hdr);
2415 encode_lockt(xdr, args, &hdr);
2420 * Encode a LOCKU request
2422 static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
2425 const struct nfs_locku_args *args = data;
2426 struct compound_hdr hdr = {
2427 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2430 encode_compound_hdr(xdr, req, &hdr);
2431 encode_sequence(xdr, &args->seq_args, &hdr);
2432 encode_putfh(xdr, args->fh, &hdr);
2433 encode_locku(xdr, args, &hdr);
2437 static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
2438 struct xdr_stream *xdr,
2441 const struct nfs_release_lockowner_args *args = data;
2442 struct compound_hdr hdr = {
2446 encode_compound_hdr(xdr, req, &hdr);
2447 encode_release_lockowner(xdr, &args->lock_owner, &hdr);
2452 * Encode a READLINK request
2454 static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2457 const struct nfs4_readlink *args = data;
2458 struct compound_hdr hdr = {
2459 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2462 encode_compound_hdr(xdr, req, &hdr);
2463 encode_sequence(xdr, &args->seq_args, &hdr);
2464 encode_putfh(xdr, args->fh, &hdr);
2465 encode_readlink(xdr, args, req, &hdr);
2467 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2468 args->pgbase, args->pglen);
2473 * Encode a READDIR request
2475 static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
2478 const struct nfs4_readdir_arg *args = data;
2479 struct compound_hdr hdr = {
2480 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2483 encode_compound_hdr(xdr, req, &hdr);
2484 encode_sequence(xdr, &args->seq_args, &hdr);
2485 encode_putfh(xdr, args->fh, &hdr);
2486 encode_readdir(xdr, args, req, &hdr);
2488 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2489 args->pgbase, args->count);
2490 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
2491 __func__, hdr.replen << 2, args->pages,
2492 args->pgbase, args->count);
2497 * Encode a READ request
2499 static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
2502 const struct nfs_pgio_args *args = data;
2503 struct compound_hdr hdr = {
2504 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2507 encode_compound_hdr(xdr, req, &hdr);
2508 encode_sequence(xdr, &args->seq_args, &hdr);
2509 encode_putfh(xdr, args->fh, &hdr);
2510 encode_read(xdr, args, &hdr);
2512 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
2513 args->pages, args->pgbase, args->count);
2514 req->rq_rcv_buf.flags |= XDRBUF_READ;
2519 * Encode an SETATTR request
2521 static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2524 const struct nfs_setattrargs *args = data;
2525 struct compound_hdr hdr = {
2526 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2529 encode_compound_hdr(xdr, req, &hdr);
2530 encode_sequence(xdr, &args->seq_args, &hdr);
2531 encode_putfh(xdr, args->fh, &hdr);
2532 encode_setattr(xdr, args, args->server, &hdr);
2533 encode_getfattr(xdr, args->bitmask, &hdr);
2538 * Encode a GETACL request
2540 static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2543 const struct nfs_getaclargs *args = data;
2544 struct compound_hdr hdr = {
2545 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2547 const __u32 nfs4_acl_bitmap[1] = {
2548 [0] = FATTR4_WORD0_ACL,
2552 encode_compound_hdr(xdr, req, &hdr);
2553 encode_sequence(xdr, &args->seq_args, &hdr);
2554 encode_putfh(xdr, args->fh, &hdr);
2555 replen = hdr.replen + op_decode_hdr_maxsz;
2556 encode_getattr(xdr, nfs4_acl_bitmap, NULL,
2557 ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
2559 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2560 args->acl_pages, 0, args->acl_len);
2566 * Encode a WRITE request
2568 static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
2571 const struct nfs_pgio_args *args = data;
2572 struct compound_hdr hdr = {
2573 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2576 encode_compound_hdr(xdr, req, &hdr);
2577 encode_sequence(xdr, &args->seq_args, &hdr);
2578 encode_putfh(xdr, args->fh, &hdr);
2579 encode_write(xdr, args, &hdr);
2580 req->rq_snd_buf.flags |= XDRBUF_WRITE;
2582 encode_getfattr(xdr, args->bitmask, &hdr);
2589 static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr,
2592 const struct nfs_commitargs *args = data;
2593 struct compound_hdr hdr = {
2594 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2597 encode_compound_hdr(xdr, req, &hdr);
2598 encode_sequence(xdr, &args->seq_args, &hdr);
2599 encode_putfh(xdr, args->fh, &hdr);
2600 encode_commit(xdr, args, &hdr);
2607 static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
2610 const struct nfs4_fsinfo_arg *args = data;
2611 struct compound_hdr hdr = {
2612 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2615 encode_compound_hdr(xdr, req, &hdr);
2616 encode_sequence(xdr, &args->seq_args, &hdr);
2617 encode_putfh(xdr, args->fh, &hdr);
2618 encode_fsinfo(xdr, args->bitmask, &hdr);
2623 * a PATHCONF request
2625 static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
2628 const struct nfs4_pathconf_arg *args = data;
2629 struct compound_hdr hdr = {
2630 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2633 encode_compound_hdr(xdr, req, &hdr);
2634 encode_sequence(xdr, &args->seq_args, &hdr);
2635 encode_putfh(xdr, args->fh, &hdr);
2636 encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask,
2637 ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr);
2644 static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
2647 const struct nfs4_statfs_arg *args = data;
2648 struct compound_hdr hdr = {
2649 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2652 encode_compound_hdr(xdr, req, &hdr);
2653 encode_sequence(xdr, &args->seq_args, &hdr);
2654 encode_putfh(xdr, args->fh, &hdr);
2655 encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask,
2656 ARRAY_SIZE(nfs4_statfs_bitmap), &hdr);
2661 * GETATTR_BITMAP request
2663 static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
2664 struct xdr_stream *xdr,
2667 const struct nfs4_server_caps_arg *args = data;
2668 const u32 *bitmask = args->bitmask;
2669 struct compound_hdr hdr = {
2670 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2673 encode_compound_hdr(xdr, req, &hdr);
2674 encode_sequence(xdr, &args->seq_args, &hdr);
2675 encode_putfh(xdr, args->fhandle, &hdr);
2676 encode_getattr(xdr, bitmask, NULL, 3, &hdr);
2683 static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
2687 const struct nfs_client *clp = data;
2688 struct compound_hdr hdr = {
2692 encode_compound_hdr(xdr, req, &hdr);
2693 encode_renew(xdr, clp->cl_clientid, &hdr);
2698 * a SETCLIENTID request
2700 static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req,
2701 struct xdr_stream *xdr,
2704 const struct nfs4_setclientid *sc = data;
2705 struct compound_hdr hdr = {
2709 encode_compound_hdr(xdr, req, &hdr);
2710 encode_setclientid(xdr, sc, &hdr);
2715 * a SETCLIENTID_CONFIRM request
2717 static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
2718 struct xdr_stream *xdr,
2721 const struct nfs4_setclientid_res *arg = data;
2722 struct compound_hdr hdr = {
2726 encode_compound_hdr(xdr, req, &hdr);
2727 encode_setclientid_confirm(xdr, arg, &hdr);
2732 * DELEGRETURN request
2734 static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req,
2735 struct xdr_stream *xdr,
2738 const struct nfs4_delegreturnargs *args = data;
2739 struct compound_hdr hdr = {
2740 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2743 encode_compound_hdr(xdr, req, &hdr);
2744 encode_sequence(xdr, &args->seq_args, &hdr);
2745 encode_putfh(xdr, args->fhandle, &hdr);
2747 encode_layoutreturn(xdr, args->lr_args, &hdr);
2749 encode_getfattr(xdr, args->bitmask, &hdr);
2750 encode_delegreturn(xdr, args->stateid, &hdr);
2755 * Encode FS_LOCATIONS request
2757 static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
2758 struct xdr_stream *xdr,
2761 const struct nfs4_fs_locations_arg *args = data;
2762 struct compound_hdr hdr = {
2763 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2767 encode_compound_hdr(xdr, req, &hdr);
2768 encode_sequence(xdr, &args->seq_args, &hdr);
2769 if (args->migration) {
2770 encode_putfh(xdr, args->fh, &hdr);
2771 replen = hdr.replen;
2772 encode_fs_locations(xdr, args->bitmask, &hdr);
2774 encode_renew(xdr, args->clientid, &hdr);
2776 encode_putfh(xdr, args->dir_fh, &hdr);
2777 encode_lookup(xdr, args->name, &hdr);
2778 replen = hdr.replen;
2779 encode_fs_locations(xdr, args->bitmask, &hdr);
2782 /* Set up reply kvec to capture returned fs_locations array. */
2783 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2784 (struct page **)&args->page, 0, PAGE_SIZE);
2789 * Encode SECINFO request
2791 static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req,
2792 struct xdr_stream *xdr,
2795 const struct nfs4_secinfo_arg *args = data;
2796 struct compound_hdr hdr = {
2797 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2800 encode_compound_hdr(xdr, req, &hdr);
2801 encode_sequence(xdr, &args->seq_args, &hdr);
2802 encode_putfh(xdr, args->dir_fh, &hdr);
2803 encode_secinfo(xdr, args->name, &hdr);
2808 * Encode FSID_PRESENT request
2810 static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req,
2811 struct xdr_stream *xdr,
2814 const struct nfs4_fsid_present_arg *args = data;
2815 struct compound_hdr hdr = {
2816 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2819 encode_compound_hdr(xdr, req, &hdr);
2820 encode_sequence(xdr, &args->seq_args, &hdr);
2821 encode_putfh(xdr, args->fh, &hdr);
2822 encode_getfh(xdr, &hdr);
2824 encode_renew(xdr, args->clientid, &hdr);
2828 #if defined(CONFIG_NFS_V4_1)
2830 * BIND_CONN_TO_SESSION request
2832 static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
2833 struct xdr_stream *xdr,
2836 const struct nfs41_bind_conn_to_session_args *args = data;
2837 struct compound_hdr hdr = {
2838 .minorversion = args->client->cl_mvops->minor_version,
2841 encode_compound_hdr(xdr, req, &hdr);
2842 encode_bind_conn_to_session(xdr, args, &hdr);
2847 * EXCHANGE_ID request
2849 static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req,
2850 struct xdr_stream *xdr,
2853 const struct nfs41_exchange_id_args *args = data;
2854 struct compound_hdr hdr = {
2855 .minorversion = args->client->cl_mvops->minor_version,
2858 encode_compound_hdr(xdr, req, &hdr);
2859 encode_exchange_id(xdr, args, &hdr);
2864 * a CREATE_SESSION request
2866 static void nfs4_xdr_enc_create_session(struct rpc_rqst *req,
2867 struct xdr_stream *xdr,
2870 const struct nfs41_create_session_args *args = data;
2871 struct compound_hdr hdr = {
2872 .minorversion = args->client->cl_mvops->minor_version,
2875 encode_compound_hdr(xdr, req, &hdr);
2876 encode_create_session(xdr, args, &hdr);
2881 * a DESTROY_SESSION request
2883 static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req,
2884 struct xdr_stream *xdr,
2887 const struct nfs4_session *session = data;
2888 struct compound_hdr hdr = {
2889 .minorversion = session->clp->cl_mvops->minor_version,
2892 encode_compound_hdr(xdr, req, &hdr);
2893 encode_destroy_session(xdr, session, &hdr);
2898 * a DESTROY_CLIENTID request
2900 static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req,
2901 struct xdr_stream *xdr,
2904 const struct nfs_client *clp = data;
2905 struct compound_hdr hdr = {
2906 .minorversion = clp->cl_mvops->minor_version,
2909 encode_compound_hdr(xdr, req, &hdr);
2910 encode_destroy_clientid(xdr, clp->cl_clientid, &hdr);
2915 * a SEQUENCE request
2917 static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr,
2920 const struct nfs4_sequence_args *args = data;
2921 struct compound_hdr hdr = {
2922 .minorversion = nfs4_xdr_minorversion(args),
2925 encode_compound_hdr(xdr, req, &hdr);
2926 encode_sequence(xdr, args, &hdr);
2931 * a GET_LEASE_TIME request
2933 static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req,
2934 struct xdr_stream *xdr,
2937 const struct nfs4_get_lease_time_args *args = data;
2938 struct compound_hdr hdr = {
2939 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
2941 const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME };
2943 encode_compound_hdr(xdr, req, &hdr);
2944 encode_sequence(xdr, &args->la_seq_args, &hdr);
2945 encode_putrootfh(xdr, &hdr);
2946 encode_fsinfo(xdr, lease_bitmap, &hdr);
2951 * a RECLAIM_COMPLETE request
2953 static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req,
2954 struct xdr_stream *xdr,
2957 const struct nfs41_reclaim_complete_args *args = data;
2958 struct compound_hdr hdr = {
2959 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
2962 encode_compound_hdr(xdr, req, &hdr);
2963 encode_sequence(xdr, &args->seq_args, &hdr);
2964 encode_reclaim_complete(xdr, args, &hdr);
2969 * Encode GETDEVICEINFO request
2971 static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req,
2972 struct xdr_stream *xdr,
2975 const struct nfs4_getdeviceinfo_args *args = data;
2976 struct compound_hdr hdr = {
2977 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2980 encode_compound_hdr(xdr, req, &hdr);
2981 encode_sequence(xdr, &args->seq_args, &hdr);
2982 encode_getdeviceinfo(xdr, args, &hdr);
2984 /* set up reply kvec. Subtract notification bitmap max size (2)
2985 * so that notification bitmap is put in xdr_buf tail */
2986 xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2,
2987 args->pdev->pages, args->pdev->pgbase,
2994 * Encode LAYOUTGET request
2996 static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req,
2997 struct xdr_stream *xdr,
3000 const struct nfs4_layoutget_args *args = data;
3001 struct compound_hdr hdr = {
3002 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3005 encode_compound_hdr(xdr, req, &hdr);
3006 encode_sequence(xdr, &args->seq_args, &hdr);
3007 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3008 encode_layoutget(xdr, args, &hdr);
3010 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
3011 args->layout.pages, 0, args->layout.pglen);
3017 * Encode LAYOUTCOMMIT request
3019 static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
3020 struct xdr_stream *xdr,
3023 const struct nfs4_layoutcommit_args *args = priv;
3024 struct nfs4_layoutcommit_data *data =
3025 container_of(args, struct nfs4_layoutcommit_data, args);
3026 struct compound_hdr hdr = {
3027 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3030 encode_compound_hdr(xdr, req, &hdr);
3031 encode_sequence(xdr, &args->seq_args, &hdr);
3032 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3033 encode_layoutcommit(xdr, data->args.inode, args, &hdr);
3034 encode_getfattr(xdr, args->bitmask, &hdr);
3039 * Encode LAYOUTRETURN request
3041 static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req,
3042 struct xdr_stream *xdr,
3045 const struct nfs4_layoutreturn_args *args = data;
3046 struct compound_hdr hdr = {
3047 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3050 encode_compound_hdr(xdr, req, &hdr);
3051 encode_sequence(xdr, &args->seq_args, &hdr);
3052 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3053 encode_layoutreturn(xdr, args, &hdr);
3058 * Encode SECINFO_NO_NAME request
3060 static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req,
3061 struct xdr_stream *xdr,
3064 const struct nfs41_secinfo_no_name_args *args = data;
3065 struct compound_hdr hdr = {
3066 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3069 encode_compound_hdr(xdr, req, &hdr);
3070 encode_sequence(xdr, &args->seq_args, &hdr);
3071 encode_putrootfh(xdr, &hdr);
3072 encode_secinfo_no_name(xdr, args, &hdr);
3077 * Encode TEST_STATEID request
3079 static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req,
3080 struct xdr_stream *xdr,
3083 const struct nfs41_test_stateid_args *args = data;
3084 struct compound_hdr hdr = {
3085 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3088 encode_compound_hdr(xdr, req, &hdr);
3089 encode_sequence(xdr, &args->seq_args, &hdr);
3090 encode_test_stateid(xdr, args, &hdr);
3095 * Encode FREE_STATEID request
3097 static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req,
3098 struct xdr_stream *xdr,
3101 const struct nfs41_free_stateid_args *args = data;
3102 struct compound_hdr hdr = {
3103 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3106 encode_compound_hdr(xdr, req, &hdr);
3107 encode_sequence(xdr, &args->seq_args, &hdr);
3108 encode_free_stateid(xdr, args, &hdr);
3111 #endif /* CONFIG_NFS_V4_1 */
3113 static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
3115 dprintk("nfs: %s: prematurely hit end of receive buffer. "
3116 "Remaining buffer length is %tu words.\n",
3117 func, xdr->end - xdr->p);
3120 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
3122 ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
3124 if (unlikely(ret < 0)) {
3125 if (ret == -EBADMSG)
3126 print_overflow_msg(__func__, xdr);
3133 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
3137 p = xdr_inline_decode(xdr, 8);
3140 hdr->status = be32_to_cpup(p++);
3141 hdr->taglen = be32_to_cpup(p);
3143 p = xdr_inline_decode(xdr, hdr->taglen + 4);
3146 hdr->tag = (char *)p;
3147 p += XDR_QUADLEN(hdr->taglen);
3148 hdr->nops = be32_to_cpup(p);
3149 if (unlikely(hdr->nops < 1))
3150 return nfs4_stat_to_errno(hdr->status);
3153 print_overflow_msg(__func__, xdr);
3157 static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
3164 p = xdr_inline_decode(xdr, 8);
3167 opnum = be32_to_cpup(p++);
3168 if (unlikely(opnum != expected))
3169 goto out_bad_operation;
3170 nfserr = be32_to_cpup(p);
3171 if (nfserr == NFS_OK)
3174 *nfs_retval = nfs4_stat_to_errno(nfserr);
3177 dprintk("nfs: Server returned operation"
3178 " %d but we issued a request for %d\n",
3180 *nfs_retval = -EREMOTEIO;
3183 print_overflow_msg(__func__, xdr);
3188 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
3192 __decode_op_hdr(xdr, expected, &retval);
3197 static int decode_ace(struct xdr_stream *xdr, void *ace)
3200 unsigned int strlen;
3203 p = xdr_inline_decode(xdr, 12);
3205 return decode_opaque_inline(xdr, &strlen, &str);
3206 print_overflow_msg(__func__, xdr);
3211 decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz)
3215 ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz);
3216 if (likely(ret >= 0))
3218 if (ret == -EMSGSIZE)
3220 print_overflow_msg(__func__, xdr);
3224 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
3227 ret = decode_bitmap4(xdr, bitmap, 3);
3228 return ret < 0 ? ret : 0;
3231 static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep)
3235 p = xdr_inline_decode(xdr, 4);
3238 *attrlen = be32_to_cpup(p);
3239 *savep = xdr_stream_pos(xdr);
3242 print_overflow_msg(__func__, xdr);
3246 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
3248 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
3250 ret = decode_attr_bitmap(xdr, bitmask);
3251 if (unlikely(ret < 0))
3253 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
3255 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3256 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3257 bitmask[0], bitmask[1], bitmask[2]);
3261 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
3267 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
3269 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
3270 p = xdr_inline_decode(xdr, 4);
3273 *type = be32_to_cpup(p);
3274 if (*type < NF4REG || *type > NF4NAMEDATTR) {
3275 dprintk("%s: bad type %d\n", __func__, *type);
3278 bitmap[0] &= ~FATTR4_WORD0_TYPE;
3279 ret = NFS_ATTR_FATTR_TYPE;
3281 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
3284 print_overflow_msg(__func__, xdr);
3288 static int decode_attr_fh_expire_type(struct xdr_stream *xdr,
3289 uint32_t *bitmap, uint32_t *type)
3294 if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U)))
3296 if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) {
3297 p = xdr_inline_decode(xdr, 4);
3300 *type = be32_to_cpup(p);
3301 bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE;
3303 dprintk("%s: expire type=0x%x\n", __func__, *type);
3306 print_overflow_msg(__func__, xdr);
3310 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
3316 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
3318 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
3319 p = xdr_inline_decode(xdr, 8);
3322 xdr_decode_hyper(p, change);
3323 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
3324 ret = NFS_ATTR_FATTR_CHANGE;
3326 dprintk("%s: change attribute=%Lu\n", __func__,
3327 (unsigned long long)*change);
3330 print_overflow_msg(__func__, xdr);
3334 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
3340 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
3342 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
3343 p = xdr_inline_decode(xdr, 8);
3346 xdr_decode_hyper(p, size);
3347 bitmap[0] &= ~FATTR4_WORD0_SIZE;
3348 ret = NFS_ATTR_FATTR_SIZE;
3350 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
3353 print_overflow_msg(__func__, xdr);
3357 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3362 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
3364 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
3365 p = xdr_inline_decode(xdr, 4);
3368 *res = be32_to_cpup(p);
3369 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
3371 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
3374 print_overflow_msg(__func__, xdr);
3378 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3383 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
3385 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
3386 p = xdr_inline_decode(xdr, 4);
3389 *res = be32_to_cpup(p);
3390 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
3392 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
3395 print_overflow_msg(__func__, xdr);
3399 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
3406 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
3408 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
3409 p = xdr_inline_decode(xdr, 16);
3412 p = xdr_decode_hyper(p, &fsid->major);
3413 xdr_decode_hyper(p, &fsid->minor);
3414 bitmap[0] &= ~FATTR4_WORD0_FSID;
3415 ret = NFS_ATTR_FATTR_FSID;
3417 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
3418 (unsigned long long)fsid->major,
3419 (unsigned long long)fsid->minor);
3422 print_overflow_msg(__func__, xdr);
3426 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3431 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
3433 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
3434 p = xdr_inline_decode(xdr, 4);
3437 *res = be32_to_cpup(p);
3438 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
3440 dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
3443 print_overflow_msg(__func__, xdr);
3447 static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
3451 if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U)))
3453 if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
3454 p = xdr_inline_decode(xdr, 4);
3457 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
3458 *res = -be32_to_cpup(p);
3462 print_overflow_msg(__func__, xdr);
3466 static int decode_attr_exclcreat_supported(struct xdr_stream *xdr,
3467 uint32_t *bitmap, uint32_t *bitmask)
3469 if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) {
3471 ret = decode_attr_bitmap(xdr, bitmask);
3472 if (unlikely(ret < 0))
3474 bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT;
3476 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3477 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3478 bitmask[0], bitmask[1], bitmask[2]);
3482 static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
3488 memset(fh, 0, sizeof(*fh));
3490 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
3492 if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
3493 p = xdr_inline_decode(xdr, 4);
3496 len = be32_to_cpup(p);
3497 if (len > NFS4_FHSIZE)
3499 p = xdr_inline_decode(xdr, len);
3503 memcpy(fh->data, p, len);
3506 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
3510 print_overflow_msg(__func__, xdr);
3514 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3519 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
3521 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
3522 p = xdr_inline_decode(xdr, 4);
3525 *res = be32_to_cpup(p);
3526 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
3528 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
3531 print_overflow_msg(__func__, xdr);
3535 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3541 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
3543 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
3544 p = xdr_inline_decode(xdr, 8);
3547 xdr_decode_hyper(p, fileid);
3548 bitmap[0] &= ~FATTR4_WORD0_FILEID;
3549 ret = NFS_ATTR_FATTR_FILEID;
3551 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3554 print_overflow_msg(__func__, xdr);
3558 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3564 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
3566 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
3567 p = xdr_inline_decode(xdr, 8);
3570 xdr_decode_hyper(p, fileid);
3571 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
3572 ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
3574 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3577 print_overflow_msg(__func__, xdr);
3581 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3587 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
3589 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
3590 p = xdr_inline_decode(xdr, 8);
3593 xdr_decode_hyper(p, res);
3594 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
3596 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
3599 print_overflow_msg(__func__, xdr);
3603 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3609 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
3611 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
3612 p = xdr_inline_decode(xdr, 8);
3615 xdr_decode_hyper(p, res);
3616 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
3618 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
3621 print_overflow_msg(__func__, xdr);
3625 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3631 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
3633 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
3634 p = xdr_inline_decode(xdr, 8);
3637 xdr_decode_hyper(p, res);
3638 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
3640 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
3643 print_overflow_msg(__func__, xdr);
3647 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3653 p = xdr_inline_decode(xdr, 4);
3656 n = be32_to_cpup(p);
3659 dprintk("pathname4: ");
3660 if (n > NFS4_PATHNAME_MAXCOMPONENTS) {
3661 dprintk("cannot parse %d components in path\n", n);
3664 for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) {
3665 struct nfs4_string *component = &path->components[path->ncomponents];
3666 status = decode_opaque_inline(xdr, &component->len, &component->data);
3667 if (unlikely(status != 0))
3671 (path->ncomponents != n ? "/ " : ""),
3672 component->len, component->data);
3677 /* a root pathname is sent as a zero component4 */
3678 path->ncomponents = 1;
3679 path->components[0].len=0;
3680 path->components[0].data=NULL;
3681 dprintk("pathname4: /\n");
3684 dprintk(" status %d", status);
3688 print_overflow_msg(__func__, xdr);
3692 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
3698 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
3701 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
3703 bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS;
3705 /* Ignore borken servers that return unrequested attrs */
3706 if (unlikely(res == NULL))
3708 dprintk("%s: fsroot:\n", __func__);
3709 status = decode_pathname(xdr, &res->fs_path);
3710 if (unlikely(status != 0))
3712 p = xdr_inline_decode(xdr, 4);
3715 n = be32_to_cpup(p);
3718 for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
3720 struct nfs4_fs_location *loc;
3722 if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES)
3724 loc = &res->locations[res->nlocations];
3725 p = xdr_inline_decode(xdr, 4);
3728 m = be32_to_cpup(p);
3730 dprintk("%s: servers:\n", __func__);
3731 for (loc->nservers = 0; loc->nservers < m; loc->nservers++) {
3732 struct nfs4_string *server;
3734 if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) {
3736 dprintk("%s: using first %u of %u servers "
3737 "returned for location %u\n",
3739 NFS4_FS_LOCATION_MAXSERVERS,
3740 m, res->nlocations);
3741 for (i = loc->nservers; i < m; i++) {
3744 status = decode_opaque_inline(xdr, &len, &data);
3745 if (unlikely(status != 0))
3750 server = &loc->servers[loc->nservers];
3751 status = decode_opaque_inline(xdr, &server->len, &server->data);
3752 if (unlikely(status != 0))
3754 dprintk("%s ", server->data);
3756 status = decode_pathname(xdr, &loc->rootpath);
3757 if (unlikely(status != 0))
3760 if (res->nlocations != 0)
3761 status = NFS_ATTR_FATTR_V4_LOCATIONS;
3763 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
3766 print_overflow_msg(__func__, xdr);
3772 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3778 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
3780 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
3781 p = xdr_inline_decode(xdr, 8);
3784 xdr_decode_hyper(p, res);
3785 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
3787 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
3790 print_overflow_msg(__func__, xdr);
3794 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
3800 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
3802 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
3803 p = xdr_inline_decode(xdr, 4);
3806 *maxlink = be32_to_cpup(p);
3807 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
3809 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
3812 print_overflow_msg(__func__, xdr);
3816 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
3822 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
3824 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
3825 p = xdr_inline_decode(xdr, 4);
3828 *maxname = be32_to_cpup(p);
3829 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
3831 dprintk("%s: maxname=%u\n", __func__, *maxname);
3834 print_overflow_msg(__func__, xdr);
3838 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3844 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
3846 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
3848 p = xdr_inline_decode(xdr, 8);
3851 xdr_decode_hyper(p, &maxread);
3852 if (maxread > 0x7FFFFFFF)
3853 maxread = 0x7FFFFFFF;
3854 *res = (uint32_t)maxread;
3855 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
3857 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
3860 print_overflow_msg(__func__, xdr);
3864 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3870 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
3872 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
3874 p = xdr_inline_decode(xdr, 8);
3877 xdr_decode_hyper(p, &maxwrite);
3878 if (maxwrite > 0x7FFFFFFF)
3879 maxwrite = 0x7FFFFFFF;
3880 *res = (uint32_t)maxwrite;
3881 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
3883 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
3886 print_overflow_msg(__func__, xdr);
3890 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
3897 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
3899 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
3900 p = xdr_inline_decode(xdr, 4);
3903 tmp = be32_to_cpup(p);
3904 *mode = tmp & ~S_IFMT;
3905 bitmap[1] &= ~FATTR4_WORD1_MODE;
3906 ret = NFS_ATTR_FATTR_MODE;
3908 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
3911 print_overflow_msg(__func__, xdr);
3915 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
3921 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
3923 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
3924 p = xdr_inline_decode(xdr, 4);
3927 *nlink = be32_to_cpup(p);
3928 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
3929 ret = NFS_ATTR_FATTR_NLINK;
3931 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
3934 print_overflow_msg(__func__, xdr);
3938 static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
3939 struct nfs4_string *name, gfp_t gfp_flags)
3943 ret = xdr_stream_decode_string_dup(xdr, &name->data,
3944 XDR_MAX_NETOBJ, gfp_flags);
3951 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3952 const struct nfs_server *server, kuid_t *uid,
3953 struct nfs4_string *owner_name)
3958 *uid = make_kuid(&init_user_ns, -2);
3959 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3961 if (!(bitmap[1] & FATTR4_WORD1_OWNER))
3963 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3965 if (owner_name != NULL) {
3966 len = decode_nfs4_string(xdr, owner_name, GFP_NOIO);
3969 dprintk("%s: name=%s\n", __func__, owner_name->data);
3970 return NFS_ATTR_FATTR_OWNER_NAME;
3972 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
3974 if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0)
3976 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
3977 return NFS_ATTR_FATTR_OWNER;
3980 if (len != -EBADMSG)
3982 print_overflow_msg(__func__, xdr);
3986 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3987 const struct nfs_server *server, kgid_t *gid,
3988 struct nfs4_string *group_name)
3993 *gid = make_kgid(&init_user_ns, -2);
3994 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
3996 if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP))
3998 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
4000 if (group_name != NULL) {
4001 len = decode_nfs4_string(xdr, group_name, GFP_NOIO);
4004 dprintk("%s: name=%s\n", __func__, group_name->data);
4005 return NFS_ATTR_FATTR_GROUP_NAME;
4007 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
4009 if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0)
4011 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
4012 return NFS_ATTR_FATTR_GROUP;
4015 if (len != -EBADMSG)
4017 print_overflow_msg(__func__, xdr);
4021 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
4023 uint32_t major = 0, minor = 0;
4028 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
4030 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
4033 p = xdr_inline_decode(xdr, 8);
4036 major = be32_to_cpup(p++);
4037 minor = be32_to_cpup(p);
4038 tmp = MKDEV(major, minor);
4039 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
4041 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
4042 ret = NFS_ATTR_FATTR_RDEV;
4044 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
4047 print_overflow_msg(__func__, xdr);
4051 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4057 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
4059 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
4060 p = xdr_inline_decode(xdr, 8);
4063 xdr_decode_hyper(p, res);
4064 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
4066 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
4069 print_overflow_msg(__func__, xdr);
4073 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4079 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
4081 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
4082 p = xdr_inline_decode(xdr, 8);
4085 xdr_decode_hyper(p, res);
4086 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
4088 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
4091 print_overflow_msg(__func__, xdr);
4095 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4101 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
4103 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
4104 p = xdr_inline_decode(xdr, 8);
4107 xdr_decode_hyper(p, res);
4108 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
4110 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
4113 print_overflow_msg(__func__, xdr);
4117 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
4123 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
4125 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
4126 p = xdr_inline_decode(xdr, 8);
4129 xdr_decode_hyper(p, used);
4130 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
4131 ret = NFS_ATTR_FATTR_SPACE_USED;
4133 dprintk("%s: space used=%Lu\n", __func__,
4134 (unsigned long long)*used);
4137 print_overflow_msg(__func__, xdr);
4142 xdr_decode_nfstime4(__be32 *p, struct timespec *t)
4146 p = xdr_decode_hyper(p, &sec);
4147 t-> tv_sec = (time_t)sec;
4148 t->tv_nsec = be32_to_cpup(p++);
4152 static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
4156 p = xdr_inline_decode(xdr, nfstime4_maxsz << 2);
4159 xdr_decode_nfstime4(p, time);
4162 print_overflow_msg(__func__, xdr);
4166 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4172 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
4174 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
4175 status = decode_attr_time(xdr, time);
4177 status = NFS_ATTR_FATTR_ATIME;
4178 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
4180 dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
4184 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4190 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
4192 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
4193 status = decode_attr_time(xdr, time);
4195 status = NFS_ATTR_FATTR_CTIME;
4196 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
4198 dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
4202 static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
4203 struct timespec *time)
4209 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U)))
4211 if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) {
4212 status = decode_attr_time(xdr, time);
4213 bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
4215 dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec,
4216 (long)time->tv_nsec);
4220 static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
4221 struct nfs4_label *label)
4229 if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
4231 if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
4232 p = xdr_inline_decode(xdr, 4);
4235 lfs = be32_to_cpup(p++);
4236 p = xdr_inline_decode(xdr, 4);
4239 pi = be32_to_cpup(p++);
4240 p = xdr_inline_decode(xdr, 4);
4243 len = be32_to_cpup(p++);
4244 p = xdr_inline_decode(xdr, len);
4247 if (len < NFS4_MAXLABELLEN) {
4249 memcpy(label->label, p, len);
4253 status = NFS_ATTR_FATTR_V4_SECURITY_LABEL;
4255 bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
4257 printk(KERN_WARNING "%s: label too long (%u)!\n",
4260 if (label && label->label)
4261 dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__,
4262 (char *)label->label, label->len, label->pi, label->lfs);
4266 print_overflow_msg(__func__, xdr);
4270 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
4276 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
4278 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
4279 status = decode_attr_time(xdr, time);
4281 status = NFS_ATTR_FATTR_MTIME;
4282 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
4284 dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
4288 static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
4290 unsigned int attrwords = XDR_QUADLEN(attrlen);
4291 unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2;
4293 if (unlikely(attrwords != nwords)) {
4294 dprintk("%s: server returned incorrect attribute length: "
4298 (attrwords < nwords) ? '<' : '>',
4305 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4309 p = xdr_inline_decode(xdr, 20);
4312 cinfo->atomic = be32_to_cpup(p++);
4313 p = xdr_decode_hyper(p, &cinfo->before);
4314 xdr_decode_hyper(p, &cinfo->after);
4317 print_overflow_msg(__func__, xdr);
4321 static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
4327 status = decode_op_hdr(xdr, OP_ACCESS);
4330 p = xdr_inline_decode(xdr, 8);
4333 supp = be32_to_cpup(p++);
4334 acc = be32_to_cpup(p);
4339 print_overflow_msg(__func__, xdr);
4343 static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
4345 ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
4346 if (unlikely(ret < 0)) {
4347 print_overflow_msg(__func__, xdr);
4353 static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4355 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4358 static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4360 stateid->type = NFS4_OPEN_STATEID_TYPE;
4361 return decode_stateid(xdr, stateid);
4364 static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4366 stateid->type = NFS4_LOCK_STATEID_TYPE;
4367 return decode_stateid(xdr, stateid);
4370 static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4372 stateid->type = NFS4_DELEGATION_STATEID_TYPE;
4373 return decode_stateid(xdr, stateid);
4376 static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4380 nfs4_stateid_copy(stateid, &invalid_stateid);
4381 return decode_stateid(xdr, &dummy);
4384 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4388 status = decode_op_hdr(xdr, OP_CLOSE);
4390 nfs_increment_open_seqid(status, res->seqid);
4392 status = decode_invalid_stateid(xdr, &res->stateid);
4396 static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4398 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4401 static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
4403 return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
4406 static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
4410 status = decode_op_hdr(xdr, OP_COMMIT);
4412 status = decode_write_verifier(xdr, &res->verf->verifier);
4416 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4422 status = decode_op_hdr(xdr, OP_CREATE);
4425 if ((status = decode_change_info(xdr, cinfo)))
4427 p = xdr_inline_decode(xdr, 4);
4430 bmlen = be32_to_cpup(p);
4431 p = xdr_inline_decode(xdr, bmlen << 2);
4435 print_overflow_msg(__func__, xdr);
4439 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
4442 uint32_t attrlen, bitmap[3] = {0};
4445 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4447 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4449 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4451 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
4453 if ((status = decode_attr_fh_expire_type(xdr, bitmap,
4454 &res->fh_expire_type)) != 0)
4456 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
4458 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
4460 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
4462 if ((status = decode_attr_exclcreat_supported(xdr, bitmap,
4463 res->exclcreat_bitmask)) != 0)
4465 status = verify_attr_len(xdr, savep, attrlen);
4467 dprintk("%s: xdr returned %d!\n", __func__, -status);
4471 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
4474 uint32_t attrlen, bitmap[3] = {0};
4477 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4479 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4481 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4484 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
4486 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
4488 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
4492 if (unlikely(bitmap[0]))
4495 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
4497 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
4499 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
4502 status = verify_attr_len(xdr, savep, attrlen);
4504 dprintk("%s: xdr returned %d!\n", __func__, -status);
4508 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
4511 uint32_t attrlen, bitmap[3] = {0};
4514 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4516 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4518 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4521 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
4523 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
4526 status = verify_attr_len(xdr, savep, attrlen);
4528 dprintk("%s: xdr returned %d!\n", __func__, -status);
4532 static int decode_threshold_hint(struct xdr_stream *xdr,
4540 if (likely(bitmap[0] & hint_bit)) {
4541 p = xdr_inline_decode(xdr, 8);
4544 xdr_decode_hyper(p, res);
4548 print_overflow_msg(__func__, xdr);
4552 static int decode_first_threshold_item4(struct xdr_stream *xdr,
4553 struct nfs4_threshold *res)
4557 uint32_t bitmap[3] = {0,}, attrlen;
4561 p = xdr_inline_decode(xdr, 4);
4563 print_overflow_msg(__func__, xdr);
4566 res->l_type = be32_to_cpup(p);
4568 /* thi_hintset bitmap */
4569 status = decode_attr_bitmap(xdr, bitmap);
4573 /* thi_hintlist length */
4574 status = decode_attr_length(xdr, &attrlen, &savep);
4578 status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD);
4581 status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR);
4584 status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz,
4588 status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz,
4593 status = verify_attr_len(xdr, savep, attrlen);
4594 res->bm = bitmap[0];
4596 dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n",
4597 __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz,
4600 dprintk("%s ret=%d!\n", __func__, status);
4605 * Thresholds on pNFS direct I/O vrs MDS I/O
4607 static int decode_attr_mdsthreshold(struct xdr_stream *xdr,
4609 struct nfs4_threshold *res)
4615 if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U)))
4617 if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) {
4618 /* Did the server return an unrequested attribute? */
4619 if (unlikely(res == NULL))
4621 p = xdr_inline_decode(xdr, 4);
4624 num = be32_to_cpup(p);
4628 printk(KERN_INFO "%s: Warning: Multiple pNFS layout "
4629 "drivers per filesystem not supported\n",
4632 status = decode_first_threshold_item4(xdr, res);
4633 bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
4637 print_overflow_msg(__func__, xdr);
4641 static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
4642 struct nfs_fattr *fattr, struct nfs_fh *fh,
4643 struct nfs4_fs_locations *fs_loc, struct nfs4_label *label,
4644 const struct nfs_server *server)
4651 status = decode_attr_type(xdr, bitmap, &type);
4656 fattr->mode |= nfs_type2fmt[type];
4657 fattr->valid |= status;
4660 status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
4663 fattr->valid |= status;
4665 status = decode_attr_size(xdr, bitmap, &fattr->size);
4668 fattr->valid |= status;
4670 status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
4673 fattr->valid |= status;
4676 status = decode_attr_error(xdr, bitmap, &err);
4680 status = decode_attr_filehandle(xdr, bitmap, fh);
4684 status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
4687 fattr->valid |= status;
4689 status = decode_attr_fs_locations(xdr, bitmap, fs_loc);
4692 fattr->valid |= status;
4695 if (unlikely(bitmap[0]))
4698 status = decode_attr_mode(xdr, bitmap, &fmode);
4702 fattr->mode |= fmode;
4703 fattr->valid |= status;
4706 status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
4709 fattr->valid |= status;
4711 status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name);
4714 fattr->valid |= status;
4716 status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name);
4719 fattr->valid |= status;
4721 status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
4724 fattr->valid |= status;
4726 status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
4729 fattr->valid |= status;
4731 status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
4734 fattr->valid |= status;
4736 status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
4739 fattr->valid |= status;
4741 status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
4744 fattr->valid |= status;
4746 status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid);
4749 fattr->valid |= status;
4752 if (unlikely(bitmap[1]))
4755 status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold);
4760 status = decode_attr_security_label(xdr, bitmap, label);
4763 fattr->valid |= status;
4767 dprintk("%s: xdr returned %d\n", __func__, -status);
4771 static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4772 struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc,
4773 struct nfs4_label *label, const struct nfs_server *server)
4780 status = decode_op_hdr(xdr, OP_GETATTR);
4784 status = decode_attr_bitmap(xdr, bitmap);
4788 status = decode_attr_length(xdr, &attrlen, &savep);
4792 status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc,
4797 status = verify_attr_len(xdr, savep, attrlen);
4799 dprintk("%s: xdr returned %d\n", __func__, -status);
4803 static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4804 struct nfs4_label *label, const struct nfs_server *server)
4806 return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server);
4809 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4810 const struct nfs_server *server)
4812 return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server);
4816 * Decode potentially multiple layout types.
4818 static int decode_pnfs_layout_types(struct xdr_stream *xdr,
4819 struct nfs_fsinfo *fsinfo)
4824 p = xdr_inline_decode(xdr, 4);
4827 fsinfo->nlayouttypes = be32_to_cpup(p);
4829 /* pNFS is not supported by the underlying file system */
4830 if (fsinfo->nlayouttypes == 0)
4833 /* Decode and set first layout type, move xdr->p past unused types */
4834 p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
4838 /* If we get too many, then just cap it at the max */
4839 if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
4840 printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n",
4841 __func__, fsinfo->nlayouttypes);
4842 fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES;
4845 for(i = 0; i < fsinfo->nlayouttypes; ++i)
4846 fsinfo->layouttype[i] = be32_to_cpup(p++);
4849 print_overflow_msg(__func__, xdr);
4854 * The type of file system exported.
4855 * Note we must ensure that layouttype is set in any non-error case.
4857 static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
4858 struct nfs_fsinfo *fsinfo)
4862 dprintk("%s: bitmap is %x\n", __func__, bitmap[1]);
4863 if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U)))
4865 if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) {
4866 status = decode_pnfs_layout_types(xdr, fsinfo);
4867 bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES;
4873 * The prefered block size for layout directed io
4875 static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4880 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4882 if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) {
4883 p = xdr_inline_decode(xdr, 4);
4885 print_overflow_msg(__func__, xdr);
4888 *res = be32_to_cpup(p);
4889 bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE;
4895 * The granularity of a CLONE operation.
4897 static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4902 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4904 if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
4905 p = xdr_inline_decode(xdr, 4);
4907 print_overflow_msg(__func__, xdr);
4910 *res = be32_to_cpup(p);
4911 bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE;
4916 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
4919 uint32_t attrlen, bitmap[3];
4922 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4924 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4926 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4929 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
4931 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
4933 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
4935 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
4937 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
4938 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
4940 fsinfo->wtpref = fsinfo->wtmax;
4943 if (unlikely(bitmap[0]))
4946 status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta);
4949 status = decode_attr_pnfstype(xdr, bitmap, fsinfo);
4954 if (unlikely(bitmap[1]))
4957 status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize);
4960 status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize);
4964 status = verify_attr_len(xdr, savep, attrlen);
4966 dprintk("%s: xdr returned %d!\n", __func__, -status);
4970 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
4976 /* Zero handle first to allow comparisons */
4977 memset(fh, 0, sizeof(*fh));
4979 status = decode_op_hdr(xdr, OP_GETFH);
4983 p = xdr_inline_decode(xdr, 4);
4986 len = be32_to_cpup(p);
4987 if (len > NFS4_FHSIZE)
4990 p = xdr_inline_decode(xdr, len);
4993 memcpy(fh->data, p, len);
4996 print_overflow_msg(__func__, xdr);
5000 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5004 status = decode_op_hdr(xdr, OP_LINK);
5007 return decode_change_info(xdr, cinfo);
5011 * We create the owner, so we know a proper owner.id length is 4.
5013 static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
5015 uint64_t offset, length, clientid;
5017 uint32_t namelen, type;
5019 p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
5022 p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
5023 p = xdr_decode_hyper(p, &length);
5024 type = be32_to_cpup(p++); /* 4 byte read */
5025 if (fl != NULL) { /* manipulate file lock */
5026 fl->fl_start = (loff_t)offset;
5027 fl->fl_end = fl->fl_start + (loff_t)length - 1;
5028 if (length == ~(uint64_t)0)
5029 fl->fl_end = OFFSET_MAX;
5030 fl->fl_type = F_WRLCK;
5032 fl->fl_type = F_RDLCK;
5035 p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
5036 namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */
5037 p = xdr_inline_decode(xdr, namelen); /* variable size field */
5039 return -NFS4ERR_DENIED;
5041 print_overflow_msg(__func__, xdr);
5045 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
5049 status = decode_op_hdr(xdr, OP_LOCK);
5053 status = decode_lock_stateid(xdr, &res->stateid);
5054 if (unlikely(status))
5056 } else if (status == -NFS4ERR_DENIED)
5057 status = decode_lock_denied(xdr, NULL);
5058 if (res->open_seqid != NULL)
5059 nfs_increment_open_seqid(status, res->open_seqid);
5060 nfs_increment_lock_seqid(status, res->lock_seqid);
5065 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
5068 status = decode_op_hdr(xdr, OP_LOCKT);
5069 if (status == -NFS4ERR_DENIED)
5070 return decode_lock_denied(xdr, res->denied);
5074 static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
5078 status = decode_op_hdr(xdr, OP_LOCKU);
5080 nfs_increment_lock_seqid(status, res->seqid);
5082 status = decode_lock_stateid(xdr, &res->stateid);
5086 static int decode_release_lockowner(struct xdr_stream *xdr)
5088 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
5091 static int decode_lookup(struct xdr_stream *xdr)
5093 return decode_op_hdr(xdr, OP_LOOKUP);
5096 static int decode_lookupp(struct xdr_stream *xdr)
5098 return decode_op_hdr(xdr, OP_LOOKUPP);
5101 /* This is too sick! */
5102 static int decode_space_limit(struct xdr_stream *xdr,
5103 unsigned long *pagemod_limit)
5106 uint32_t limit_type, nblocks, blocksize;
5109 p = xdr_inline_decode(xdr, 12);
5112 limit_type = be32_to_cpup(p++);
5113 switch (limit_type) {
5114 case NFS4_LIMIT_SIZE:
5115 xdr_decode_hyper(p, &maxsize);
5117 case NFS4_LIMIT_BLOCKS:
5118 nblocks = be32_to_cpup(p++);
5119 blocksize = be32_to_cpup(p);
5120 maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
5122 maxsize >>= PAGE_SHIFT;
5123 *pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
5126 print_overflow_msg(__func__, xdr);
5130 static int decode_rw_delegation(struct xdr_stream *xdr,
5131 uint32_t delegation_type,
5132 struct nfs_openres *res)
5137 status = decode_delegation_stateid(xdr, &res->delegation);
5138 if (unlikely(status))
5140 p = xdr_inline_decode(xdr, 4);
5143 res->do_recall = be32_to_cpup(p);
5145 switch (delegation_type) {
5146 case NFS4_OPEN_DELEGATE_READ:
5147 res->delegation_type = FMODE_READ;
5149 case NFS4_OPEN_DELEGATE_WRITE:
5150 res->delegation_type = FMODE_WRITE|FMODE_READ;
5151 if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
5154 return decode_ace(xdr, NULL);
5156 print_overflow_msg(__func__, xdr);
5160 static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5163 uint32_t why_no_delegation;
5165 p = xdr_inline_decode(xdr, 4);
5168 why_no_delegation = be32_to_cpup(p);
5169 switch (why_no_delegation) {
5170 case WND4_CONTENTION:
5172 xdr_inline_decode(xdr, 4);
5173 /* Ignore for now */
5177 print_overflow_msg(__func__, xdr);
5181 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5184 uint32_t delegation_type;
5186 p = xdr_inline_decode(xdr, 4);
5189 delegation_type = be32_to_cpup(p);
5190 res->delegation_type = 0;
5191 switch (delegation_type) {
5192 case NFS4_OPEN_DELEGATE_NONE:
5194 case NFS4_OPEN_DELEGATE_READ:
5195 case NFS4_OPEN_DELEGATE_WRITE:
5196 return decode_rw_delegation(xdr, delegation_type, res);
5197 case NFS4_OPEN_DELEGATE_NONE_EXT:
5198 return decode_no_delegation(xdr, res);
5202 print_overflow_msg(__func__, xdr);
5206 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
5209 uint32_t savewords, bmlen, i;
5212 if (!__decode_op_hdr(xdr, OP_OPEN, &status))
5214 nfs_increment_open_seqid(status, res->seqid);
5217 status = decode_open_stateid(xdr, &res->stateid);
5218 if (unlikely(status))
5221 decode_change_info(xdr, &res->cinfo);
5223 p = xdr_inline_decode(xdr, 8);
5226 res->rflags = be32_to_cpup(p++);
5227 bmlen = be32_to_cpup(p);
5231 p = xdr_inline_decode(xdr, bmlen << 2);
5234 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
5235 for (i = 0; i < savewords; ++i)
5236 res->attrset[i] = be32_to_cpup(p++);
5237 for (; i < NFS4_BITMAP_SIZE; i++)
5238 res->attrset[i] = 0;
5240 return decode_delegation(xdr, res);
5242 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
5245 print_overflow_msg(__func__, xdr);
5249 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
5253 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
5255 nfs_increment_open_seqid(status, res->seqid);
5257 status = decode_open_stateid(xdr, &res->stateid);
5261 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
5265 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
5267 nfs_increment_open_seqid(status, res->seqid);
5269 status = decode_open_stateid(xdr, &res->stateid);
5273 static int decode_putfh(struct xdr_stream *xdr)
5275 return decode_op_hdr(xdr, OP_PUTFH);
5278 static int decode_putrootfh(struct xdr_stream *xdr)
5280 return decode_op_hdr(xdr, OP_PUTROOTFH);
5283 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req,
5284 struct nfs_pgio_res *res)
5287 uint32_t count, eof, recvd;
5290 status = decode_op_hdr(xdr, OP_READ);
5293 p = xdr_inline_decode(xdr, 8);
5296 eof = be32_to_cpup(p++);
5297 count = be32_to_cpup(p);
5298 recvd = xdr_read_pages(xdr, count);
5299 if (count > recvd) {
5300 dprintk("NFS: server cheating in read reply: "
5301 "count %u > recvd %u\n", count, recvd);
5309 print_overflow_msg(__func__, xdr);
5313 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
5318 status = decode_op_hdr(xdr, OP_READDIR);
5320 status = decode_verifier(xdr, readdir->verifier.data);
5321 if (unlikely(status))
5323 memcpy(verf, readdir->verifier.data, sizeof(verf));
5324 dprintk("%s: verifier = %08x:%08x\n",
5325 __func__, verf[0], verf[1]);
5326 return xdr_read_pages(xdr, xdr->buf->page_len);
5329 static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
5331 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
5336 status = decode_op_hdr(xdr, OP_READLINK);
5340 /* Convert length of symlink */
5341 p = xdr_inline_decode(xdr, 4);
5344 len = be32_to_cpup(p);
5345 if (len >= rcvbuf->page_len || len <= 0) {
5346 dprintk("nfs: server returned giant symlink!\n");
5347 return -ENAMETOOLONG;
5349 recvd = xdr_read_pages(xdr, len);
5351 dprintk("NFS: server cheating in readlink reply: "
5352 "count %u > recvd %u\n", len, recvd);
5356 * The XDR encode routine has set things up so that
5357 * the link text will be copied directly into the
5358 * buffer. We just have to do overflow-checking,
5359 * and and null-terminate the text (the VFS expects
5360 * null-termination).
5362 xdr_terminate_string(rcvbuf, len);
5365 print_overflow_msg(__func__, xdr);
5369 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5373 status = decode_op_hdr(xdr, OP_REMOVE);
5376 status = decode_change_info(xdr, cinfo);
5381 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
5382 struct nfs4_change_info *new_cinfo)
5386 status = decode_op_hdr(xdr, OP_RENAME);
5389 if ((status = decode_change_info(xdr, old_cinfo)))
5391 status = decode_change_info(xdr, new_cinfo);
5396 static int decode_renew(struct xdr_stream *xdr)
5398 return decode_op_hdr(xdr, OP_RENEW);
5402 decode_restorefh(struct xdr_stream *xdr)
5404 return decode_op_hdr(xdr, OP_RESTOREFH);
5407 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
5408 struct nfs_getaclres *res)
5414 unsigned int pg_offset;
5417 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
5420 xdr_enter_page(xdr, xdr->buf->page_len);
5422 /* Calculate the offset of the page data */
5423 pg_offset = xdr->buf->head[0].iov_len;
5425 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
5427 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
5430 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
5432 if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
5434 /* The bitmap (xdr len + bitmaps) and the attr xdr len words
5435 * are stored with the acl data to handle the problem of
5436 * variable length bitmaps.*/
5437 res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset;
5438 res->acl_len = attrlen;
5440 /* Check for receive buffer overflow */
5441 if (res->acl_len > (xdr->nwords << 2) ||
5442 res->acl_len + res->acl_data_offset > xdr->buf->page_len) {
5443 res->acl_flags |= NFS4_ACL_TRUNC;
5444 dprintk("NFS: acl reply: attrlen %u > page_len %u\n",
5445 attrlen, xdr->nwords << 2);
5448 status = -EOPNOTSUPP;
5455 decode_savefh(struct xdr_stream *xdr)
5457 return decode_op_hdr(xdr, OP_SAVEFH);
5460 static int decode_setattr(struct xdr_stream *xdr)
5464 status = decode_op_hdr(xdr, OP_SETATTR);
5467 if (decode_bitmap4(xdr, NULL, 0) >= 0)
5469 print_overflow_msg(__func__, xdr);
5473 static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
5479 p = xdr_inline_decode(xdr, 8);
5482 opnum = be32_to_cpup(p++);
5483 if (opnum != OP_SETCLIENTID) {
5484 dprintk("nfs: decode_setclientid: Server returned operation"
5488 nfserr = be32_to_cpup(p);
5489 if (nfserr == NFS_OK) {
5490 p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
5493 p = xdr_decode_hyper(p, &res->clientid);
5494 memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
5495 } else if (nfserr == NFSERR_CLID_INUSE) {
5498 /* skip netid string */
5499 p = xdr_inline_decode(xdr, 4);
5502 len = be32_to_cpup(p);
5503 p = xdr_inline_decode(xdr, len);
5507 /* skip uaddr string */
5508 p = xdr_inline_decode(xdr, 4);
5511 len = be32_to_cpup(p);
5512 p = xdr_inline_decode(xdr, len);
5515 return -NFSERR_CLID_INUSE;
5517 return nfs4_stat_to_errno(nfserr);
5521 print_overflow_msg(__func__, xdr);
5525 static int decode_setclientid_confirm(struct xdr_stream *xdr)
5527 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
5530 static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res)
5535 status = decode_op_hdr(xdr, OP_WRITE);
5539 p = xdr_inline_decode(xdr, 8);
5542 res->count = be32_to_cpup(p++);
5543 res->verf->committed = be32_to_cpup(p++);
5544 return decode_write_verifier(xdr, &res->verf->verifier);
5546 print_overflow_msg(__func__, xdr);
5550 static int decode_delegreturn(struct xdr_stream *xdr)
5552 return decode_op_hdr(xdr, OP_DELEGRETURN);
5555 static int decode_secinfo_gss(struct xdr_stream *xdr,
5556 struct nfs4_secinfo4 *flavor)
5561 p = xdr_inline_decode(xdr, 4);
5564 oid_len = be32_to_cpup(p);
5565 if (oid_len > GSS_OID_MAX_LEN)
5568 p = xdr_inline_decode(xdr, oid_len);
5571 memcpy(flavor->flavor_info.oid.data, p, oid_len);
5572 flavor->flavor_info.oid.len = oid_len;
5574 p = xdr_inline_decode(xdr, 8);
5577 flavor->flavor_info.qop = be32_to_cpup(p++);
5578 flavor->flavor_info.service = be32_to_cpup(p);
5583 print_overflow_msg(__func__, xdr);
5589 static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5591 struct nfs4_secinfo4 *sec_flavor;
5592 unsigned int i, num_flavors;
5596 p = xdr_inline_decode(xdr, 4);
5600 res->flavors->num_flavors = 0;
5601 num_flavors = be32_to_cpup(p);
5603 for (i = 0; i < num_flavors; i++) {
5604 sec_flavor = &res->flavors->flavors[i];
5605 if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE)
5608 p = xdr_inline_decode(xdr, 4);
5611 sec_flavor->flavor = be32_to_cpup(p);
5613 if (sec_flavor->flavor == RPC_AUTH_GSS) {
5614 status = decode_secinfo_gss(xdr, sec_flavor);
5618 res->flavors->num_flavors++;
5625 print_overflow_msg(__func__, xdr);
5629 static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5631 int status = decode_op_hdr(xdr, OP_SECINFO);
5634 return decode_secinfo_common(xdr, res);
5637 #if defined(CONFIG_NFS_V4_1)
5638 static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5640 int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME);
5643 return decode_secinfo_common(xdr, res);
5646 static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map)
5649 uint32_t bitmap_words;
5652 p = xdr_inline_decode(xdr, 4);
5655 bitmap_words = be32_to_cpup(p++);
5656 if (bitmap_words > NFS4_OP_MAP_NUM_WORDS)
5658 p = xdr_inline_decode(xdr, 4 * bitmap_words);
5659 for (i = 0; i < bitmap_words; i++)
5660 op_map->u.words[i] = be32_to_cpup(p++);
5665 static int decode_exchange_id(struct xdr_stream *xdr,
5666 struct nfs41_exchange_id_res *res)
5672 uint32_t impl_id_count;
5674 status = decode_op_hdr(xdr, OP_EXCHANGE_ID);
5678 p = xdr_inline_decode(xdr, 8);
5681 xdr_decode_hyper(p, &res->clientid);
5682 p = xdr_inline_decode(xdr, 12);
5685 res->seqid = be32_to_cpup(p++);
5686 res->flags = be32_to_cpup(p++);
5688 res->state_protect.how = be32_to_cpup(p);
5689 switch (res->state_protect.how) {
5693 status = decode_op_map(xdr, &res->state_protect.enforce);
5696 status = decode_op_map(xdr, &res->state_protect.allow);
5705 /* server_owner4.so_minor_id */
5706 p = xdr_inline_decode(xdr, 8);
5709 p = xdr_decode_hyper(p, &res->server_owner->minor_id);
5711 /* server_owner4.so_major_id */
5712 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5713 if (unlikely(status))
5715 memcpy(res->server_owner->major_id, dummy_str, dummy);
5716 res->server_owner->major_id_sz = dummy;
5719 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5720 if (unlikely(status))
5722 memcpy(res->server_scope->server_scope, dummy_str, dummy);
5723 res->server_scope->server_scope_sz = dummy;
5725 /* Implementation Id */
5726 p = xdr_inline_decode(xdr, 4);
5729 impl_id_count = be32_to_cpup(p++);
5731 if (impl_id_count) {
5733 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5734 if (unlikely(status))
5736 memcpy(res->impl_id->domain, dummy_str, dummy);
5739 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5740 if (unlikely(status))
5742 memcpy(res->impl_id->name, dummy_str, dummy);
5745 p = xdr_inline_decode(xdr, 12);
5748 p = xdr_decode_hyper(p, &res->impl_id->date.seconds);
5749 res->impl_id->date.nseconds = be32_to_cpup(p);
5751 /* if there's more than one entry, ignore the rest */
5755 print_overflow_msg(__func__, xdr);
5759 static int decode_chan_attrs(struct xdr_stream *xdr,
5760 struct nfs4_channel_attrs *attrs)
5765 p = xdr_inline_decode(xdr, 28);
5768 val = be32_to_cpup(p++); /* headerpadsz */
5770 return -EINVAL; /* no support for header padding yet */
5771 attrs->max_rqst_sz = be32_to_cpup(p++);
5772 attrs->max_resp_sz = be32_to_cpup(p++);
5773 attrs->max_resp_sz_cached = be32_to_cpup(p++);
5774 attrs->max_ops = be32_to_cpup(p++);
5775 attrs->max_reqs = be32_to_cpup(p++);
5776 nr_attrs = be32_to_cpup(p);
5777 if (unlikely(nr_attrs > 1)) {
5778 printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs "
5779 "count %u\n", __func__, nr_attrs);
5782 if (nr_attrs == 1) {
5783 p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
5789 print_overflow_msg(__func__, xdr);
5793 static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
5795 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
5798 static int decode_bind_conn_to_session(struct xdr_stream *xdr,
5799 struct nfs41_bind_conn_to_session_res *res)
5804 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
5806 status = decode_sessionid(xdr, &res->sessionid);
5807 if (unlikely(status))
5810 /* dir flags, rdma mode bool */
5811 p = xdr_inline_decode(xdr, 8);
5815 res->dir = be32_to_cpup(p++);
5816 if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
5818 if (be32_to_cpup(p) == 0)
5819 res->use_conn_in_rdma_mode = false;
5821 res->use_conn_in_rdma_mode = true;
5825 print_overflow_msg(__func__, xdr);
5829 static int decode_create_session(struct xdr_stream *xdr,
5830 struct nfs41_create_session_res *res)
5835 status = decode_op_hdr(xdr, OP_CREATE_SESSION);
5837 status = decode_sessionid(xdr, &res->sessionid);
5838 if (unlikely(status))
5842 p = xdr_inline_decode(xdr, 8);
5845 res->seqid = be32_to_cpup(p++);
5846 res->flags = be32_to_cpup(p);
5848 /* Channel attributes */
5849 status = decode_chan_attrs(xdr, &res->fc_attrs);
5851 status = decode_chan_attrs(xdr, &res->bc_attrs);
5854 print_overflow_msg(__func__, xdr);
5858 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
5860 return decode_op_hdr(xdr, OP_DESTROY_SESSION);
5863 static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy)
5865 return decode_op_hdr(xdr, OP_DESTROY_CLIENTID);
5868 static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
5870 return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
5872 #endif /* CONFIG_NFS_V4_1 */
5874 static int decode_sequence(struct xdr_stream *xdr,
5875 struct nfs4_sequence_res *res,
5876 struct rpc_rqst *rqstp)
5878 #if defined(CONFIG_NFS_V4_1)
5879 struct nfs4_session *session;
5880 struct nfs4_sessionid id;
5885 if (res->sr_slot == NULL)
5887 if (!res->sr_slot->table->session)
5890 status = decode_op_hdr(xdr, OP_SEQUENCE);
5892 status = decode_sessionid(xdr, &id);
5893 if (unlikely(status))
5897 * If the server returns different values for sessionID, slotID or
5898 * sequence number, the server is looney tunes.
5900 status = -EREMOTEIO;
5901 session = res->sr_slot->table->session;
5903 if (memcmp(id.data, session->sess_id.data,
5904 NFS4_MAX_SESSIONID_LEN)) {
5905 dprintk("%s Invalid session id\n", __func__);
5909 p = xdr_inline_decode(xdr, 20);
5914 dummy = be32_to_cpup(p++);
5915 if (dummy != res->sr_slot->seq_nr) {
5916 dprintk("%s Invalid sequence number\n", __func__);
5920 dummy = be32_to_cpup(p++);
5921 if (dummy != res->sr_slot->slot_nr) {
5922 dprintk("%s Invalid slot id\n", __func__);
5925 /* highest slot id */
5926 res->sr_highest_slotid = be32_to_cpup(p++);
5927 /* target highest slot id */
5928 res->sr_target_highest_slotid = be32_to_cpup(p++);
5930 res->sr_status_flags = be32_to_cpup(p);
5933 res->sr_status = status;
5936 print_overflow_msg(__func__, xdr);
5939 #else /* CONFIG_NFS_V4_1 */
5941 #endif /* CONFIG_NFS_V4_1 */
5944 #if defined(CONFIG_NFS_V4_1)
5945 static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
5947 stateid->type = NFS4_LAYOUT_STATEID_TYPE;
5948 return decode_stateid(xdr, stateid);
5951 static int decode_getdeviceinfo(struct xdr_stream *xdr,
5952 struct nfs4_getdeviceinfo_res *res)
5954 struct pnfs_device *pdev = res->pdev;
5959 status = decode_op_hdr(xdr, OP_GETDEVICEINFO);
5961 if (status == -ETOOSMALL) {
5962 p = xdr_inline_decode(xdr, 4);
5965 pdev->mincount = be32_to_cpup(p);
5966 dprintk("%s: Min count too small. mincnt = %u\n",
5967 __func__, pdev->mincount);
5972 p = xdr_inline_decode(xdr, 8);
5975 type = be32_to_cpup(p++);
5976 if (type != pdev->layout_type) {
5977 dprintk("%s: layout mismatch req: %u pdev: %u\n",
5978 __func__, pdev->layout_type, type);
5982 * Get the length of the opaque device_addr4. xdr_read_pages places
5983 * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages)
5984 * and places the remaining xdr data in xdr_buf->tail
5986 pdev->mincount = be32_to_cpup(p);
5987 if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount)
5990 /* Parse notification bitmap, verifying that it is zero. */
5991 p = xdr_inline_decode(xdr, 4);
5994 len = be32_to_cpup(p);
5998 p = xdr_inline_decode(xdr, 4 * len);
6002 res->notification = be32_to_cpup(p++);
6003 for (i = 1; i < len; i++) {
6004 if (be32_to_cpup(p++)) {
6005 dprintk("%s: unsupported notification\n",
6013 print_overflow_msg(__func__, xdr);
6017 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
6018 struct nfs4_layoutget_res *res)
6025 status = decode_op_hdr(xdr, OP_LAYOUTGET);
6028 p = xdr_inline_decode(xdr, 4);
6031 res->return_on_close = be32_to_cpup(p);
6032 decode_layout_stateid(xdr, &res->stateid);
6033 p = xdr_inline_decode(xdr, 4);
6036 layout_count = be32_to_cpup(p);
6037 if (!layout_count) {
6038 dprintk("%s: server responded with empty layout array\n",
6043 p = xdr_inline_decode(xdr, 28);
6046 p = xdr_decode_hyper(p, &res->range.offset);
6047 p = xdr_decode_hyper(p, &res->range.length);
6048 res->range.iomode = be32_to_cpup(p++);
6049 res->type = be32_to_cpup(p++);
6050 res->layoutp->len = be32_to_cpup(p);
6052 dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n",
6054 (unsigned long)res->range.offset,
6055 (unsigned long)res->range.length,
6060 recvd = xdr_read_pages(xdr, res->layoutp->len);
6061 if (res->layoutp->len > recvd) {
6062 dprintk("NFS: server cheating in layoutget reply: "
6063 "layout len %u > recvd %u\n",
6064 res->layoutp->len, recvd);
6068 if (layout_count > 1) {
6069 /* We only handle a length one array at the moment. Any
6070 * further entries are just ignored. Note that this means
6071 * the client may see a response that is less than the
6072 * minimum it requested.
6074 dprintk("%s: server responded with %d layouts, dropping tail\n",
6075 __func__, layout_count);
6080 print_overflow_msg(__func__, xdr);
6084 static int decode_layoutreturn(struct xdr_stream *xdr,
6085 struct nfs4_layoutreturn_res *res)
6090 status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
6093 p = xdr_inline_decode(xdr, 4);
6096 res->lrs_present = be32_to_cpup(p);
6097 if (res->lrs_present)
6098 status = decode_layout_stateid(xdr, &res->stateid);
6100 nfs4_stateid_copy(&res->stateid, &invalid_stateid);
6103 print_overflow_msg(__func__, xdr);
6107 static int decode_layoutcommit(struct xdr_stream *xdr,
6108 struct rpc_rqst *req,
6109 struct nfs4_layoutcommit_res *res)
6115 status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT);
6116 res->status = status;
6120 p = xdr_inline_decode(xdr, 4);
6123 sizechanged = be32_to_cpup(p);
6126 /* throw away new size */
6127 p = xdr_inline_decode(xdr, 8);
6133 print_overflow_msg(__func__, xdr);
6137 static int decode_test_stateid(struct xdr_stream *xdr,
6138 struct nfs41_test_stateid_res *res)
6144 status = decode_op_hdr(xdr, OP_TEST_STATEID);
6148 p = xdr_inline_decode(xdr, 4);
6151 num_res = be32_to_cpup(p++);
6155 p = xdr_inline_decode(xdr, 4);
6158 res->status = be32_to_cpup(p++);
6162 print_overflow_msg(__func__, xdr);
6167 static int decode_free_stateid(struct xdr_stream *xdr,
6168 struct nfs41_free_stateid_res *res)
6170 res->status = decode_op_hdr(xdr, OP_FREE_STATEID);
6175 int decode_layoutreturn(struct xdr_stream *xdr,
6176 struct nfs4_layoutreturn_res *res)
6180 #endif /* CONFIG_NFS_V4_1 */
6183 * END OF "GENERIC" DECODE ROUTINES.
6187 * Decode OPEN_DOWNGRADE response
6189 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp,
6190 struct xdr_stream *xdr,
6193 struct nfs_closeres *res = data;
6194 struct compound_hdr hdr;
6197 status = decode_compound_hdr(xdr, &hdr);
6200 status = decode_sequence(xdr, &res->seq_res, rqstp);
6203 status = decode_putfh(xdr);
6207 status = decode_layoutreturn(xdr, res->lr_res);
6208 res->lr_ret = status;
6212 status = decode_open_downgrade(xdr, res);
6218 * Decode ACCESS response
6220 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6223 struct nfs4_accessres *res = data;
6224 struct compound_hdr hdr;
6227 status = decode_compound_hdr(xdr, &hdr);
6230 status = decode_sequence(xdr, &res->seq_res, rqstp);
6233 status = decode_putfh(xdr);
6236 status = decode_access(xdr, &res->supported, &res->access);
6240 decode_getfattr(xdr, res->fattr, res->server);
6246 * Decode LOOKUP response
6248 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6251 struct nfs4_lookup_res *res = data;
6252 struct compound_hdr hdr;
6255 status = decode_compound_hdr(xdr, &hdr);
6258 status = decode_sequence(xdr, &res->seq_res, rqstp);
6261 status = decode_putfh(xdr);
6264 status = decode_lookup(xdr);
6267 status = decode_getfh(xdr, res->fh);
6270 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6276 * Decode LOOKUPP response
6278 static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6281 struct nfs4_lookupp_res *res = data;
6282 struct compound_hdr hdr;
6285 status = decode_compound_hdr(xdr, &hdr);
6288 status = decode_sequence(xdr, &res->seq_res, rqstp);
6291 status = decode_putfh(xdr);
6294 status = decode_lookupp(xdr);
6297 status = decode_getfh(xdr, res->fh);
6300 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6306 * Decode LOOKUP_ROOT response
6308 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp,
6309 struct xdr_stream *xdr,
6312 struct nfs4_lookup_res *res = data;
6313 struct compound_hdr hdr;
6316 status = decode_compound_hdr(xdr, &hdr);
6319 status = decode_sequence(xdr, &res->seq_res, rqstp);
6322 status = decode_putrootfh(xdr);
6325 status = decode_getfh(xdr, res->fh);
6327 status = decode_getfattr_label(xdr, res->fattr,
6328 res->label, res->server);
6334 * Decode REMOVE response
6336 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6339 struct nfs_removeres *res = data;
6340 struct compound_hdr hdr;
6343 status = decode_compound_hdr(xdr, &hdr);
6346 status = decode_sequence(xdr, &res->seq_res, rqstp);
6349 status = decode_putfh(xdr);
6352 status = decode_remove(xdr, &res->cinfo);
6358 * Decode RENAME response
6360 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6363 struct nfs_renameres *res = data;
6364 struct compound_hdr hdr;
6367 status = decode_compound_hdr(xdr, &hdr);
6370 status = decode_sequence(xdr, &res->seq_res, rqstp);
6373 status = decode_putfh(xdr);
6376 status = decode_savefh(xdr);
6379 status = decode_putfh(xdr);
6382 status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo);
6388 * Decode LINK response
6390 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6393 struct nfs4_link_res *res = data;
6394 struct compound_hdr hdr;
6397 status = decode_compound_hdr(xdr, &hdr);
6400 status = decode_sequence(xdr, &res->seq_res, rqstp);
6403 status = decode_putfh(xdr);
6406 status = decode_savefh(xdr);
6409 status = decode_putfh(xdr);
6412 status = decode_link(xdr, &res->cinfo);
6416 * Note order: OP_LINK leaves the directory as the current
6419 status = decode_restorefh(xdr);
6422 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6428 * Decode CREATE response
6430 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6433 struct nfs4_create_res *res = data;
6434 struct compound_hdr hdr;
6437 status = decode_compound_hdr(xdr, &hdr);
6440 status = decode_sequence(xdr, &res->seq_res, rqstp);
6443 status = decode_putfh(xdr);
6446 status = decode_create(xdr, &res->dir_cinfo);
6449 status = decode_getfh(xdr, res->fh);
6452 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6458 * Decode SYMLINK response
6460 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6463 return nfs4_xdr_dec_create(rqstp, xdr, res);
6467 * Decode GETATTR response
6469 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6472 struct nfs4_getattr_res *res = data;
6473 struct compound_hdr hdr;
6476 status = decode_compound_hdr(xdr, &hdr);
6479 status = decode_sequence(xdr, &res->seq_res, rqstp);
6482 status = decode_putfh(xdr);
6485 status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6491 * Encode an SETACL request
6493 static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr,
6496 const struct nfs_setaclargs *args = data;
6497 struct compound_hdr hdr = {
6498 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
6501 encode_compound_hdr(xdr, req, &hdr);
6502 encode_sequence(xdr, &args->seq_args, &hdr);
6503 encode_putfh(xdr, args->fh, &hdr);
6504 encode_setacl(xdr, args, &hdr);
6509 * Decode SETACL response
6512 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6515 struct nfs_setaclres *res = data;
6516 struct compound_hdr hdr;
6519 status = decode_compound_hdr(xdr, &hdr);
6522 status = decode_sequence(xdr, &res->seq_res, rqstp);
6525 status = decode_putfh(xdr);
6528 status = decode_setattr(xdr);
6534 * Decode GETACL response
6537 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6540 struct nfs_getaclres *res = data;
6541 struct compound_hdr hdr;
6544 if (res->acl_scratch != NULL) {
6545 void *p = page_address(res->acl_scratch);
6546 xdr_set_scratch_buffer(xdr, p, PAGE_SIZE);
6548 status = decode_compound_hdr(xdr, &hdr);
6551 status = decode_sequence(xdr, &res->seq_res, rqstp);
6554 status = decode_putfh(xdr);
6557 status = decode_getacl(xdr, rqstp, res);
6564 * Decode CLOSE response
6566 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6569 struct nfs_closeres *res = data;
6570 struct compound_hdr hdr;
6573 status = decode_compound_hdr(xdr, &hdr);
6576 status = decode_sequence(xdr, &res->seq_res, rqstp);
6579 status = decode_putfh(xdr);
6583 status = decode_layoutreturn(xdr, res->lr_res);
6584 res->lr_ret = status;
6588 if (res->fattr != NULL) {
6589 status = decode_getfattr(xdr, res->fattr, res->server);
6593 status = decode_close(xdr, res);
6599 * Decode OPEN response
6601 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6604 struct nfs_openres *res = data;
6605 struct compound_hdr hdr;
6608 status = decode_compound_hdr(xdr, &hdr);
6611 status = decode_sequence(xdr, &res->seq_res, rqstp);
6614 status = decode_putfh(xdr);
6617 status = decode_open(xdr, res);
6620 status = decode_getfh(xdr, &res->fh);
6623 if (res->access_request)
6624 decode_access(xdr, &res->access_supported, &res->access_result);
6625 decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server);
6631 * Decode OPEN_CONFIRM response
6633 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp,
6634 struct xdr_stream *xdr,
6637 struct nfs_open_confirmres *res = data;
6638 struct compound_hdr hdr;
6641 status = decode_compound_hdr(xdr, &hdr);
6644 status = decode_putfh(xdr);
6647 status = decode_open_confirm(xdr, res);
6653 * Decode OPEN response
6655 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp,
6656 struct xdr_stream *xdr,
6659 struct nfs_openres *res = data;
6660 struct compound_hdr hdr;
6663 status = decode_compound_hdr(xdr, &hdr);
6666 status = decode_sequence(xdr, &res->seq_res, rqstp);
6669 status = decode_putfh(xdr);
6672 status = decode_open(xdr, res);
6675 if (res->access_request)
6676 decode_access(xdr, &res->access_supported, &res->access_result);
6677 decode_getfattr(xdr, res->f_attr, res->server);
6683 * Decode SETATTR response
6685 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp,
6686 struct xdr_stream *xdr,
6689 struct nfs_setattrres *res = data;
6690 struct compound_hdr hdr;
6693 status = decode_compound_hdr(xdr, &hdr);
6696 status = decode_sequence(xdr, &res->seq_res, rqstp);
6699 status = decode_putfh(xdr);
6702 status = decode_setattr(xdr);
6705 decode_getfattr_label(xdr, res->fattr, res->label, res->server);
6711 * Decode LOCK response
6713 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6716 struct nfs_lock_res *res = data;
6717 struct compound_hdr hdr;
6720 status = decode_compound_hdr(xdr, &hdr);
6723 status = decode_sequence(xdr, &res->seq_res, rqstp);
6726 status = decode_putfh(xdr);
6729 status = decode_lock(xdr, res);
6735 * Decode LOCKT response
6737 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6740 struct nfs_lockt_res *res = data;
6741 struct compound_hdr hdr;
6744 status = decode_compound_hdr(xdr, &hdr);
6747 status = decode_sequence(xdr, &res->seq_res, rqstp);
6750 status = decode_putfh(xdr);
6753 status = decode_lockt(xdr, res);
6759 * Decode LOCKU response
6761 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6764 struct nfs_locku_res *res = data;
6765 struct compound_hdr hdr;
6768 status = decode_compound_hdr(xdr, &hdr);
6771 status = decode_sequence(xdr, &res->seq_res, rqstp);
6774 status = decode_putfh(xdr);
6777 status = decode_locku(xdr, res);
6782 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
6783 struct xdr_stream *xdr, void *dummy)
6785 struct compound_hdr hdr;
6788 status = decode_compound_hdr(xdr, &hdr);
6790 status = decode_release_lockowner(xdr);
6795 * Decode READLINK response
6797 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp,
6798 struct xdr_stream *xdr,
6801 struct nfs4_readlink_res *res = data;
6802 struct compound_hdr hdr;
6805 status = decode_compound_hdr(xdr, &hdr);
6808 status = decode_sequence(xdr, &res->seq_res, rqstp);
6811 status = decode_putfh(xdr);
6814 status = decode_readlink(xdr, rqstp);
6820 * Decode READDIR response
6822 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6825 struct nfs4_readdir_res *res = data;
6826 struct compound_hdr hdr;
6829 status = decode_compound_hdr(xdr, &hdr);
6832 status = decode_sequence(xdr, &res->seq_res, rqstp);
6835 status = decode_putfh(xdr);
6838 status = decode_readdir(xdr, rqstp, res);
6844 * Decode Read response
6846 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6849 struct nfs_pgio_res *res = data;
6850 struct compound_hdr hdr;
6853 status = decode_compound_hdr(xdr, &hdr);
6854 res->op_status = hdr.status;
6857 status = decode_sequence(xdr, &res->seq_res, rqstp);
6860 status = decode_putfh(xdr);
6863 status = decode_read(xdr, rqstp, res);
6865 status = res->count;
6871 * Decode WRITE response
6873 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6876 struct nfs_pgio_res *res = data;
6877 struct compound_hdr hdr;
6880 status = decode_compound_hdr(xdr, &hdr);
6881 res->op_status = hdr.status;
6884 status = decode_sequence(xdr, &res->seq_res, rqstp);
6887 status = decode_putfh(xdr);
6890 status = decode_write(xdr, res);
6894 decode_getfattr(xdr, res->fattr, res->server);
6896 status = res->count;
6902 * Decode COMMIT response
6904 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6907 struct nfs_commitres *res = data;
6908 struct compound_hdr hdr;
6911 status = decode_compound_hdr(xdr, &hdr);
6912 res->op_status = hdr.status;
6915 status = decode_sequence(xdr, &res->seq_res, rqstp);
6918 status = decode_putfh(xdr);
6921 status = decode_commit(xdr, res);
6927 * Decode FSINFO response
6929 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
6932 struct nfs4_fsinfo_res *res = data;
6933 struct compound_hdr hdr;
6936 status = decode_compound_hdr(xdr, &hdr);
6938 status = decode_sequence(xdr, &res->seq_res, req);
6940 status = decode_putfh(xdr);
6942 status = decode_fsinfo(xdr, res->fsinfo);
6947 * Decode PATHCONF response
6949 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
6952 struct nfs4_pathconf_res *res = data;
6953 struct compound_hdr hdr;
6956 status = decode_compound_hdr(xdr, &hdr);
6958 status = decode_sequence(xdr, &res->seq_res, req);
6960 status = decode_putfh(xdr);
6962 status = decode_pathconf(xdr, res->pathconf);
6967 * Decode STATFS response
6969 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
6972 struct nfs4_statfs_res *res = data;
6973 struct compound_hdr hdr;
6976 status = decode_compound_hdr(xdr, &hdr);
6978 status = decode_sequence(xdr, &res->seq_res, req);
6980 status = decode_putfh(xdr);
6982 status = decode_statfs(xdr, res->fsstat);
6987 * Decode GETATTR_BITMAP response
6989 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req,
6990 struct xdr_stream *xdr,
6993 struct nfs4_server_caps_res *res = data;
6994 struct compound_hdr hdr;
6997 status = decode_compound_hdr(xdr, &hdr);
7000 status = decode_sequence(xdr, &res->seq_res, req);
7003 status = decode_putfh(xdr);
7006 status = decode_server_caps(xdr, res);
7012 * Decode RENEW response
7014 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
7017 struct compound_hdr hdr;
7020 status = decode_compound_hdr(xdr, &hdr);
7022 status = decode_renew(xdr);
7027 * Decode SETCLIENTID response
7029 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req,
7030 struct xdr_stream *xdr,
7033 struct nfs4_setclientid_res *res = data;
7034 struct compound_hdr hdr;
7037 status = decode_compound_hdr(xdr, &hdr);
7039 status = decode_setclientid(xdr, res);
7044 * Decode SETCLIENTID_CONFIRM response
7046 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
7047 struct xdr_stream *xdr,
7050 struct compound_hdr hdr;
7053 status = decode_compound_hdr(xdr, &hdr);
7055 status = decode_setclientid_confirm(xdr);
7060 * Decode DELEGRETURN response
7062 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp,
7063 struct xdr_stream *xdr,
7066 struct nfs4_delegreturnres *res = data;
7067 struct compound_hdr hdr;
7070 status = decode_compound_hdr(xdr, &hdr);
7073 status = decode_sequence(xdr, &res->seq_res, rqstp);
7076 status = decode_putfh(xdr);
7080 status = decode_layoutreturn(xdr, res->lr_res);
7081 res->lr_ret = status;
7086 status = decode_getfattr(xdr, res->fattr, res->server);
7090 status = decode_delegreturn(xdr);
7096 * Decode FS_LOCATIONS response
7098 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req,
7099 struct xdr_stream *xdr,
7102 struct nfs4_fs_locations_res *res = data;
7103 struct compound_hdr hdr;
7106 status = decode_compound_hdr(xdr, &hdr);
7109 status = decode_sequence(xdr, &res->seq_res, req);
7112 status = decode_putfh(xdr);
7115 if (res->migration) {
7116 xdr_enter_page(xdr, PAGE_SIZE);
7117 status = decode_getfattr_generic(xdr,
7118 &res->fs_locations->fattr,
7119 NULL, res->fs_locations,
7120 NULL, res->fs_locations->server);
7124 status = decode_renew(xdr);
7126 status = decode_lookup(xdr);
7129 xdr_enter_page(xdr, PAGE_SIZE);
7130 status = decode_getfattr_generic(xdr,
7131 &res->fs_locations->fattr,
7132 NULL, res->fs_locations,
7133 NULL, res->fs_locations->server);
7140 * Decode SECINFO response
7142 static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp,
7143 struct xdr_stream *xdr,
7146 struct nfs4_secinfo_res *res = data;
7147 struct compound_hdr hdr;
7150 status = decode_compound_hdr(xdr, &hdr);
7153 status = decode_sequence(xdr, &res->seq_res, rqstp);
7156 status = decode_putfh(xdr);
7159 status = decode_secinfo(xdr, res);
7165 * Decode FSID_PRESENT response
7167 static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp,
7168 struct xdr_stream *xdr,
7171 struct nfs4_fsid_present_res *res = data;
7172 struct compound_hdr hdr;
7175 status = decode_compound_hdr(xdr, &hdr);
7178 status = decode_sequence(xdr, &res->seq_res, rqstp);
7181 status = decode_putfh(xdr);
7184 status = decode_getfh(xdr, res->fh);
7188 status = decode_renew(xdr);
7193 #if defined(CONFIG_NFS_V4_1)
7195 * Decode BIND_CONN_TO_SESSION response
7197 static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp,
7198 struct xdr_stream *xdr,
7201 struct compound_hdr hdr;
7204 status = decode_compound_hdr(xdr, &hdr);
7206 status = decode_bind_conn_to_session(xdr, res);
7211 * Decode EXCHANGE_ID response
7213 static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp,
7214 struct xdr_stream *xdr,
7217 struct compound_hdr hdr;
7220 status = decode_compound_hdr(xdr, &hdr);
7222 status = decode_exchange_id(xdr, res);
7227 * Decode CREATE_SESSION response
7229 static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp,
7230 struct xdr_stream *xdr,
7233 struct compound_hdr hdr;
7236 status = decode_compound_hdr(xdr, &hdr);
7238 status = decode_create_session(xdr, res);
7243 * Decode DESTROY_SESSION response
7245 static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp,
7246 struct xdr_stream *xdr,
7249 struct compound_hdr hdr;
7252 status = decode_compound_hdr(xdr, &hdr);
7254 status = decode_destroy_session(xdr, res);
7259 * Decode DESTROY_CLIENTID response
7261 static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp,
7262 struct xdr_stream *xdr,
7265 struct compound_hdr hdr;
7268 status = decode_compound_hdr(xdr, &hdr);
7270 status = decode_destroy_clientid(xdr, res);
7275 * Decode SEQUENCE response
7277 static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp,
7278 struct xdr_stream *xdr,
7281 struct compound_hdr hdr;
7284 status = decode_compound_hdr(xdr, &hdr);
7286 status = decode_sequence(xdr, res, rqstp);
7291 * Decode GET_LEASE_TIME response
7293 static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp,
7294 struct xdr_stream *xdr,
7297 struct nfs4_get_lease_time_res *res = data;
7298 struct compound_hdr hdr;
7301 status = decode_compound_hdr(xdr, &hdr);
7303 status = decode_sequence(xdr, &res->lr_seq_res, rqstp);
7305 status = decode_putrootfh(xdr);
7307 status = decode_fsinfo(xdr, res->lr_fsinfo);
7312 * Decode RECLAIM_COMPLETE response
7314 static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp,
7315 struct xdr_stream *xdr,
7318 struct nfs41_reclaim_complete_res *res = data;
7319 struct compound_hdr hdr;
7322 status = decode_compound_hdr(xdr, &hdr);
7324 status = decode_sequence(xdr, &res->seq_res, rqstp);
7326 status = decode_reclaim_complete(xdr, NULL);
7331 * Decode GETDEVINFO response
7333 static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp,
7334 struct xdr_stream *xdr,
7337 struct nfs4_getdeviceinfo_res *res = data;
7338 struct compound_hdr hdr;
7341 status = decode_compound_hdr(xdr, &hdr);
7344 status = decode_sequence(xdr, &res->seq_res, rqstp);
7347 status = decode_getdeviceinfo(xdr, res);
7353 * Decode LAYOUTGET response
7355 static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp,
7356 struct xdr_stream *xdr,
7359 struct nfs4_layoutget_res *res = data;
7360 struct compound_hdr hdr;
7363 status = decode_compound_hdr(xdr, &hdr);
7366 status = decode_sequence(xdr, &res->seq_res, rqstp);
7369 status = decode_putfh(xdr);
7372 status = decode_layoutget(xdr, rqstp, res);
7378 * Decode LAYOUTRETURN response
7380 static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp,
7381 struct xdr_stream *xdr,
7384 struct nfs4_layoutreturn_res *res = data;
7385 struct compound_hdr hdr;
7388 status = decode_compound_hdr(xdr, &hdr);
7391 status = decode_sequence(xdr, &res->seq_res, rqstp);
7394 status = decode_putfh(xdr);
7397 status = decode_layoutreturn(xdr, res);
7403 * Decode LAYOUTCOMMIT response
7405 static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp,
7406 struct xdr_stream *xdr,
7409 struct nfs4_layoutcommit_res *res = data;
7410 struct compound_hdr hdr;
7413 status = decode_compound_hdr(xdr, &hdr);
7416 status = decode_sequence(xdr, &res->seq_res, rqstp);
7419 status = decode_putfh(xdr);
7422 status = decode_layoutcommit(xdr, rqstp, res);
7425 decode_getfattr(xdr, res->fattr, res->server);
7431 * Decode SECINFO_NO_NAME response
7433 static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp,
7434 struct xdr_stream *xdr,
7437 struct nfs4_secinfo_res *res = data;
7438 struct compound_hdr hdr;
7441 status = decode_compound_hdr(xdr, &hdr);
7444 status = decode_sequence(xdr, &res->seq_res, rqstp);
7447 status = decode_putrootfh(xdr);
7450 status = decode_secinfo_no_name(xdr, res);
7456 * Decode TEST_STATEID response
7458 static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp,
7459 struct xdr_stream *xdr,
7462 struct nfs41_test_stateid_res *res = data;
7463 struct compound_hdr hdr;
7466 status = decode_compound_hdr(xdr, &hdr);
7469 status = decode_sequence(xdr, &res->seq_res, rqstp);
7472 status = decode_test_stateid(xdr, res);
7478 * Decode FREE_STATEID response
7480 static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp,
7481 struct xdr_stream *xdr,
7484 struct nfs41_free_stateid_res *res = data;
7485 struct compound_hdr hdr;
7488 status = decode_compound_hdr(xdr, &hdr);
7491 status = decode_sequence(xdr, &res->seq_res, rqstp);
7494 status = decode_free_stateid(xdr, res);
7498 #endif /* CONFIG_NFS_V4_1 */
7501 * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in
7502 * the local page cache.
7503 * @xdr: XDR stream where entry resides
7504 * @entry: buffer to fill in with entry data
7505 * @plus: boolean indicating whether this should be a readdirplus entry
7507 * Returns zero if successful, otherwise a negative errno value is
7510 * This function is not invoked during READDIR reply decoding, but
7511 * rather whenever an application invokes the getdents(2) system call
7512 * on a directory already in our cache.
7514 int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
7518 uint32_t bitmap[3] = {0};
7520 uint64_t new_cookie;
7521 __be32 *p = xdr_inline_decode(xdr, 4);
7524 if (*p == xdr_zero) {
7525 p = xdr_inline_decode(xdr, 4);
7534 p = xdr_inline_decode(xdr, 12);
7537 p = xdr_decode_hyper(p, &new_cookie);
7538 entry->len = be32_to_cpup(p);
7540 p = xdr_inline_decode(xdr, entry->len);
7543 entry->name = (const char *) p;
7546 * In case the server doesn't return an inode number,
7547 * we fake one here. (We don't use inode number 0,
7548 * since glibc seems to choke on it...)
7551 entry->fattr->valid = 0;
7553 if (decode_attr_bitmap(xdr, bitmap) < 0)
7556 if (decode_attr_length(xdr, &len, &savep) < 0)
7559 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,
7560 NULL, entry->label, entry->server) < 0)
7562 if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
7563 entry->ino = entry->fattr->mounted_on_fileid;
7564 else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
7565 entry->ino = entry->fattr->fileid;
7567 entry->d_type = DT_UNKNOWN;
7568 if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
7569 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
7571 entry->prev_cookie = entry->cookie;
7572 entry->cookie = new_cookie;
7577 print_overflow_msg(__func__, xdr);
7582 * We need to translate between nfs status return values and
7583 * the local errno values which may not be the same.
7590 { NFS4ERR_PERM, -EPERM },
7591 { NFS4ERR_NOENT, -ENOENT },
7592 { NFS4ERR_IO, -errno_NFSERR_IO},
7593 { NFS4ERR_NXIO, -ENXIO },
7594 { NFS4ERR_ACCESS, -EACCES },
7595 { NFS4ERR_EXIST, -EEXIST },
7596 { NFS4ERR_XDEV, -EXDEV },
7597 { NFS4ERR_NOTDIR, -ENOTDIR },
7598 { NFS4ERR_ISDIR, -EISDIR },
7599 { NFS4ERR_INVAL, -EINVAL },
7600 { NFS4ERR_FBIG, -EFBIG },
7601 { NFS4ERR_NOSPC, -ENOSPC },
7602 { NFS4ERR_ROFS, -EROFS },
7603 { NFS4ERR_MLINK, -EMLINK },
7604 { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
7605 { NFS4ERR_NOTEMPTY, -ENOTEMPTY },
7606 { NFS4ERR_DQUOT, -EDQUOT },
7607 { NFS4ERR_STALE, -ESTALE },
7608 { NFS4ERR_BADHANDLE, -EBADHANDLE },
7609 { NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
7610 { NFS4ERR_NOTSUPP, -ENOTSUPP },
7611 { NFS4ERR_TOOSMALL, -ETOOSMALL },
7612 { NFS4ERR_SERVERFAULT, -EREMOTEIO },
7613 { NFS4ERR_BADTYPE, -EBADTYPE },
7614 { NFS4ERR_LOCKED, -EAGAIN },
7615 { NFS4ERR_SYMLINK, -ELOOP },
7616 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
7617 { NFS4ERR_DEADLOCK, -EDEADLK },
7622 * Convert an NFS error code to a local one.
7623 * This one is used jointly by NFSv2 and NFSv3.
7626 nfs4_stat_to_errno(int stat)
7629 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
7630 if (nfs_errtbl[i].stat == stat)
7631 return nfs_errtbl[i].errno;
7633 if (stat <= 10000 || stat > 10100) {
7634 /* The server is looney tunes. */
7637 /* If we cannot translate the error, the recovery routines should
7639 * Note: remaining NFSv4 error codes have values > 10000, so should
7640 * not conflict with native Linux error codes.
7645 #ifdef CONFIG_NFS_V4_2
7646 #include "nfs42xdr.c"
7647 #endif /* CONFIG_NFS_V4_2 */
7649 #define PROC(proc, argtype, restype) \
7650 [NFSPROC4_CLNT_##proc] = { \
7651 .p_proc = NFSPROC4_COMPOUND, \
7652 .p_encode = nfs4_xdr_##argtype, \
7653 .p_decode = nfs4_xdr_##restype, \
7654 .p_arglen = NFS4_##argtype##_sz, \
7655 .p_replen = NFS4_##restype##_sz, \
7656 .p_statidx = NFSPROC4_CLNT_##proc, \
7660 #define STUB(proc) \
7661 [NFSPROC4_CLNT_##proc] = { \
7665 #if defined(CONFIG_NFS_V4_1)
7666 #define PROC41(proc, argtype, restype) \
7667 PROC(proc, argtype, restype)
7669 #define PROC41(proc, argtype, restype) \
7673 #if defined(CONFIG_NFS_V4_2)
7674 #define PROC42(proc, argtype, restype) \
7675 PROC(proc, argtype, restype)
7677 #define PROC42(proc, argtype, restype) \
7681 const struct rpc_procinfo nfs4_procedures[] = {
7682 PROC(READ, enc_read, dec_read),
7683 PROC(WRITE, enc_write, dec_write),
7684 PROC(COMMIT, enc_commit, dec_commit),
7685 PROC(OPEN, enc_open, dec_open),
7686 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
7687 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
7688 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
7689 PROC(CLOSE, enc_close, dec_close),
7690 PROC(SETATTR, enc_setattr, dec_setattr),
7691 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
7692 PROC(RENEW, enc_renew, dec_renew),
7693 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
7694 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
7695 PROC(LOCK, enc_lock, dec_lock),
7696 PROC(LOCKT, enc_lockt, dec_lockt),
7697 PROC(LOCKU, enc_locku, dec_locku),
7698 PROC(ACCESS, enc_access, dec_access),
7699 PROC(GETATTR, enc_getattr, dec_getattr),
7700 PROC(LOOKUP, enc_lookup, dec_lookup),
7701 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
7702 PROC(REMOVE, enc_remove, dec_remove),
7703 PROC(RENAME, enc_rename, dec_rename),
7704 PROC(LINK, enc_link, dec_link),
7705 PROC(SYMLINK, enc_symlink, dec_symlink),
7706 PROC(CREATE, enc_create, dec_create),
7707 PROC(PATHCONF, enc_pathconf, dec_pathconf),
7708 PROC(STATFS, enc_statfs, dec_statfs),
7709 PROC(READLINK, enc_readlink, dec_readlink),
7710 PROC(READDIR, enc_readdir, dec_readdir),
7711 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
7712 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
7713 PROC(GETACL, enc_getacl, dec_getacl),
7714 PROC(SETACL, enc_setacl, dec_setacl),
7715 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
7716 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
7717 PROC(SECINFO, enc_secinfo, dec_secinfo),
7718 PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present),
7719 PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
7720 PROC41(CREATE_SESSION, enc_create_session, dec_create_session),
7721 PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
7722 PROC41(SEQUENCE, enc_sequence, dec_sequence),
7723 PROC41(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time),
7724 PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete),
7725 PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo),
7726 PROC41(LAYOUTGET, enc_layoutget, dec_layoutget),
7727 PROC41(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit),
7728 PROC41(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn),
7729 PROC41(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name),
7730 PROC41(TEST_STATEID, enc_test_stateid, dec_test_stateid),
7731 PROC41(FREE_STATEID, enc_free_stateid, dec_free_stateid),
7732 STUB(GETDEVICELIST),
7733 PROC41(BIND_CONN_TO_SESSION,
7734 enc_bind_conn_to_session, dec_bind_conn_to_session),
7735 PROC41(DESTROY_CLIENTID,enc_destroy_clientid, dec_destroy_clientid),
7736 PROC42(SEEK, enc_seek, dec_seek),
7737 PROC42(ALLOCATE, enc_allocate, dec_allocate),
7738 PROC42(DEALLOCATE, enc_deallocate, dec_deallocate),
7739 PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats),
7740 PROC42(CLONE, enc_clone, dec_clone),
7741 PROC42(COPY, enc_copy, dec_copy),
7742 PROC(LOOKUPP, enc_lookupp, dec_lookupp),
7745 static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
7746 const struct rpc_version nfs_version4 = {
7748 .nrprocs = ARRAY_SIZE(nfs4_procedures),
7749 .procs = nfs4_procedures,
7750 .counts = nfs_version4_counts,