4 * Client-side XDR for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <linux/param.h>
39 #include <linux/time.h>
41 #include <linux/errno.h>
42 #include <linux/string.h>
44 #include <linux/pagemap.h>
45 #include <linux/proc_fs.h>
46 #include <linux/kdev_t.h>
47 #include <linux/module.h>
48 #include <linux/utsname.h>
49 #include <linux/sunrpc/clnt.h>
50 #include <linux/sunrpc/msg_prot.h>
51 #include <linux/sunrpc/gss_api.h>
52 #include <linux/nfs.h>
53 #include <linux/nfs4.h>
54 #include <linux/nfs_fs.h>
57 #include "nfs4trace.h"
59 #include "nfs4idmap.h"
60 #include "nfs4session.h"
64 #define NFSDBG_FACILITY NFSDBG_XDR
66 /* Mapping from NFS error code to "errno" error code. */
67 #define errno_NFSERR_IO EIO
70 static int nfs4_stat_to_errno(int);
71 static void encode_layoutget(struct xdr_stream *xdr,
72 const struct nfs4_layoutget_args *args,
73 struct compound_hdr *hdr);
74 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
75 struct nfs4_layoutget_res *res);
77 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
79 #define NFS4_MAXTAGLEN 20
81 #define NFS4_MAXTAGLEN 0
84 /* lock,open owner id:
85 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
87 #define pagepad_maxsz (1)
88 #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2)
89 #define lock_owner_id_maxsz (1 + 1 + 4)
90 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
91 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
92 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
93 #define op_encode_hdr_maxsz (1)
94 #define op_decode_hdr_maxsz (2)
95 #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
96 #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
97 #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
98 #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
99 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
101 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
102 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
103 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
104 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
105 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
106 ((3+NFS4_FHSIZE) >> 2))
107 #define nfs4_fattr_bitmap_maxsz 4
108 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
109 #define nfstime4_maxsz (3)
110 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
111 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
112 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
113 #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
114 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
115 /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */
116 #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN))
118 #define nfs4_label_maxsz 0
120 /* We support only one layout type per file system */
121 #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8)
122 /* This is based on getfattr, which uses the most attributes: */
123 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
126 nfs4_group_maxsz + nfs4_label_maxsz + \
127 decode_mdsthreshold_maxsz))
128 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
129 nfs4_fattr_value_maxsz)
130 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
131 #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
136 1 + nfstime4_maxsz + \
138 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
139 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
140 #define encode_restorefh_maxsz (op_encode_hdr_maxsz)
141 #define decode_restorefh_maxsz (op_decode_hdr_maxsz)
142 #define encode_fsinfo_maxsz (encode_getattr_maxsz)
143 /* The 5 accounts for the PNFS attributes, and assumes that at most three
144 * layout types will be returned.
146 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \
147 nfs4_fattr_bitmap_maxsz + 1 + \
148 1 /* lease time */ + \
149 2 /* max filesize */ + \
151 2 /* max write */ + \
152 nfstime4_maxsz /* time delta */ + \
153 5 /* fs layout types */ + \
154 1 /* layout blksize */ + \
155 1 /* clone blksize */ + \
156 1 /* change attr type */ + \
157 1 /* xattr support */)
158 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
159 #define decode_renew_maxsz (op_decode_hdr_maxsz)
160 #define encode_setclientid_maxsz \
161 (op_encode_hdr_maxsz + \
162 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
164 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
166 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
167 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
169 #define decode_setclientid_maxsz \
170 (op_decode_hdr_maxsz + \
172 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
173 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
174 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
175 #define encode_setclientid_confirm_maxsz \
176 (op_encode_hdr_maxsz + \
177 3 + (NFS4_VERIFIER_SIZE >> 2))
178 #define decode_setclientid_confirm_maxsz \
179 (op_decode_hdr_maxsz)
180 #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
181 #define decode_lookup_maxsz (op_decode_hdr_maxsz)
182 #define encode_lookupp_maxsz (op_encode_hdr_maxsz)
183 #define decode_lookupp_maxsz (op_decode_hdr_maxsz)
184 #define encode_share_access_maxsz \
186 #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
187 #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
188 #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
189 #define encode_open_maxsz (op_encode_hdr_maxsz + \
190 2 + encode_share_access_maxsz + 2 + \
191 open_owner_id_maxsz + \
192 encode_opentype_maxsz + \
193 encode_claim_null_maxsz)
194 #define decode_space_limit_maxsz (3)
195 #define decode_ace_maxsz (3 + nfs4_owner_maxsz)
196 #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
197 decode_space_limit_maxsz + \
199 #define decode_change_info_maxsz (5)
200 #define decode_open_maxsz (op_decode_hdr_maxsz + \
201 decode_stateid_maxsz + \
202 decode_change_info_maxsz + 1 + \
203 nfs4_fattr_bitmap_maxsz + \
204 decode_delegation_maxsz)
205 #define encode_open_confirm_maxsz \
206 (op_encode_hdr_maxsz + \
207 encode_stateid_maxsz + 1)
208 #define decode_open_confirm_maxsz \
209 (op_decode_hdr_maxsz + \
210 decode_stateid_maxsz)
211 #define encode_open_downgrade_maxsz \
212 (op_encode_hdr_maxsz + \
213 encode_stateid_maxsz + 1 + \
214 encode_share_access_maxsz)
215 #define decode_open_downgrade_maxsz \
216 (op_decode_hdr_maxsz + \
217 decode_stateid_maxsz)
218 #define encode_close_maxsz (op_encode_hdr_maxsz + \
219 1 + encode_stateid_maxsz)
220 #define decode_close_maxsz (op_decode_hdr_maxsz + \
221 decode_stateid_maxsz)
222 #define encode_setattr_maxsz (op_encode_hdr_maxsz + \
223 encode_stateid_maxsz + \
225 #define decode_setattr_maxsz (op_decode_hdr_maxsz + \
226 nfs4_fattr_bitmap_maxsz)
227 #define encode_read_maxsz (op_encode_hdr_maxsz + \
228 encode_stateid_maxsz + 3)
229 #define decode_read_maxsz (op_decode_hdr_maxsz + 2 + pagepad_maxsz)
230 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
231 2 + encode_verifier_maxsz + 5 + \
233 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
234 decode_verifier_maxsz + pagepad_maxsz)
235 #define encode_readlink_maxsz (op_encode_hdr_maxsz)
236 #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz)
237 #define encode_write_maxsz (op_encode_hdr_maxsz + \
238 encode_stateid_maxsz + 4)
239 #define decode_write_maxsz (op_decode_hdr_maxsz + \
240 2 + decode_verifier_maxsz)
241 #define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
242 #define decode_commit_maxsz (op_decode_hdr_maxsz + \
243 decode_verifier_maxsz)
244 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
246 #define decode_remove_maxsz (op_decode_hdr_maxsz + \
247 decode_change_info_maxsz)
248 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
250 #define decode_rename_maxsz (op_decode_hdr_maxsz + \
251 decode_change_info_maxsz + \
252 decode_change_info_maxsz)
253 #define encode_link_maxsz (op_encode_hdr_maxsz + \
255 #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
256 #define encode_lockowner_maxsz (7)
257 #define encode_lock_maxsz (op_encode_hdr_maxsz + \
259 1 + encode_stateid_maxsz + 1 + \
260 encode_lockowner_maxsz)
261 #define decode_lock_denied_maxsz \
262 (8 + decode_lockowner_maxsz)
263 #define decode_lock_maxsz (op_decode_hdr_maxsz + \
264 decode_lock_denied_maxsz)
265 #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \
266 encode_lockowner_maxsz)
267 #define decode_lockt_maxsz (op_decode_hdr_maxsz + \
268 decode_lock_denied_maxsz)
269 #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
270 encode_stateid_maxsz + \
272 #define decode_locku_maxsz (op_decode_hdr_maxsz + \
273 decode_stateid_maxsz)
274 #define encode_release_lockowner_maxsz \
275 (op_encode_hdr_maxsz + \
276 encode_lockowner_maxsz)
277 #define decode_release_lockowner_maxsz \
278 (op_decode_hdr_maxsz)
279 #define encode_access_maxsz (op_encode_hdr_maxsz + 1)
280 #define decode_access_maxsz (op_decode_hdr_maxsz + 2)
281 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
282 1 + nfs4_name_maxsz + \
285 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
286 #define encode_create_maxsz (op_encode_hdr_maxsz + \
287 1 + 2 + nfs4_name_maxsz + \
289 #define decode_create_maxsz (op_decode_hdr_maxsz + \
290 decode_change_info_maxsz + \
291 nfs4_fattr_bitmap_maxsz)
292 #define encode_statfs_maxsz (encode_getattr_maxsz)
293 #define decode_statfs_maxsz (decode_getattr_maxsz)
294 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
295 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
296 #define encode_getacl_maxsz (encode_getattr_maxsz)
297 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
298 nfs4_fattr_bitmap_maxsz + 1 + pagepad_maxsz)
299 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
300 encode_stateid_maxsz + 3)
301 #define decode_setacl_maxsz (decode_setattr_maxsz)
302 #define encode_fs_locations_maxsz \
303 (encode_getattr_maxsz)
304 #define decode_fs_locations_maxsz \
306 #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
307 #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
309 #if defined(CONFIG_NFS_V4_1)
310 #define NFS4_MAX_MACHINE_NAME_LEN (64)
311 #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \
312 sizeof(utsname()->version) + sizeof(utsname()->machine) + 8)
314 #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
315 encode_verifier_maxsz + \
316 1 /* co_ownerid.len */ + \
317 /* eia_clientowner */ \
318 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
321 /* max is SP4_MACH_CRED (for now) */ + \
322 1 + NFS4_OP_MAP_NUM_WORDS + \
323 1 + NFS4_OP_MAP_NUM_WORDS + \
324 1 /* implementation id array of size 1 */ + \
325 1 /* nii_domain */ + \
326 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
328 XDR_QUADLEN(IMPL_NAME_LIMIT) + \
330 #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
331 2 /* eir_clientid */ + \
332 1 /* eir_sequenceid */ + \
333 1 /* eir_flags */ + \
335 /* max is SP4_MACH_CRED (for now) */ + \
336 1 + NFS4_OP_MAP_NUM_WORDS + \
337 1 + NFS4_OP_MAP_NUM_WORDS + \
338 2 /* eir_server_owner.so_minor_id */ + \
339 /* eir_server_owner.so_major_id<> */ \
340 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
341 /* eir_server_scope<> */ \
342 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
343 1 /* eir_server_impl_id array length */ + \
344 1 /* nii_domain */ + \
345 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
347 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
349 #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */)
350 #define decode_channel_attrs_maxsz (6 + \
351 1 /* ca_rdma_ird.len */ + \
353 #define encode_create_session_maxsz (op_encode_hdr_maxsz + \
354 2 /* csa_clientid */ + \
355 1 /* csa_sequence */ + \
356 1 /* csa_flags */ + \
357 encode_channel_attrs_maxsz + \
358 encode_channel_attrs_maxsz + \
359 1 /* csa_cb_program */ + \
360 1 /* csa_sec_parms.len (1) */ + \
361 1 /* cb_secflavor (AUTH_SYS) */ + \
363 1 /* machinename.len */ + \
364 XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \
367 1 /* gids.len (0) */)
368 #define decode_create_session_maxsz (op_decode_hdr_maxsz + \
369 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
370 1 /* csr_sequence */ + \
371 1 /* csr_flags */ + \
372 decode_channel_attrs_maxsz + \
373 decode_channel_attrs_maxsz)
374 #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \
376 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
377 1 /* bctsa_dir */ + \
378 1 /* bctsa_use_conn_in_rdma_mode */)
379 #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \
381 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
382 1 /* bctsr_dir */ + \
383 1 /* bctsr_use_conn_in_rdma_mode */)
384 #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)
385 #define decode_destroy_session_maxsz (op_decode_hdr_maxsz)
386 #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2)
387 #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz)
388 #define encode_sequence_maxsz (op_encode_hdr_maxsz + \
389 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
390 #define decode_sequence_maxsz (op_decode_hdr_maxsz + \
391 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
392 #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
393 #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
394 #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \
395 XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
396 1 /* layout type */ + \
398 1 /* bitmap size */ + \
399 1 /* notification bitmap length */ + \
400 1 /* notification bitmap, word 0 */)
401 #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \
402 1 /* layout type */ + \
403 1 /* opaque devaddr4 length */ + \
404 /* devaddr4 payload is read into page */ \
405 1 /* notification bitmap length */ + \
406 1 /* notification bitmap, word 0 */ + \
407 pagepad_maxsz /* possible XDR padding */)
408 #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \
409 encode_stateid_maxsz)
410 #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \
411 decode_stateid_maxsz + \
412 XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + \
414 #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \
418 encode_stateid_maxsz + \
419 1 /* new offset (true) */ + \
420 2 /* last byte written */ + \
421 1 /* nt_timechanged (false) */ + \
422 1 /* layoutupdate4 layout type */ + \
423 1 /* layoutupdate4 opaqueue len */)
424 /* the actual content of layoutupdate4 should
425 be allocated by drivers and spliced in
426 using xdr_write_pages */
427 #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3)
428 #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \
429 encode_stateid_maxsz + \
431 XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
432 #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \
433 1 + decode_stateid_maxsz)
434 #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1)
435 #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz
436 #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \
437 XDR_QUADLEN(NFS4_STATEID_SIZE))
438 #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1)
439 #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \
440 XDR_QUADLEN(NFS4_STATEID_SIZE))
441 #define decode_free_stateid_maxsz (op_decode_hdr_maxsz)
442 #else /* CONFIG_NFS_V4_1 */
443 #define encode_sequence_maxsz 0
444 #define decode_sequence_maxsz 0
445 #define encode_layoutreturn_maxsz 0
446 #define decode_layoutreturn_maxsz 0
447 #define encode_layoutget_maxsz 0
448 #define decode_layoutget_maxsz 0
449 #endif /* CONFIG_NFS_V4_1 */
451 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
452 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
453 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
454 encode_sequence_maxsz + \
455 encode_putfh_maxsz + \
457 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
458 decode_sequence_maxsz + \
459 decode_putfh_maxsz + \
461 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
462 encode_sequence_maxsz + \
463 encode_putfh_maxsz + \
464 encode_readlink_maxsz)
465 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
466 decode_sequence_maxsz + \
467 decode_putfh_maxsz + \
468 decode_readlink_maxsz)
469 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
470 encode_sequence_maxsz + \
471 encode_putfh_maxsz + \
472 encode_readdir_maxsz)
473 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
474 decode_sequence_maxsz + \
475 decode_putfh_maxsz + \
476 decode_readdir_maxsz)
477 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
478 encode_sequence_maxsz + \
479 encode_putfh_maxsz + \
480 encode_write_maxsz + \
481 encode_getattr_maxsz)
482 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
483 decode_sequence_maxsz + \
484 decode_putfh_maxsz + \
485 decode_write_maxsz + \
486 decode_getattr_maxsz)
487 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
488 encode_sequence_maxsz + \
489 encode_putfh_maxsz + \
491 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
492 decode_sequence_maxsz + \
493 decode_putfh_maxsz + \
495 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
496 encode_sequence_maxsz + \
497 encode_putfh_maxsz + \
498 encode_open_maxsz + \
499 encode_access_maxsz + \
500 encode_getfh_maxsz + \
501 encode_getattr_maxsz + \
502 encode_layoutget_maxsz)
503 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
504 decode_sequence_maxsz + \
505 decode_putfh_maxsz + \
506 decode_open_maxsz + \
507 decode_access_maxsz + \
508 decode_getfh_maxsz + \
509 decode_getattr_maxsz + \
510 decode_layoutget_maxsz)
511 #define NFS4_enc_open_confirm_sz \
512 (compound_encode_hdr_maxsz + \
513 encode_putfh_maxsz + \
514 encode_open_confirm_maxsz)
515 #define NFS4_dec_open_confirm_sz \
516 (compound_decode_hdr_maxsz + \
517 decode_putfh_maxsz + \
518 decode_open_confirm_maxsz)
519 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
520 encode_sequence_maxsz + \
521 encode_putfh_maxsz + \
522 encode_open_maxsz + \
523 encode_access_maxsz + \
524 encode_getattr_maxsz + \
525 encode_layoutget_maxsz)
526 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
527 decode_sequence_maxsz + \
528 decode_putfh_maxsz + \
529 decode_open_maxsz + \
530 decode_access_maxsz + \
531 decode_getattr_maxsz + \
532 decode_layoutget_maxsz)
533 #define NFS4_enc_open_downgrade_sz \
534 (compound_encode_hdr_maxsz + \
535 encode_sequence_maxsz + \
536 encode_putfh_maxsz + \
537 encode_layoutreturn_maxsz + \
538 encode_open_downgrade_maxsz)
539 #define NFS4_dec_open_downgrade_sz \
540 (compound_decode_hdr_maxsz + \
541 decode_sequence_maxsz + \
542 decode_putfh_maxsz + \
543 decode_layoutreturn_maxsz + \
544 decode_open_downgrade_maxsz)
545 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
546 encode_sequence_maxsz + \
547 encode_putfh_maxsz + \
548 encode_layoutreturn_maxsz + \
549 encode_close_maxsz + \
550 encode_getattr_maxsz)
551 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
552 decode_sequence_maxsz + \
553 decode_putfh_maxsz + \
554 decode_layoutreturn_maxsz + \
555 decode_close_maxsz + \
556 decode_getattr_maxsz)
557 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
558 encode_sequence_maxsz + \
559 encode_putfh_maxsz + \
560 encode_setattr_maxsz + \
561 encode_getattr_maxsz)
562 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
563 decode_sequence_maxsz + \
564 decode_putfh_maxsz + \
565 decode_setattr_maxsz + \
566 decode_getattr_maxsz)
567 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
568 encode_sequence_maxsz + \
569 encode_putfh_maxsz + \
571 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
572 decode_sequence_maxsz + \
573 decode_putfh_maxsz + \
575 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
577 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
579 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
580 encode_setclientid_maxsz)
581 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
582 decode_setclientid_maxsz)
583 #define NFS4_enc_setclientid_confirm_sz \
584 (compound_encode_hdr_maxsz + \
585 encode_setclientid_confirm_maxsz)
586 #define NFS4_dec_setclientid_confirm_sz \
587 (compound_decode_hdr_maxsz + \
588 decode_setclientid_confirm_maxsz)
589 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
590 encode_sequence_maxsz + \
591 encode_putfh_maxsz + \
593 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
594 decode_sequence_maxsz + \
595 decode_putfh_maxsz + \
597 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
598 encode_sequence_maxsz + \
599 encode_putfh_maxsz + \
601 #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
602 decode_sequence_maxsz + \
603 decode_putfh_maxsz + \
605 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
606 encode_sequence_maxsz + \
607 encode_putfh_maxsz + \
609 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
610 decode_sequence_maxsz + \
611 decode_putfh_maxsz + \
613 #define NFS4_enc_release_lockowner_sz \
614 (compound_encode_hdr_maxsz + \
615 encode_lockowner_maxsz)
616 #define NFS4_dec_release_lockowner_sz \
617 (compound_decode_hdr_maxsz + \
618 decode_lockowner_maxsz)
619 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
620 encode_sequence_maxsz + \
621 encode_putfh_maxsz + \
622 encode_access_maxsz + \
623 encode_getattr_maxsz)
624 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
625 decode_sequence_maxsz + \
626 decode_putfh_maxsz + \
627 decode_access_maxsz + \
628 decode_getattr_maxsz)
629 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
630 encode_sequence_maxsz + \
631 encode_putfh_maxsz + \
632 encode_getattr_maxsz + \
634 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
635 decode_sequence_maxsz + \
636 decode_putfh_maxsz + \
637 decode_getattr_maxsz + \
639 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
640 encode_sequence_maxsz + \
641 encode_putfh_maxsz + \
642 encode_lookup_maxsz + \
643 encode_getattr_maxsz + \
645 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
646 decode_sequence_maxsz + \
647 decode_putfh_maxsz + \
648 decode_lookup_maxsz + \
649 decode_getattr_maxsz + \
651 #define NFS4_enc_lookupp_sz (compound_encode_hdr_maxsz + \
652 encode_sequence_maxsz + \
653 encode_putfh_maxsz + \
654 encode_lookupp_maxsz + \
655 encode_getattr_maxsz + \
657 #define NFS4_dec_lookupp_sz (compound_decode_hdr_maxsz + \
658 decode_sequence_maxsz + \
659 decode_putfh_maxsz + \
660 decode_lookupp_maxsz + \
661 decode_getattr_maxsz + \
663 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
664 encode_sequence_maxsz + \
665 encode_putrootfh_maxsz + \
666 encode_getattr_maxsz + \
668 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
669 decode_sequence_maxsz + \
670 decode_putrootfh_maxsz + \
671 decode_getattr_maxsz + \
673 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
674 encode_sequence_maxsz + \
675 encode_putfh_maxsz + \
677 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
678 decode_sequence_maxsz + \
679 decode_putfh_maxsz + \
681 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
682 encode_sequence_maxsz + \
683 encode_putfh_maxsz + \
684 encode_savefh_maxsz + \
685 encode_putfh_maxsz + \
687 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
688 decode_sequence_maxsz + \
689 decode_putfh_maxsz + \
690 decode_savefh_maxsz + \
691 decode_putfh_maxsz + \
693 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
694 encode_sequence_maxsz + \
695 encode_putfh_maxsz + \
696 encode_savefh_maxsz + \
697 encode_putfh_maxsz + \
698 encode_link_maxsz + \
699 encode_restorefh_maxsz + \
700 encode_getattr_maxsz)
701 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
702 decode_sequence_maxsz + \
703 decode_putfh_maxsz + \
704 decode_savefh_maxsz + \
705 decode_putfh_maxsz + \
706 decode_link_maxsz + \
707 decode_restorefh_maxsz + \
708 decode_getattr_maxsz)
709 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
710 encode_sequence_maxsz + \
711 encode_putfh_maxsz + \
712 encode_symlink_maxsz + \
713 encode_getattr_maxsz + \
715 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
716 decode_sequence_maxsz + \
717 decode_putfh_maxsz + \
718 decode_symlink_maxsz + \
719 decode_getattr_maxsz + \
721 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
722 encode_sequence_maxsz + \
723 encode_putfh_maxsz + \
724 encode_create_maxsz + \
725 encode_getfh_maxsz + \
726 encode_getattr_maxsz)
727 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
728 decode_sequence_maxsz + \
729 decode_putfh_maxsz + \
730 decode_create_maxsz + \
731 decode_getfh_maxsz + \
732 decode_getattr_maxsz)
733 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
734 encode_sequence_maxsz + \
735 encode_putfh_maxsz + \
736 encode_getattr_maxsz)
737 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
738 decode_sequence_maxsz + \
739 decode_putfh_maxsz + \
740 decode_getattr_maxsz)
741 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
742 encode_sequence_maxsz + \
743 encode_putfh_maxsz + \
745 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
746 decode_sequence_maxsz + \
747 decode_putfh_maxsz + \
749 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
750 encode_sequence_maxsz + \
751 encode_putfh_maxsz + \
752 encode_getattr_maxsz)
753 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
754 decode_sequence_maxsz + \
755 decode_putfh_maxsz + \
756 decode_getattr_maxsz)
757 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
758 encode_sequence_maxsz + \
759 encode_putfh_maxsz + \
760 encode_layoutreturn_maxsz + \
761 encode_delegreturn_maxsz + \
762 encode_getattr_maxsz)
763 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
764 decode_sequence_maxsz + \
765 decode_putfh_maxsz + \
766 decode_layoutreturn_maxsz + \
767 decode_delegreturn_maxsz + \
768 decode_getattr_maxsz)
769 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
770 encode_sequence_maxsz + \
771 encode_putfh_maxsz + \
773 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
774 decode_sequence_maxsz + \
775 decode_putfh_maxsz + \
777 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
778 encode_sequence_maxsz + \
779 encode_putfh_maxsz + \
781 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
782 decode_sequence_maxsz + \
783 decode_putfh_maxsz + \
785 #define NFS4_enc_fs_locations_sz \
786 (compound_encode_hdr_maxsz + \
787 encode_sequence_maxsz + \
788 encode_putfh_maxsz + \
789 encode_lookup_maxsz + \
790 encode_fs_locations_maxsz + \
792 #define NFS4_dec_fs_locations_sz \
793 (compound_decode_hdr_maxsz + \
794 decode_sequence_maxsz + \
795 decode_putfh_maxsz + \
796 decode_lookup_maxsz + \
797 decode_fs_locations_maxsz + \
799 #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \
800 encode_sequence_maxsz + \
801 encode_putfh_maxsz + \
802 encode_secinfo_maxsz)
803 #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \
804 decode_sequence_maxsz + \
805 decode_putfh_maxsz + \
806 decode_secinfo_maxsz)
807 #define NFS4_enc_fsid_present_sz \
808 (compound_encode_hdr_maxsz + \
809 encode_sequence_maxsz + \
810 encode_putfh_maxsz + \
811 encode_getfh_maxsz + \
813 #define NFS4_dec_fsid_present_sz \
814 (compound_decode_hdr_maxsz + \
815 decode_sequence_maxsz + \
816 decode_putfh_maxsz + \
817 decode_getfh_maxsz + \
819 #if defined(CONFIG_NFS_V4_1)
820 #define NFS4_enc_bind_conn_to_session_sz \
821 (compound_encode_hdr_maxsz + \
822 encode_bind_conn_to_session_maxsz)
823 #define NFS4_dec_bind_conn_to_session_sz \
824 (compound_decode_hdr_maxsz + \
825 decode_bind_conn_to_session_maxsz)
826 #define NFS4_enc_exchange_id_sz \
827 (compound_encode_hdr_maxsz + \
828 encode_exchange_id_maxsz)
829 #define NFS4_dec_exchange_id_sz \
830 (compound_decode_hdr_maxsz + \
831 decode_exchange_id_maxsz)
832 #define NFS4_enc_create_session_sz \
833 (compound_encode_hdr_maxsz + \
834 encode_create_session_maxsz)
835 #define NFS4_dec_create_session_sz \
836 (compound_decode_hdr_maxsz + \
837 decode_create_session_maxsz)
838 #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \
839 encode_destroy_session_maxsz)
840 #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \
841 decode_destroy_session_maxsz)
842 #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \
843 encode_destroy_clientid_maxsz)
844 #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \
845 decode_destroy_clientid_maxsz)
846 #define NFS4_enc_sequence_sz \
847 (compound_decode_hdr_maxsz + \
848 encode_sequence_maxsz)
849 #define NFS4_dec_sequence_sz \
850 (compound_decode_hdr_maxsz + \
851 decode_sequence_maxsz)
853 #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \
854 encode_sequence_maxsz + \
855 encode_putrootfh_maxsz + \
857 #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \
858 decode_sequence_maxsz + \
859 decode_putrootfh_maxsz + \
861 #if defined(CONFIG_NFS_V4_1)
862 #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
863 encode_sequence_maxsz + \
864 encode_reclaim_complete_maxsz)
865 #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \
866 decode_sequence_maxsz + \
867 decode_reclaim_complete_maxsz)
868 #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \
869 encode_sequence_maxsz +\
870 encode_getdeviceinfo_maxsz)
871 #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \
872 decode_sequence_maxsz + \
873 decode_getdeviceinfo_maxsz)
874 #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \
875 encode_sequence_maxsz + \
876 encode_putfh_maxsz + \
877 encode_layoutget_maxsz)
878 #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \
879 decode_sequence_maxsz + \
880 decode_putfh_maxsz + \
881 decode_layoutget_maxsz)
882 #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \
883 encode_sequence_maxsz +\
884 encode_putfh_maxsz + \
885 encode_layoutcommit_maxsz + \
886 encode_getattr_maxsz)
887 #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \
888 decode_sequence_maxsz + \
889 decode_putfh_maxsz + \
890 decode_layoutcommit_maxsz + \
891 decode_getattr_maxsz)
892 #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \
893 encode_sequence_maxsz + \
894 encode_putfh_maxsz + \
895 encode_layoutreturn_maxsz)
896 #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \
897 decode_sequence_maxsz + \
898 decode_putfh_maxsz + \
899 decode_layoutreturn_maxsz)
900 #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \
901 encode_sequence_maxsz + \
902 encode_putrootfh_maxsz +\
903 encode_secinfo_no_name_maxsz)
904 #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \
905 decode_sequence_maxsz + \
906 decode_putrootfh_maxsz + \
907 decode_secinfo_no_name_maxsz)
908 #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \
909 encode_sequence_maxsz + \
910 encode_test_stateid_maxsz)
911 #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \
912 decode_sequence_maxsz + \
913 decode_test_stateid_maxsz)
914 #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \
915 encode_sequence_maxsz + \
916 encode_free_stateid_maxsz)
917 #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \
918 decode_sequence_maxsz + \
919 decode_free_stateid_maxsz)
921 const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
922 compound_encode_hdr_maxsz +
923 encode_sequence_maxsz +
925 encode_getattr_maxsz) *
928 const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
929 compound_decode_hdr_maxsz +
930 decode_sequence_maxsz +
931 decode_putfh_maxsz) *
934 const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH +
935 compound_decode_hdr_maxsz +
936 decode_sequence_maxsz) *
938 EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead);
939 #endif /* CONFIG_NFS_V4_1 */
941 static const umode_t nfs_type2fmt[] = {
948 [NF4SOCK] = S_IFSOCK,
954 struct compound_hdr {
960 uint32_t replen; /* expected reply words */
964 static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
966 __be32 *p = xdr_reserve_space(xdr, nbytes);
971 static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
973 WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
976 static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
978 WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
981 static void encode_uint32(struct xdr_stream *xdr, u32 n)
983 WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
986 static void encode_uint64(struct xdr_stream *xdr, u64 n)
988 WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
991 static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr,
992 const __u32 *bitmap, size_t len)
996 /* Trim empty words */
997 while (len > 0 && bitmap[len-1] == 0)
999 ret = xdr_stream_encode_uint32_array(xdr, bitmap, len);
1000 if (WARN_ON_ONCE(ret < 0))
1005 static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask,
1006 __u32 *res, size_t len)
1011 while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0))
1013 for (i = len; i-- > 0;) {
1014 tmp = bitmap[i] & mask[i];
1020 static void encode_nfs4_seqid(struct xdr_stream *xdr,
1021 const struct nfs_seqid *seqid)
1024 encode_uint32(xdr, seqid->sequence->counter);
1026 encode_uint32(xdr, 0);
1029 static void encode_compound_hdr(struct xdr_stream *xdr,
1030 struct rpc_rqst *req,
1031 struct compound_hdr *hdr)
1035 /* initialize running count of expected bytes in reply.
1036 * NOTE: the replied tag SHOULD be the same is the one sent,
1037 * but this is not required as a MUST for the server to do so. */
1038 hdr->replen = 3 + hdr->taglen;
1040 WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN);
1041 encode_string(xdr, hdr->taglen, hdr->tag);
1042 p = reserve_space(xdr, 8);
1043 *p++ = cpu_to_be32(hdr->minorversion);
1045 *p = cpu_to_be32(hdr->nops);
1048 static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op,
1050 struct compound_hdr *hdr)
1052 encode_uint32(xdr, op);
1054 hdr->replen += replen;
1057 static void encode_nops(struct compound_hdr *hdr)
1059 WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS);
1060 *hdr->nops_p = htonl(hdr->nops);
1063 static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1065 encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
1068 static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
1070 encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE);
1074 xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t)
1076 p = xdr_encode_hyper(p, t->tv_sec);
1077 *p++ = cpu_to_be32(t->tv_nsec);
1081 static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1082 const struct nfs4_label *label,
1083 const umode_t *umask,
1084 const struct nfs_server *server,
1085 const uint32_t attrmask[])
1087 char owner_name[IDMAP_NAMESZ];
1088 char owner_group[IDMAP_NAMESZ];
1089 int owner_namelen = 0;
1090 int owner_grouplen = 0;
1093 uint32_t bmval[3] = { 0 };
1096 * We reserve enough space to write the entire attribute buffer at once.
1098 if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) {
1099 bmval[0] |= FATTR4_WORD0_SIZE;
1102 if (iap->ia_valid & ATTR_MODE) {
1103 if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) {
1104 bmval[2] |= FATTR4_WORD2_MODE_UMASK;
1106 } else if (attrmask[1] & FATTR4_WORD1_MODE) {
1107 bmval[1] |= FATTR4_WORD1_MODE;
1111 if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) {
1112 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
1113 if (owner_namelen < 0) {
1114 dprintk("nfs: couldn't resolve uid %d to string\n",
1115 from_kuid(&init_user_ns, iap->ia_uid));
1117 strcpy(owner_name, "nobody");
1118 owner_namelen = sizeof("nobody") - 1;
1121 bmval[1] |= FATTR4_WORD1_OWNER;
1122 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
1124 if ((iap->ia_valid & ATTR_GID) &&
1125 (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) {
1126 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
1127 if (owner_grouplen < 0) {
1128 dprintk("nfs: couldn't resolve gid %d to string\n",
1129 from_kgid(&init_user_ns, iap->ia_gid));
1130 strcpy(owner_group, "nobody");
1131 owner_grouplen = sizeof("nobody") - 1;
1134 bmval[1] |= FATTR4_WORD1_OWNER_GROUP;
1135 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
1137 if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1138 if (iap->ia_valid & ATTR_ATIME_SET) {
1139 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1140 len += 4 + (nfstime4_maxsz << 2);
1141 } else if (iap->ia_valid & ATTR_ATIME) {
1142 bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
1146 if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1147 if (iap->ia_valid & ATTR_MTIME_SET) {
1148 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1149 len += 4 + (nfstime4_maxsz << 2);
1150 } else if (iap->ia_valid & ATTR_MTIME) {
1151 bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
1156 if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) {
1157 len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
1158 bmval[2] |= FATTR4_WORD2_SECURITY_LABEL;
1161 xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval));
1162 xdr_stream_encode_opaque_inline(xdr, (void **)&p, len);
1164 if (bmval[0] & FATTR4_WORD0_SIZE)
1165 p = xdr_encode_hyper(p, iap->ia_size);
1166 if (bmval[1] & FATTR4_WORD1_MODE)
1167 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1168 if (bmval[1] & FATTR4_WORD1_OWNER)
1169 p = xdr_encode_opaque(p, owner_name, owner_namelen);
1170 if (bmval[1] & FATTR4_WORD1_OWNER_GROUP)
1171 p = xdr_encode_opaque(p, owner_group, owner_grouplen);
1172 if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
1173 if (iap->ia_valid & ATTR_ATIME_SET) {
1174 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1175 p = xdr_encode_nfstime4(p, &iap->ia_atime);
1177 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1179 if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
1180 if (iap->ia_valid & ATTR_MTIME_SET) {
1181 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
1182 p = xdr_encode_nfstime4(p, &iap->ia_mtime);
1184 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
1186 if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) {
1187 *p++ = cpu_to_be32(label->lfs);
1188 *p++ = cpu_to_be32(label->pi);
1189 *p++ = cpu_to_be32(label->len);
1190 p = xdr_encode_opaque_fixed(p, label->label, label->len);
1192 if (bmval[2] & FATTR4_WORD2_MODE_UMASK) {
1193 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
1194 *p++ = cpu_to_be32(*umask);
1200 static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
1202 encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr);
1203 encode_uint32(xdr, access);
1206 static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1208 encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr);
1209 encode_nfs4_seqid(xdr, arg->seqid);
1210 encode_nfs4_stateid(xdr, &arg->stateid);
1213 static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr)
1217 encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
1218 p = reserve_space(xdr, 12);
1219 p = xdr_encode_hyper(p, args->offset);
1220 *p = cpu_to_be32(args->count);
1223 static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
1227 encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr);
1228 encode_uint32(xdr, create->ftype);
1230 switch (create->ftype) {
1232 p = reserve_space(xdr, 4);
1233 *p = cpu_to_be32(create->u.symlink.len);
1234 xdr_write_pages(xdr, create->u.symlink.pages, 0,
1235 create->u.symlink.len);
1236 xdr->buf->flags |= XDRBUF_WRITE;
1239 case NF4BLK: case NF4CHR:
1240 p = reserve_space(xdr, 8);
1241 *p++ = cpu_to_be32(create->u.device.specdata1);
1242 *p = cpu_to_be32(create->u.device.specdata2);
1249 encode_string(xdr, create->name->len, create->name->name);
1250 encode_attrs(xdr, create->attrs, create->label, &create->umask,
1251 create->server, create->server->attr_bitmask);
1254 static void encode_getattr(struct xdr_stream *xdr,
1255 const __u32 *bitmap, const __u32 *mask, size_t len,
1256 struct compound_hdr *hdr)
1258 __u32 masked_bitmap[nfs4_fattr_bitmap_maxsz];
1260 encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr);
1262 if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap)))
1263 len = ARRAY_SIZE(masked_bitmap);
1264 len = mask_bitmap4(bitmap, mask, masked_bitmap, len);
1265 bitmap = masked_bitmap;
1267 xdr_encode_bitmap4(xdr, bitmap, len);
1270 static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1272 encode_getattr(xdr, nfs4_fattr_bitmap, bitmask,
1273 ARRAY_SIZE(nfs4_fattr_bitmap), hdr);
1276 static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask,
1277 const u32 *open_bitmap,
1278 struct compound_hdr *hdr)
1280 encode_getattr(xdr, open_bitmap, bitmask, 3, hdr);
1283 static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1285 encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask,
1286 ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr);
1289 static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1291 encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask,
1292 ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr);
1295 static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1297 encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr);
1300 static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1302 encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr);
1303 encode_string(xdr, name->len, name->name);
1306 static inline int nfs4_lock_type(struct file_lock *fl, int block)
1308 if (fl->fl_type == F_RDLCK)
1309 return block ? NFS4_READW_LT : NFS4_READ_LT;
1310 return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
1313 static inline uint64_t nfs4_lock_length(struct file_lock *fl)
1315 if (fl->fl_end == OFFSET_MAX)
1316 return ~(uint64_t)0;
1317 return fl->fl_end - fl->fl_start + 1;
1320 static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner)
1324 p = reserve_space(xdr, 32);
1325 p = xdr_encode_hyper(p, lowner->clientid);
1326 *p++ = cpu_to_be32(20);
1327 p = xdr_encode_opaque_fixed(p, "lock id:", 8);
1328 *p++ = cpu_to_be32(lowner->s_dev);
1329 xdr_encode_hyper(p, lowner->id);
1333 * opcode,type,reclaim,offset,length,new_lock_owner = 32
1334 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
1336 static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
1340 encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr);
1341 p = reserve_space(xdr, 28);
1342 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
1343 *p++ = cpu_to_be32(args->reclaim);
1344 p = xdr_encode_hyper(p, args->fl->fl_start);
1345 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1346 *p = cpu_to_be32(args->new_lock_owner);
1347 if (args->new_lock_owner){
1348 encode_nfs4_seqid(xdr, args->open_seqid);
1349 encode_nfs4_stateid(xdr, &args->open_stateid);
1350 encode_nfs4_seqid(xdr, args->lock_seqid);
1351 encode_lockowner(xdr, &args->lock_owner);
1354 encode_nfs4_stateid(xdr, &args->lock_stateid);
1355 encode_nfs4_seqid(xdr, args->lock_seqid);
1359 static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
1363 encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr);
1364 p = reserve_space(xdr, 20);
1365 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1366 p = xdr_encode_hyper(p, args->fl->fl_start);
1367 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1368 encode_lockowner(xdr, &args->lock_owner);
1371 static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
1375 encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr);
1376 encode_uint32(xdr, nfs4_lock_type(args->fl, 0));
1377 encode_nfs4_seqid(xdr, args->seqid);
1378 encode_nfs4_stateid(xdr, &args->stateid);
1379 p = reserve_space(xdr, 16);
1380 p = xdr_encode_hyper(p, args->fl->fl_start);
1381 xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1384 static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
1386 encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr);
1387 encode_lockowner(xdr, lowner);
1390 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1392 encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr);
1393 encode_string(xdr, name->len, name->name);
1396 static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr)
1398 encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr);
1401 static void encode_share_access(struct xdr_stream *xdr, u32 share_access)
1405 p = reserve_space(xdr, 8);
1406 *p++ = cpu_to_be32(share_access);
1407 *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */
1410 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1414 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1417 encode_nfs4_seqid(xdr, arg->seqid);
1418 encode_share_access(xdr, arg->share_access);
1419 p = reserve_space(xdr, 36);
1420 p = xdr_encode_hyper(p, arg->clientid);
1421 *p++ = cpu_to_be32(24);
1422 p = xdr_encode_opaque_fixed(p, "open id:", 8);
1423 *p++ = cpu_to_be32(arg->server->s_dev);
1424 *p++ = cpu_to_be32(arg->id.uniquifier);
1425 xdr_encode_hyper(p, arg->id.create_time);
1428 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1432 p = reserve_space(xdr, 4);
1433 switch(arg->createmode) {
1434 case NFS4_CREATE_UNCHECKED:
1435 *p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
1436 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1437 arg->server, arg->server->attr_bitmask);
1439 case NFS4_CREATE_GUARDED:
1440 *p = cpu_to_be32(NFS4_CREATE_GUARDED);
1441 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1442 arg->server, arg->server->attr_bitmask);
1444 case NFS4_CREATE_EXCLUSIVE:
1445 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
1446 encode_nfs4_verifier(xdr, &arg->u.verifier);
1448 case NFS4_CREATE_EXCLUSIVE4_1:
1449 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
1450 encode_nfs4_verifier(xdr, &arg->u.verifier);
1451 encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
1452 arg->server, arg->server->exclcreat_bitmask);
1456 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1460 p = reserve_space(xdr, 4);
1461 switch (arg->open_flags & O_CREAT) {
1463 *p = cpu_to_be32(NFS4_OPEN_NOCREATE);
1466 *p = cpu_to_be32(NFS4_OPEN_CREATE);
1467 encode_createmode(xdr, arg);
1471 static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
1475 p = reserve_space(xdr, 4);
1476 switch (delegation_type) {
1478 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
1481 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ);
1483 case FMODE_WRITE|FMODE_READ:
1484 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE);
1491 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
1495 p = reserve_space(xdr, 4);
1496 *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
1497 encode_string(xdr, name->len, name->name);
1500 static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1504 p = reserve_space(xdr, 4);
1505 *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
1506 encode_delegation_type(xdr, type);
1509 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
1513 p = reserve_space(xdr, 4);
1514 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1515 encode_nfs4_stateid(xdr, stateid);
1516 encode_string(xdr, name->len, name->name);
1519 static inline void encode_claim_fh(struct xdr_stream *xdr)
1523 p = reserve_space(xdr, 4);
1524 *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH);
1527 static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1531 p = reserve_space(xdr, 4);
1532 *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
1533 encode_nfs4_stateid(xdr, stateid);
1536 static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
1538 encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr);
1539 encode_openhdr(xdr, arg);
1540 encode_opentype(xdr, arg);
1541 switch (arg->claim) {
1542 case NFS4_OPEN_CLAIM_NULL:
1543 encode_claim_null(xdr, arg->name);
1545 case NFS4_OPEN_CLAIM_PREVIOUS:
1546 encode_claim_previous(xdr, arg->u.delegation_type);
1548 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
1549 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
1551 case NFS4_OPEN_CLAIM_FH:
1552 encode_claim_fh(xdr);
1554 case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
1555 encode_claim_delegate_cur_fh(xdr, &arg->u.delegation);
1562 static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
1564 encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr);
1565 encode_nfs4_stateid(xdr, arg->stateid);
1566 encode_nfs4_seqid(xdr, arg->seqid);
1569 static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1571 encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr);
1572 encode_nfs4_stateid(xdr, &arg->stateid);
1573 encode_nfs4_seqid(xdr, arg->seqid);
1574 encode_share_access(xdr, arg->share_access);
1578 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1580 encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr);
1581 encode_string(xdr, fh->size, fh->data);
1584 static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1586 encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
1589 static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1590 struct compound_hdr *hdr)
1594 encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
1595 encode_nfs4_stateid(xdr, &args->stateid);
1597 p = reserve_space(xdr, 12);
1598 p = xdr_encode_hyper(p, args->offset);
1599 *p = cpu_to_be32(args->count);
1602 static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
1604 uint32_t attrs[3] = {
1605 FATTR4_WORD0_RDATTR_ERROR,
1606 FATTR4_WORD1_MOUNTED_ON_FILEID,
1608 uint32_t dircount = readdir->count;
1609 uint32_t maxcount = readdir->count;
1611 uint32_t attrlen = 0;
1614 if (readdir->plus) {
1615 attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
1616 FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID;
1617 attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
1618 FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
1619 FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
1620 FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
1621 attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
1623 /* Use mounted_on_fileid only if the server supports it */
1624 if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID))
1625 attrs[0] |= FATTR4_WORD0_FILEID;
1626 for (i = 0; i < ARRAY_SIZE(attrs); i++) {
1627 attrs[i] &= readdir->bitmask[i];
1632 encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr);
1633 encode_uint64(xdr, readdir->cookie);
1634 encode_nfs4_verifier(xdr, &readdir->verifier);
1635 p = reserve_space(xdr, 12 + (attrlen << 2));
1636 *p++ = cpu_to_be32(dircount);
1637 *p++ = cpu_to_be32(maxcount);
1638 *p++ = cpu_to_be32(attrlen);
1639 for (i = 0; i < attrlen; i++)
1640 *p++ = cpu_to_be32(attrs[i]);
1641 memcpy(verf, readdir->verifier.data, sizeof(verf));
1643 dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n",
1645 (unsigned long long)readdir->cookie,
1647 attrs[0] & readdir->bitmask[0],
1648 attrs[1] & readdir->bitmask[1],
1649 attrs[2] & readdir->bitmask[2]);
1652 static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
1654 encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr);
1657 static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1659 encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr);
1660 encode_string(xdr, name->len, name->name);
1663 static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
1665 encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr);
1666 encode_string(xdr, oldname->len, oldname->name);
1667 encode_string(xdr, newname->len, newname->name);
1670 static void encode_renew(struct xdr_stream *xdr, clientid4 clid,
1671 struct compound_hdr *hdr)
1673 encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr);
1674 encode_uint64(xdr, clid);
1678 encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1680 encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr);
1683 static void nfs4_acltype_to_bitmap(enum nfs4_acl_type type, __u32 bitmap[2])
1687 bitmap[0] = FATTR4_WORD0_ACL;
1692 bitmap[1] = FATTR4_WORD1_DACL;
1696 bitmap[1] = FATTR4_WORD1_SACL;
1700 static void encode_setacl(struct xdr_stream *xdr,
1701 const struct nfs_setaclargs *arg,
1702 struct compound_hdr *hdr)
1706 nfs4_acltype_to_bitmap(arg->acl_type, bitmap);
1708 encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr);
1709 encode_nfs4_stateid(xdr, &zero_stateid);
1710 xdr_encode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap));
1711 encode_uint32(xdr, arg->acl_len);
1712 xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len);
1716 encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1718 encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr);
1721 static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
1723 encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr);
1724 encode_nfs4_stateid(xdr, &arg->stateid);
1725 encode_attrs(xdr, arg->iap, arg->label, NULL, server,
1726 server->attr_bitmask);
1729 static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
1733 encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr);
1734 encode_nfs4_verifier(xdr, setclientid->sc_verifier);
1736 encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id),
1737 setclientid->sc_clnt->cl_owner_id);
1738 p = reserve_space(xdr, 4);
1739 *p = cpu_to_be32(setclientid->sc_prog);
1740 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1741 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1742 p = reserve_space(xdr, 4);
1743 *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident);
1746 static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
1748 encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM,
1749 decode_setclientid_confirm_maxsz, hdr);
1750 encode_uint64(xdr, arg->clientid);
1751 encode_nfs4_verifier(xdr, &arg->confirm);
1754 static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
1755 struct compound_hdr *hdr)
1759 encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
1760 encode_nfs4_stateid(xdr, &args->stateid);
1762 p = reserve_space(xdr, 16);
1763 p = xdr_encode_hyper(p, args->offset);
1764 *p++ = cpu_to_be32(args->stable);
1765 *p = cpu_to_be32(args->count);
1767 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1770 static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
1772 encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr);
1773 encode_nfs4_stateid(xdr, stateid);
1776 static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1778 encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr);
1779 encode_string(xdr, name->len, name->name);
1782 #if defined(CONFIG_NFS_V4_1)
1783 /* NFSv4.1 operations */
1784 static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1785 const struct nfs41_bind_conn_to_session_args *args,
1786 struct compound_hdr *hdr)
1790 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
1791 decode_bind_conn_to_session_maxsz, hdr);
1792 encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
1793 p = xdr_reserve_space(xdr, 8);
1794 *p++ = cpu_to_be32(args->dir);
1795 *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
1798 static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map)
1801 encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS);
1802 for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++)
1803 encode_uint32(xdr, op_map->u.words[i]);
1806 static void encode_exchange_id(struct xdr_stream *xdr,
1807 const struct nfs41_exchange_id_args *args,
1808 struct compound_hdr *hdr)
1811 char impl_name[IMPL_NAME_LIMIT];
1814 encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
1815 encode_nfs4_verifier(xdr, &args->verifier);
1817 encode_string(xdr, strlen(args->client->cl_owner_id),
1818 args->client->cl_owner_id);
1820 encode_uint32(xdr, args->flags);
1821 encode_uint32(xdr, args->state_protect.how);
1823 switch (args->state_protect.how) {
1827 encode_op_map(xdr, &args->state_protect.enforce);
1828 encode_op_map(xdr, &args->state_protect.allow);
1835 if (send_implementation_id &&
1836 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 &&
1837 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN)
1838 <= sizeof(impl_name) + 1)
1839 len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s",
1840 utsname()->sysname, utsname()->release,
1841 utsname()->version, utsname()->machine);
1844 encode_uint32(xdr, 1); /* implementation id array length=1 */
1847 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1,
1848 CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN);
1849 encode_string(xdr, len, impl_name);
1850 /* just send zeros for nii_date - the date is in nii_name */
1851 p = reserve_space(xdr, 12);
1852 p = xdr_encode_hyper(p, 0);
1853 *p = cpu_to_be32(0);
1855 encode_uint32(xdr, 0); /* implementation id array length=0 */
1858 static void encode_create_session(struct xdr_stream *xdr,
1859 const struct nfs41_create_session_args *args,
1860 struct compound_hdr *hdr)
1863 struct nfs_client *clp = args->client;
1864 struct rpc_clnt *clnt = clp->cl_rpcclient;
1865 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
1866 u32 max_resp_sz_cached;
1869 * Assumes OPEN is the biggest non-idempotent compound.
1870 * 2 is the verifier.
1872 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
1873 * XDR_UNIT + RPC_MAX_AUTH_SIZE;
1875 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
1876 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
1877 p = xdr_encode_hyper(p, args->clientid);
1878 *p++ = cpu_to_be32(args->seqid); /*Sequence id */
1879 *p++ = cpu_to_be32(args->flags); /*flags */
1882 *p++ = cpu_to_be32(0); /* header padding size */
1883 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */
1884 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */
1885 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */
1886 *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */
1887 *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */
1888 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1891 *p++ = cpu_to_be32(0); /* header padding size */
1892 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */
1893 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */
1894 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */
1895 *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */
1896 *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */
1897 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1899 *p++ = cpu_to_be32(args->cb_program); /* cb_program */
1900 *p++ = cpu_to_be32(1);
1901 *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
1903 /* authsys_parms rfc1831 */
1904 *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
1905 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
1906 *p++ = cpu_to_be32(0); /* UID */
1907 *p++ = cpu_to_be32(0); /* GID */
1908 *p = cpu_to_be32(0); /* No more gids */
1911 static void encode_destroy_session(struct xdr_stream *xdr,
1912 const struct nfs4_session *session,
1913 struct compound_hdr *hdr)
1915 encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr);
1916 encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1919 static void encode_destroy_clientid(struct xdr_stream *xdr,
1921 struct compound_hdr *hdr)
1923 encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr);
1924 encode_uint64(xdr, clientid);
1927 static void encode_reclaim_complete(struct xdr_stream *xdr,
1928 const struct nfs41_reclaim_complete_args *args,
1929 struct compound_hdr *hdr)
1931 encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr);
1932 encode_uint32(xdr, args->one_fs);
1934 #endif /* CONFIG_NFS_V4_1 */
1936 static void encode_sequence(struct xdr_stream *xdr,
1937 const struct nfs4_sequence_args *args,
1938 struct compound_hdr *hdr)
1940 #if defined(CONFIG_NFS_V4_1)
1941 struct nfs4_session *session;
1942 struct nfs4_slot_table *tp;
1943 struct nfs4_slot *slot = args->sa_slot;
1947 session = tp->session;
1951 encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr);
1954 * Sessionid + seqid + slotid + max slotid + cache_this
1956 dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
1957 "max_slotid=%d cache_this=%d\n",
1959 ((u32 *)session->sess_id.data)[0],
1960 ((u32 *)session->sess_id.data)[1],
1961 ((u32 *)session->sess_id.data)[2],
1962 ((u32 *)session->sess_id.data)[3],
1963 slot->seq_nr, slot->slot_nr,
1964 tp->highest_used_slotid, args->sa_cache_this);
1965 p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16);
1966 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1967 *p++ = cpu_to_be32(slot->seq_nr);
1968 *p++ = cpu_to_be32(slot->slot_nr);
1969 *p++ = cpu_to_be32(tp->highest_used_slotid);
1970 *p = cpu_to_be32(args->sa_cache_this);
1971 #endif /* CONFIG_NFS_V4_1 */
1974 #ifdef CONFIG_NFS_V4_1
1976 encode_getdeviceinfo(struct xdr_stream *xdr,
1977 const struct nfs4_getdeviceinfo_args *args,
1978 struct compound_hdr *hdr)
1982 encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr);
1983 p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4);
1984 p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data,
1985 NFS4_DEVICEID4_SIZE);
1986 *p++ = cpu_to_be32(args->pdev->layout_type);
1987 *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */
1989 p = reserve_space(xdr, 4 + 4);
1990 *p++ = cpu_to_be32(1); /* bitmap length */
1991 *p++ = cpu_to_be32(args->notify_types);
1995 encode_layoutget(struct xdr_stream *xdr,
1996 const struct nfs4_layoutget_args *args,
1997 struct compound_hdr *hdr)
2001 encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr);
2002 p = reserve_space(xdr, 36);
2003 *p++ = cpu_to_be32(0); /* Signal layout available */
2004 *p++ = cpu_to_be32(args->type);
2005 *p++ = cpu_to_be32(args->range.iomode);
2006 p = xdr_encode_hyper(p, args->range.offset);
2007 p = xdr_encode_hyper(p, args->range.length);
2008 p = xdr_encode_hyper(p, args->minlength);
2009 encode_nfs4_stateid(xdr, &args->stateid);
2010 encode_uint32(xdr, args->maxcount);
2012 dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n",
2016 (unsigned long)args->range.offset,
2017 (unsigned long)args->range.length,
2022 encode_layoutcommit(struct xdr_stream *xdr,
2023 struct inode *inode,
2024 const struct nfs4_layoutcommit_args *args,
2025 struct compound_hdr *hdr)
2029 dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten,
2030 NFS_SERVER(args->inode)->pnfs_curr_ld->id);
2032 encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr);
2033 p = reserve_space(xdr, 20);
2034 /* Only whole file layouts */
2035 p = xdr_encode_hyper(p, 0); /* offset */
2036 p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */
2037 *p = cpu_to_be32(0); /* reclaim */
2038 encode_nfs4_stateid(xdr, &args->stateid);
2039 if (args->lastbytewritten != U64_MAX) {
2040 p = reserve_space(xdr, 20);
2041 *p++ = cpu_to_be32(1); /* newoffset = TRUE */
2042 p = xdr_encode_hyper(p, args->lastbytewritten);
2044 p = reserve_space(xdr, 12);
2045 *p++ = cpu_to_be32(0); /* newoffset = FALSE */
2047 *p++ = cpu_to_be32(0); /* Never send time_modify_changed */
2048 *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
2050 encode_uint32(xdr, args->layoutupdate_len);
2051 if (args->layoutupdate_pages)
2052 xdr_write_pages(xdr, args->layoutupdate_pages, 0,
2053 args->layoutupdate_len);
2059 encode_layoutreturn(struct xdr_stream *xdr,
2060 const struct nfs4_layoutreturn_args *args,
2061 struct compound_hdr *hdr)
2065 encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr);
2066 p = reserve_space(xdr, 16);
2067 *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */
2068 *p++ = cpu_to_be32(args->layout_type);
2069 *p++ = cpu_to_be32(args->range.iomode);
2070 *p = cpu_to_be32(RETURN_FILE);
2071 p = reserve_space(xdr, 16);
2072 p = xdr_encode_hyper(p, args->range.offset);
2073 p = xdr_encode_hyper(p, args->range.length);
2074 spin_lock(&args->inode->i_lock);
2075 encode_nfs4_stateid(xdr, &args->stateid);
2076 spin_unlock(&args->inode->i_lock);
2077 if (args->ld_private->ops && args->ld_private->ops->encode)
2078 args->ld_private->ops->encode(xdr, args, args->ld_private);
2080 encode_uint32(xdr, 0);
2084 encode_secinfo_no_name(struct xdr_stream *xdr,
2085 const struct nfs41_secinfo_no_name_args *args,
2086 struct compound_hdr *hdr)
2088 encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr);
2089 encode_uint32(xdr, args->style);
2093 static void encode_test_stateid(struct xdr_stream *xdr,
2094 const struct nfs41_test_stateid_args *args,
2095 struct compound_hdr *hdr)
2097 encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr);
2098 encode_uint32(xdr, 1);
2099 encode_nfs4_stateid(xdr, args->stateid);
2102 static void encode_free_stateid(struct xdr_stream *xdr,
2103 const struct nfs41_free_stateid_args *args,
2104 struct compound_hdr *hdr)
2106 encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr);
2107 encode_nfs4_stateid(xdr, &args->stateid);
2111 encode_layoutreturn(struct xdr_stream *xdr,
2112 const struct nfs4_layoutreturn_args *args,
2113 struct compound_hdr *hdr)
2118 encode_layoutget(struct xdr_stream *xdr,
2119 const struct nfs4_layoutget_args *args,
2120 struct compound_hdr *hdr)
2123 #endif /* CONFIG_NFS_V4_1 */
2126 * END OF "GENERIC" ENCODE ROUTINES.
2129 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
2131 #if defined(CONFIG_NFS_V4_1)
2132 struct nfs4_session *session = args->sa_slot->table->session;
2134 return session->clp->cl_mvops->minor_version;
2135 #endif /* CONFIG_NFS_V4_1 */
2140 * Encode an ACCESS request
2142 static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr,
2145 const struct nfs4_accessargs *args = data;
2146 struct compound_hdr hdr = {
2147 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2150 encode_compound_hdr(xdr, req, &hdr);
2151 encode_sequence(xdr, &args->seq_args, &hdr);
2152 encode_putfh(xdr, args->fh, &hdr);
2153 encode_access(xdr, args->access, &hdr);
2155 encode_getfattr(xdr, args->bitmask, &hdr);
2160 * Encode LOOKUP request
2162 static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr,
2165 const struct nfs4_lookup_arg *args = data;
2166 struct compound_hdr hdr = {
2167 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2170 encode_compound_hdr(xdr, req, &hdr);
2171 encode_sequence(xdr, &args->seq_args, &hdr);
2172 encode_putfh(xdr, args->dir_fh, &hdr);
2173 encode_lookup(xdr, args->name, &hdr);
2174 encode_getfh(xdr, &hdr);
2175 encode_getfattr(xdr, args->bitmask, &hdr);
2180 * Encode LOOKUPP request
2182 static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr,
2185 const struct nfs4_lookupp_arg *args = data;
2186 struct compound_hdr hdr = {
2187 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2190 encode_compound_hdr(xdr, req, &hdr);
2191 encode_sequence(xdr, &args->seq_args, &hdr);
2192 encode_putfh(xdr, args->fh, &hdr);
2193 encode_lookupp(xdr, &hdr);
2194 encode_getfh(xdr, &hdr);
2195 encode_getfattr(xdr, args->bitmask, &hdr);
2200 * Encode LOOKUP_ROOT request
2202 static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req,
2203 struct xdr_stream *xdr,
2206 const struct nfs4_lookup_root_arg *args = data;
2207 struct compound_hdr hdr = {
2208 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2211 encode_compound_hdr(xdr, req, &hdr);
2212 encode_sequence(xdr, &args->seq_args, &hdr);
2213 encode_putrootfh(xdr, &hdr);
2214 encode_getfh(xdr, &hdr);
2215 encode_getfattr(xdr, args->bitmask, &hdr);
2220 * Encode REMOVE request
2222 static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
2225 const struct nfs_removeargs *args = data;
2226 struct compound_hdr hdr = {
2227 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2230 encode_compound_hdr(xdr, req, &hdr);
2231 encode_sequence(xdr, &args->seq_args, &hdr);
2232 encode_putfh(xdr, args->fh, &hdr);
2233 encode_remove(xdr, &args->name, &hdr);
2238 * Encode RENAME request
2240 static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
2243 const struct nfs_renameargs *args = data;
2244 struct compound_hdr hdr = {
2245 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2248 encode_compound_hdr(xdr, req, &hdr);
2249 encode_sequence(xdr, &args->seq_args, &hdr);
2250 encode_putfh(xdr, args->old_dir, &hdr);
2251 encode_savefh(xdr, &hdr);
2252 encode_putfh(xdr, args->new_dir, &hdr);
2253 encode_rename(xdr, args->old_name, args->new_name, &hdr);
2258 * Encode LINK request
2260 static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
2263 const struct nfs4_link_arg *args = data;
2264 struct compound_hdr hdr = {
2265 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2268 encode_compound_hdr(xdr, req, &hdr);
2269 encode_sequence(xdr, &args->seq_args, &hdr);
2270 encode_putfh(xdr, args->fh, &hdr);
2271 encode_savefh(xdr, &hdr);
2272 encode_putfh(xdr, args->dir_fh, &hdr);
2273 encode_link(xdr, args->name, &hdr);
2274 encode_restorefh(xdr, &hdr);
2275 encode_getfattr(xdr, args->bitmask, &hdr);
2280 * Encode CREATE request
2282 static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr,
2285 const struct nfs4_create_arg *args = data;
2286 struct compound_hdr hdr = {
2287 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2290 encode_compound_hdr(xdr, req, &hdr);
2291 encode_sequence(xdr, &args->seq_args, &hdr);
2292 encode_putfh(xdr, args->dir_fh, &hdr);
2293 encode_create(xdr, args, &hdr);
2294 encode_getfh(xdr, &hdr);
2295 encode_getfattr(xdr, args->bitmask, &hdr);
2300 * Encode SYMLINK request
2302 static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2305 const struct nfs4_create_arg *args = data;
2307 nfs4_xdr_enc_create(req, xdr, args);
2311 * Encode GETATTR request
2313 static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2316 const struct nfs4_getattr_arg *args = data;
2317 struct compound_hdr hdr = {
2318 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2321 encode_compound_hdr(xdr, req, &hdr);
2322 encode_sequence(xdr, &args->seq_args, &hdr);
2323 encode_putfh(xdr, args->fh, &hdr);
2324 encode_getfattr(xdr, args->bitmask, &hdr);
2329 * Encode a CLOSE request
2331 static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
2334 const struct nfs_closeargs *args = data;
2335 struct compound_hdr hdr = {
2336 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2339 encode_compound_hdr(xdr, req, &hdr);
2340 encode_sequence(xdr, &args->seq_args, &hdr);
2341 encode_putfh(xdr, args->fh, &hdr);
2343 encode_layoutreturn(xdr, args->lr_args, &hdr);
2344 if (args->bitmask != NULL)
2345 encode_getfattr(xdr, args->bitmask, &hdr);
2346 encode_close(xdr, args, &hdr);
2351 * Encode an OPEN request
2353 static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
2356 const struct nfs_openargs *args = data;
2357 struct compound_hdr hdr = {
2358 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2361 encode_compound_hdr(xdr, req, &hdr);
2362 encode_sequence(xdr, &args->seq_args, &hdr);
2363 encode_putfh(xdr, args->fh, &hdr);
2364 encode_open(xdr, args, &hdr);
2365 encode_getfh(xdr, &hdr);
2367 encode_access(xdr, args->access, &hdr);
2368 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2369 if (args->lg_args) {
2370 encode_layoutget(xdr, args->lg_args, &hdr);
2371 rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0,
2372 args->lg_args->layout.pglen,
2373 hdr.replen - pagepad_maxsz);
2379 * Encode an OPEN_CONFIRM request
2381 static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req,
2382 struct xdr_stream *xdr,
2385 const struct nfs_open_confirmargs *args = data;
2386 struct compound_hdr hdr = {
2390 encode_compound_hdr(xdr, req, &hdr);
2391 encode_putfh(xdr, args->fh, &hdr);
2392 encode_open_confirm(xdr, args, &hdr);
2397 * Encode an OPEN request with no attributes.
2399 static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
2400 struct xdr_stream *xdr,
2403 const struct nfs_openargs *args = data;
2404 struct compound_hdr hdr = {
2405 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2408 encode_compound_hdr(xdr, req, &hdr);
2409 encode_sequence(xdr, &args->seq_args, &hdr);
2410 encode_putfh(xdr, args->fh, &hdr);
2411 encode_open(xdr, args, &hdr);
2413 encode_access(xdr, args->access, &hdr);
2414 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
2415 if (args->lg_args) {
2416 encode_layoutget(xdr, args->lg_args, &hdr);
2417 rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0,
2418 args->lg_args->layout.pglen,
2419 hdr.replen - pagepad_maxsz);
2425 * Encode an OPEN_DOWNGRADE request
2427 static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req,
2428 struct xdr_stream *xdr,
2431 const struct nfs_closeargs *args = data;
2432 struct compound_hdr hdr = {
2433 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2436 encode_compound_hdr(xdr, req, &hdr);
2437 encode_sequence(xdr, &args->seq_args, &hdr);
2438 encode_putfh(xdr, args->fh, &hdr);
2440 encode_layoutreturn(xdr, args->lr_args, &hdr);
2441 encode_open_downgrade(xdr, args, &hdr);
2446 * Encode a LOCK request
2448 static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr,
2451 const struct nfs_lock_args *args = data;
2452 struct compound_hdr hdr = {
2453 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2456 encode_compound_hdr(xdr, req, &hdr);
2457 encode_sequence(xdr, &args->seq_args, &hdr);
2458 encode_putfh(xdr, args->fh, &hdr);
2459 encode_lock(xdr, args, &hdr);
2464 * Encode a LOCKT request
2466 static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr,
2469 const struct nfs_lockt_args *args = data;
2470 struct compound_hdr hdr = {
2471 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2474 encode_compound_hdr(xdr, req, &hdr);
2475 encode_sequence(xdr, &args->seq_args, &hdr);
2476 encode_putfh(xdr, args->fh, &hdr);
2477 encode_lockt(xdr, args, &hdr);
2482 * Encode a LOCKU request
2484 static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
2487 const struct nfs_locku_args *args = data;
2488 struct compound_hdr hdr = {
2489 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2492 encode_compound_hdr(xdr, req, &hdr);
2493 encode_sequence(xdr, &args->seq_args, &hdr);
2494 encode_putfh(xdr, args->fh, &hdr);
2495 encode_locku(xdr, args, &hdr);
2499 static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
2500 struct xdr_stream *xdr,
2503 const struct nfs_release_lockowner_args *args = data;
2504 struct compound_hdr hdr = {
2508 encode_compound_hdr(xdr, req, &hdr);
2509 encode_release_lockowner(xdr, &args->lock_owner, &hdr);
2514 * Encode a READLINK request
2516 static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2519 const struct nfs4_readlink *args = data;
2520 struct compound_hdr hdr = {
2521 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2524 encode_compound_hdr(xdr, req, &hdr);
2525 encode_sequence(xdr, &args->seq_args, &hdr);
2526 encode_putfh(xdr, args->fh, &hdr);
2527 encode_readlink(xdr, args, req, &hdr);
2529 rpc_prepare_reply_pages(req, args->pages, args->pgbase,
2530 args->pglen, hdr.replen - pagepad_maxsz);
2535 * Encode a READDIR request
2537 static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
2540 const struct nfs4_readdir_arg *args = data;
2541 struct compound_hdr hdr = {
2542 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2545 encode_compound_hdr(xdr, req, &hdr);
2546 encode_sequence(xdr, &args->seq_args, &hdr);
2547 encode_putfh(xdr, args->fh, &hdr);
2548 encode_readdir(xdr, args, req, &hdr);
2550 rpc_prepare_reply_pages(req, args->pages, args->pgbase,
2551 args->count, hdr.replen - pagepad_maxsz);
2556 * Encode a READ request
2558 static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
2561 const struct nfs_pgio_args *args = data;
2562 struct compound_hdr hdr = {
2563 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2566 encode_compound_hdr(xdr, req, &hdr);
2567 encode_sequence(xdr, &args->seq_args, &hdr);
2568 encode_putfh(xdr, args->fh, &hdr);
2569 encode_read(xdr, args, &hdr);
2571 rpc_prepare_reply_pages(req, args->pages, args->pgbase,
2572 args->count, hdr.replen - pagepad_maxsz);
2573 req->rq_rcv_buf.flags |= XDRBUF_READ;
2578 * Encode an SETATTR request
2580 static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2583 const struct nfs_setattrargs *args = data;
2584 struct compound_hdr hdr = {
2585 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2588 encode_compound_hdr(xdr, req, &hdr);
2589 encode_sequence(xdr, &args->seq_args, &hdr);
2590 encode_putfh(xdr, args->fh, &hdr);
2591 encode_setattr(xdr, args, args->server, &hdr);
2592 encode_getfattr(xdr, args->bitmask, &hdr);
2597 * Encode a GETACL request
2599 static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2602 const struct nfs_getaclargs *args = data;
2603 struct compound_hdr hdr = {
2604 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2606 __u32 nfs4_acl_bitmap[2];
2609 nfs4_acltype_to_bitmap(args->acl_type, nfs4_acl_bitmap);
2611 encode_compound_hdr(xdr, req, &hdr);
2612 encode_sequence(xdr, &args->seq_args, &hdr);
2613 encode_putfh(xdr, args->fh, &hdr);
2614 replen = hdr.replen + op_decode_hdr_maxsz;
2615 encode_getattr(xdr, nfs4_acl_bitmap, NULL,
2616 ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
2618 rpc_prepare_reply_pages(req, args->acl_pages, 0,
2619 args->acl_len, replen);
2624 * Encode a WRITE request
2626 static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
2629 const struct nfs_pgio_args *args = data;
2630 struct compound_hdr hdr = {
2631 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2634 encode_compound_hdr(xdr, req, &hdr);
2635 encode_sequence(xdr, &args->seq_args, &hdr);
2636 encode_putfh(xdr, args->fh, &hdr);
2637 encode_write(xdr, args, &hdr);
2638 req->rq_snd_buf.flags |= XDRBUF_WRITE;
2640 encode_getfattr(xdr, args->bitmask, &hdr);
2647 static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr,
2650 const struct nfs_commitargs *args = data;
2651 struct compound_hdr hdr = {
2652 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2655 encode_compound_hdr(xdr, req, &hdr);
2656 encode_sequence(xdr, &args->seq_args, &hdr);
2657 encode_putfh(xdr, args->fh, &hdr);
2658 encode_commit(xdr, args, &hdr);
2665 static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
2668 const struct nfs4_fsinfo_arg *args = data;
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->fh, &hdr);
2676 encode_fsinfo(xdr, args->bitmask, &hdr);
2681 * a PATHCONF request
2683 static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
2686 const struct nfs4_pathconf_arg *args = data;
2687 struct compound_hdr hdr = {
2688 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2691 encode_compound_hdr(xdr, req, &hdr);
2692 encode_sequence(xdr, &args->seq_args, &hdr);
2693 encode_putfh(xdr, args->fh, &hdr);
2694 encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask,
2695 ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr);
2702 static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
2705 const struct nfs4_statfs_arg *args = data;
2706 struct compound_hdr hdr = {
2707 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2710 encode_compound_hdr(xdr, req, &hdr);
2711 encode_sequence(xdr, &args->seq_args, &hdr);
2712 encode_putfh(xdr, args->fh, &hdr);
2713 encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask,
2714 ARRAY_SIZE(nfs4_statfs_bitmap), &hdr);
2719 * GETATTR_BITMAP request
2721 static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
2722 struct xdr_stream *xdr,
2725 const struct nfs4_server_caps_arg *args = data;
2726 const u32 *bitmask = args->bitmask;
2727 struct compound_hdr hdr = {
2728 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2731 encode_compound_hdr(xdr, req, &hdr);
2732 encode_sequence(xdr, &args->seq_args, &hdr);
2733 encode_putfh(xdr, args->fhandle, &hdr);
2734 encode_getattr(xdr, bitmask, NULL, 3, &hdr);
2741 static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
2745 const struct nfs_client *clp = data;
2746 struct compound_hdr hdr = {
2750 encode_compound_hdr(xdr, req, &hdr);
2751 encode_renew(xdr, clp->cl_clientid, &hdr);
2756 * a SETCLIENTID request
2758 static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req,
2759 struct xdr_stream *xdr,
2762 const struct nfs4_setclientid *sc = data;
2763 struct compound_hdr hdr = {
2767 encode_compound_hdr(xdr, req, &hdr);
2768 encode_setclientid(xdr, sc, &hdr);
2773 * a SETCLIENTID_CONFIRM request
2775 static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
2776 struct xdr_stream *xdr,
2779 const struct nfs4_setclientid_res *arg = data;
2780 struct compound_hdr hdr = {
2784 encode_compound_hdr(xdr, req, &hdr);
2785 encode_setclientid_confirm(xdr, arg, &hdr);
2790 * DELEGRETURN request
2792 static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req,
2793 struct xdr_stream *xdr,
2796 const struct nfs4_delegreturnargs *args = data;
2797 struct compound_hdr hdr = {
2798 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2801 encode_compound_hdr(xdr, req, &hdr);
2802 encode_sequence(xdr, &args->seq_args, &hdr);
2803 encode_putfh(xdr, args->fhandle, &hdr);
2805 encode_layoutreturn(xdr, args->lr_args, &hdr);
2807 encode_getfattr(xdr, args->bitmask, &hdr);
2808 encode_delegreturn(xdr, args->stateid, &hdr);
2813 * Encode FS_LOCATIONS request
2815 static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
2816 struct xdr_stream *xdr,
2819 const struct nfs4_fs_locations_arg *args = data;
2820 struct compound_hdr hdr = {
2821 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2825 encode_compound_hdr(xdr, req, &hdr);
2826 encode_sequence(xdr, &args->seq_args, &hdr);
2827 if (args->migration) {
2828 encode_putfh(xdr, args->fh, &hdr);
2829 replen = hdr.replen;
2830 encode_fs_locations(xdr, args->bitmask, &hdr);
2832 encode_renew(xdr, args->clientid, &hdr);
2834 encode_putfh(xdr, args->dir_fh, &hdr);
2835 encode_lookup(xdr, args->name, &hdr);
2836 replen = hdr.replen;
2837 encode_fs_locations(xdr, args->bitmask, &hdr);
2840 rpc_prepare_reply_pages(req, (struct page **)&args->page, 0,
2846 * Encode SECINFO request
2848 static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req,
2849 struct xdr_stream *xdr,
2852 const struct nfs4_secinfo_arg *args = data;
2853 struct compound_hdr hdr = {
2854 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2857 encode_compound_hdr(xdr, req, &hdr);
2858 encode_sequence(xdr, &args->seq_args, &hdr);
2859 encode_putfh(xdr, args->dir_fh, &hdr);
2860 encode_secinfo(xdr, args->name, &hdr);
2865 * Encode FSID_PRESENT request
2867 static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req,
2868 struct xdr_stream *xdr,
2871 const struct nfs4_fsid_present_arg *args = data;
2872 struct compound_hdr hdr = {
2873 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2876 encode_compound_hdr(xdr, req, &hdr);
2877 encode_sequence(xdr, &args->seq_args, &hdr);
2878 encode_putfh(xdr, args->fh, &hdr);
2879 encode_getfh(xdr, &hdr);
2881 encode_renew(xdr, args->clientid, &hdr);
2885 #if defined(CONFIG_NFS_V4_1)
2887 * BIND_CONN_TO_SESSION request
2889 static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
2890 struct xdr_stream *xdr,
2893 const struct nfs41_bind_conn_to_session_args *args = data;
2894 struct compound_hdr hdr = {
2895 .minorversion = args->client->cl_mvops->minor_version,
2898 encode_compound_hdr(xdr, req, &hdr);
2899 encode_bind_conn_to_session(xdr, args, &hdr);
2904 * EXCHANGE_ID request
2906 static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req,
2907 struct xdr_stream *xdr,
2910 const struct nfs41_exchange_id_args *args = data;
2911 struct compound_hdr hdr = {
2912 .minorversion = args->client->cl_mvops->minor_version,
2915 encode_compound_hdr(xdr, req, &hdr);
2916 encode_exchange_id(xdr, args, &hdr);
2921 * a CREATE_SESSION request
2923 static void nfs4_xdr_enc_create_session(struct rpc_rqst *req,
2924 struct xdr_stream *xdr,
2927 const struct nfs41_create_session_args *args = data;
2928 struct compound_hdr hdr = {
2929 .minorversion = args->client->cl_mvops->minor_version,
2932 encode_compound_hdr(xdr, req, &hdr);
2933 encode_create_session(xdr, args, &hdr);
2938 * a DESTROY_SESSION request
2940 static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req,
2941 struct xdr_stream *xdr,
2944 const struct nfs4_session *session = data;
2945 struct compound_hdr hdr = {
2946 .minorversion = session->clp->cl_mvops->minor_version,
2949 encode_compound_hdr(xdr, req, &hdr);
2950 encode_destroy_session(xdr, session, &hdr);
2955 * a DESTROY_CLIENTID request
2957 static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req,
2958 struct xdr_stream *xdr,
2961 const struct nfs_client *clp = data;
2962 struct compound_hdr hdr = {
2963 .minorversion = clp->cl_mvops->minor_version,
2966 encode_compound_hdr(xdr, req, &hdr);
2967 encode_destroy_clientid(xdr, clp->cl_clientid, &hdr);
2972 * a SEQUENCE request
2974 static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr,
2977 const struct nfs4_sequence_args *args = data;
2978 struct compound_hdr hdr = {
2979 .minorversion = nfs4_xdr_minorversion(args),
2982 encode_compound_hdr(xdr, req, &hdr);
2983 encode_sequence(xdr, args, &hdr);
2990 * a GET_LEASE_TIME request
2992 static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req,
2993 struct xdr_stream *xdr,
2996 const struct nfs4_get_lease_time_args *args = data;
2997 struct compound_hdr hdr = {
2998 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
3000 const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME };
3002 encode_compound_hdr(xdr, req, &hdr);
3003 encode_sequence(xdr, &args->la_seq_args, &hdr);
3004 encode_putrootfh(xdr, &hdr);
3005 encode_fsinfo(xdr, lease_bitmap, &hdr);
3009 #ifdef CONFIG_NFS_V4_1
3012 * a RECLAIM_COMPLETE request
3014 static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req,
3015 struct xdr_stream *xdr,
3018 const struct nfs41_reclaim_complete_args *args = data;
3019 struct compound_hdr hdr = {
3020 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
3023 encode_compound_hdr(xdr, req, &hdr);
3024 encode_sequence(xdr, &args->seq_args, &hdr);
3025 encode_reclaim_complete(xdr, args, &hdr);
3030 * Encode GETDEVICEINFO request
3032 static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req,
3033 struct xdr_stream *xdr,
3036 const struct nfs4_getdeviceinfo_args *args = data;
3037 struct compound_hdr hdr = {
3038 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3042 encode_compound_hdr(xdr, req, &hdr);
3043 encode_sequence(xdr, &args->seq_args, &hdr);
3045 replen = hdr.replen + op_decode_hdr_maxsz + 2;
3047 encode_getdeviceinfo(xdr, args, &hdr);
3049 /* set up reply kvec. device_addr4 opaque data is read into the
3051 rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase,
3052 args->pdev->pglen, replen);
3057 * Encode LAYOUTGET request
3059 static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req,
3060 struct xdr_stream *xdr,
3063 const struct nfs4_layoutget_args *args = data;
3064 struct compound_hdr hdr = {
3065 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3068 encode_compound_hdr(xdr, req, &hdr);
3069 encode_sequence(xdr, &args->seq_args, &hdr);
3070 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3071 encode_layoutget(xdr, args, &hdr);
3073 rpc_prepare_reply_pages(req, args->layout.pages, 0,
3074 args->layout.pglen, hdr.replen - pagepad_maxsz);
3079 * Encode LAYOUTCOMMIT request
3081 static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
3082 struct xdr_stream *xdr,
3085 const struct nfs4_layoutcommit_args *args = priv;
3086 struct nfs4_layoutcommit_data *data =
3087 container_of(args, struct nfs4_layoutcommit_data, args);
3088 struct compound_hdr hdr = {
3089 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3092 encode_compound_hdr(xdr, req, &hdr);
3093 encode_sequence(xdr, &args->seq_args, &hdr);
3094 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3095 encode_layoutcommit(xdr, data->args.inode, args, &hdr);
3096 encode_getfattr(xdr, args->bitmask, &hdr);
3101 * Encode LAYOUTRETURN request
3103 static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req,
3104 struct xdr_stream *xdr,
3107 const struct nfs4_layoutreturn_args *args = data;
3108 struct compound_hdr hdr = {
3109 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3112 encode_compound_hdr(xdr, req, &hdr);
3113 encode_sequence(xdr, &args->seq_args, &hdr);
3114 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
3115 encode_layoutreturn(xdr, args, &hdr);
3120 * Encode SECINFO_NO_NAME request
3122 static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req,
3123 struct xdr_stream *xdr,
3126 const struct nfs41_secinfo_no_name_args *args = data;
3127 struct compound_hdr hdr = {
3128 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3131 encode_compound_hdr(xdr, req, &hdr);
3132 encode_sequence(xdr, &args->seq_args, &hdr);
3133 encode_putrootfh(xdr, &hdr);
3134 encode_secinfo_no_name(xdr, args, &hdr);
3139 * Encode TEST_STATEID request
3141 static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req,
3142 struct xdr_stream *xdr,
3145 const struct nfs41_test_stateid_args *args = data;
3146 struct compound_hdr hdr = {
3147 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3150 encode_compound_hdr(xdr, req, &hdr);
3151 encode_sequence(xdr, &args->seq_args, &hdr);
3152 encode_test_stateid(xdr, args, &hdr);
3157 * Encode FREE_STATEID request
3159 static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req,
3160 struct xdr_stream *xdr,
3163 const struct nfs41_free_stateid_args *args = data;
3164 struct compound_hdr hdr = {
3165 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
3168 encode_compound_hdr(xdr, req, &hdr);
3169 encode_sequence(xdr, &args->seq_args, &hdr);
3170 encode_free_stateid(xdr, args, &hdr);
3173 #endif /* CONFIG_NFS_V4_1 */
3175 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
3177 ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
3179 if (unlikely(ret < 0))
3185 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
3191 if (xdr_stream_decode_u32(xdr, &tmp) < 0)
3195 ret = xdr_stream_decode_opaque_inline(xdr, &ptr, NFS4_OPAQUE_LIMIT);
3201 if (xdr_stream_decode_u32(xdr, &tmp) < 0)
3204 if (unlikely(hdr->nops < 1))
3205 return nfs4_stat_to_errno(hdr->status);
3209 static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
3216 p = xdr_inline_decode(xdr, 8);
3219 opnum = be32_to_cpup(p++);
3220 if (unlikely(opnum != expected))
3221 goto out_bad_operation;
3222 if (unlikely(*p != cpu_to_be32(NFS_OK)))
3227 nfserr = be32_to_cpup(p);
3228 trace_nfs4_xdr_status(xdr, opnum, nfserr);
3229 *nfs_retval = nfs4_stat_to_errno(nfserr);
3232 trace_nfs4_xdr_bad_operation(xdr, opnum, expected);
3233 *nfs_retval = -EREMOTEIO;
3240 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
3244 __decode_op_hdr(xdr, expected, &retval);
3249 static int decode_ace(struct xdr_stream *xdr, void *ace)
3252 unsigned int strlen;
3255 p = xdr_inline_decode(xdr, 12);
3258 return decode_opaque_inline(xdr, &strlen, &str);
3262 decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz)
3266 ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz);
3267 if (likely(ret >= 0))
3269 if (ret != -EMSGSIZE)
3274 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
3277 ret = decode_bitmap4(xdr, bitmap, 3);
3278 return ret < 0 ? ret : 0;
3281 static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep)
3285 p = xdr_inline_decode(xdr, 4);
3288 *attrlen = be32_to_cpup(p);
3289 *savep = xdr_stream_pos(xdr);
3293 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
3295 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
3297 ret = decode_attr_bitmap(xdr, bitmask);
3298 if (unlikely(ret < 0))
3300 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
3302 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3303 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3304 bitmask[0], bitmask[1], bitmask[2]);
3308 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
3314 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
3316 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
3317 p = xdr_inline_decode(xdr, 4);
3320 *type = be32_to_cpup(p);
3321 if (*type < NF4REG || *type > NF4NAMEDATTR) {
3322 dprintk("%s: bad type %d\n", __func__, *type);
3325 bitmap[0] &= ~FATTR4_WORD0_TYPE;
3326 ret = NFS_ATTR_FATTR_TYPE;
3328 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
3332 static int decode_attr_fh_expire_type(struct xdr_stream *xdr,
3333 uint32_t *bitmap, uint32_t *type)
3338 if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U)))
3340 if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) {
3341 p = xdr_inline_decode(xdr, 4);
3344 *type = be32_to_cpup(p);
3345 bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE;
3347 dprintk("%s: expire type=0x%x\n", __func__, *type);
3351 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
3357 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
3359 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
3360 p = xdr_inline_decode(xdr, 8);
3363 xdr_decode_hyper(p, change);
3364 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
3365 ret = NFS_ATTR_FATTR_CHANGE;
3367 dprintk("%s: change attribute=%Lu\n", __func__,
3368 (unsigned long long)*change);
3372 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
3378 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
3380 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
3381 p = xdr_inline_decode(xdr, 8);
3384 xdr_decode_hyper(p, size);
3385 bitmap[0] &= ~FATTR4_WORD0_SIZE;
3386 ret = NFS_ATTR_FATTR_SIZE;
3388 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
3392 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3397 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
3399 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
3400 p = xdr_inline_decode(xdr, 4);
3403 *res = be32_to_cpup(p);
3404 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
3406 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
3410 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3415 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
3417 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
3418 p = xdr_inline_decode(xdr, 4);
3421 *res = be32_to_cpup(p);
3422 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
3424 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
3428 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
3435 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
3437 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
3438 p = xdr_inline_decode(xdr, 16);
3441 p = xdr_decode_hyper(p, &fsid->major);
3442 xdr_decode_hyper(p, &fsid->minor);
3443 bitmap[0] &= ~FATTR4_WORD0_FSID;
3444 ret = NFS_ATTR_FATTR_FSID;
3446 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
3447 (unsigned long long)fsid->major,
3448 (unsigned long long)fsid->minor);
3452 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3457 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
3459 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
3460 p = xdr_inline_decode(xdr, 4);
3463 *res = be32_to_cpup(p);
3464 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
3466 dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res);
3470 static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
3474 if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U)))
3476 if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
3477 p = xdr_inline_decode(xdr, 4);
3480 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
3481 *res = -be32_to_cpup(p);
3486 static int decode_attr_exclcreat_supported(struct xdr_stream *xdr,
3487 uint32_t *bitmap, uint32_t *bitmask)
3489 if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) {
3491 ret = decode_attr_bitmap(xdr, bitmask);
3492 if (unlikely(ret < 0))
3494 bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT;
3496 bitmask[0] = bitmask[1] = bitmask[2] = 0;
3497 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
3498 bitmask[0], bitmask[1], bitmask[2]);
3502 static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
3508 memset(fh, 0, sizeof(*fh));
3510 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
3512 if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
3513 p = xdr_inline_decode(xdr, 4);
3516 len = be32_to_cpup(p);
3517 if (len > NFS4_FHSIZE || len == 0) {
3518 trace_nfs4_xdr_bad_filehandle(xdr, OP_READDIR,
3522 p = xdr_inline_decode(xdr, len);
3526 memcpy(fh->data, p, len);
3529 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
3534 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3539 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
3541 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
3542 p = xdr_inline_decode(xdr, 4);
3545 *res = be32_to_cpup(p);
3546 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
3548 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
3552 static int decode_attr_case_insensitive(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3557 if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_INSENSITIVE - 1U)))
3559 if (likely(bitmap[0] & FATTR4_WORD0_CASE_INSENSITIVE)) {
3560 p = xdr_inline_decode(xdr, 4);
3563 *res = be32_to_cpup(p);
3564 bitmap[0] &= ~FATTR4_WORD0_CASE_INSENSITIVE;
3566 dprintk("%s: case_insensitive=%s\n", __func__, *res == 0 ? "false" : "true");
3570 static int decode_attr_case_preserving(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3575 if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_PRESERVING - 1U)))
3577 if (likely(bitmap[0] & FATTR4_WORD0_CASE_PRESERVING)) {
3578 p = xdr_inline_decode(xdr, 4);
3581 *res = be32_to_cpup(p);
3582 bitmap[0] &= ~FATTR4_WORD0_CASE_PRESERVING;
3584 dprintk("%s: case_preserving=%s\n", __func__, *res == 0 ? "false" : "true");
3588 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3594 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
3596 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
3597 p = xdr_inline_decode(xdr, 8);
3600 xdr_decode_hyper(p, fileid);
3601 bitmap[0] &= ~FATTR4_WORD0_FILEID;
3602 ret = NFS_ATTR_FATTR_FILEID;
3604 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3608 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
3614 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
3616 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
3617 p = xdr_inline_decode(xdr, 8);
3620 xdr_decode_hyper(p, fileid);
3621 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
3622 ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
3624 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
3628 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3634 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
3636 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
3637 p = xdr_inline_decode(xdr, 8);
3640 xdr_decode_hyper(p, res);
3641 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
3643 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
3647 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3653 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
3655 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
3656 p = xdr_inline_decode(xdr, 8);
3659 xdr_decode_hyper(p, res);
3660 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
3662 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
3666 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3672 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
3674 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
3675 p = xdr_inline_decode(xdr, 8);
3678 xdr_decode_hyper(p, res);
3679 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
3681 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
3685 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3691 p = xdr_inline_decode(xdr, 4);
3694 n = be32_to_cpup(p);
3697 dprintk("pathname4: ");
3698 if (n > NFS4_PATHNAME_MAXCOMPONENTS) {
3699 dprintk("cannot parse %d components in path\n", n);
3702 for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) {
3703 struct nfs4_string *component = &path->components[path->ncomponents];
3704 status = decode_opaque_inline(xdr, &component->len, &component->data);
3705 if (unlikely(status != 0))
3709 (path->ncomponents != n ? "/ " : ""),
3710 component->len, component->data);
3715 /* a root pathname is sent as a zero component4 */
3716 path->ncomponents = 1;
3717 path->components[0].len=0;
3718 path->components[0].data=NULL;
3719 dprintk("pathname4: /\n");
3722 dprintk(" status %d", status);
3727 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
3733 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
3736 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
3738 bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS;
3740 /* Ignore borken servers that return unrequested attrs */
3741 if (unlikely(res == NULL))
3743 dprintk("%s: fsroot:\n", __func__);
3744 status = decode_pathname(xdr, &res->fs_path);
3745 if (unlikely(status != 0))
3747 p = xdr_inline_decode(xdr, 4);
3750 n = be32_to_cpup(p);
3751 for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
3753 struct nfs4_fs_location *loc;
3755 if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES)
3757 loc = &res->locations[res->nlocations];
3758 p = xdr_inline_decode(xdr, 4);
3761 m = be32_to_cpup(p);
3763 dprintk("%s: servers:\n", __func__);
3764 for (loc->nservers = 0; loc->nservers < m; loc->nservers++) {
3765 struct nfs4_string *server;
3767 if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) {
3769 dprintk("%s: using first %u of %u servers "
3770 "returned for location %u\n",
3772 NFS4_FS_LOCATION_MAXSERVERS,
3773 m, res->nlocations);
3774 for (i = loc->nservers; i < m; i++) {
3777 status = decode_opaque_inline(xdr, &len, &data);
3778 if (unlikely(status != 0))
3783 server = &loc->servers[loc->nservers];
3784 status = decode_opaque_inline(xdr, &server->len, &server->data);
3785 if (unlikely(status != 0))
3787 dprintk("%s ", server->data);
3789 status = decode_pathname(xdr, &loc->rootpath);
3790 if (unlikely(status != 0))
3793 if (res->nlocations != 0)
3794 status = NFS_ATTR_FATTR_V4_LOCATIONS;
3796 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
3803 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3809 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
3811 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
3812 p = xdr_inline_decode(xdr, 8);
3815 xdr_decode_hyper(p, res);
3816 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
3818 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
3822 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
3828 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
3830 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
3831 p = xdr_inline_decode(xdr, 4);
3834 *maxlink = be32_to_cpup(p);
3835 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
3837 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
3841 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
3847 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
3849 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
3850 p = xdr_inline_decode(xdr, 4);
3853 *maxname = be32_to_cpup(p);
3854 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
3856 dprintk("%s: maxname=%u\n", __func__, *maxname);
3860 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3866 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
3868 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
3870 p = xdr_inline_decode(xdr, 8);
3873 xdr_decode_hyper(p, &maxread);
3874 if (maxread > 0x7FFFFFFF)
3875 maxread = 0x7FFFFFFF;
3876 *res = (uint32_t)maxread;
3877 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
3879 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
3883 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3889 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
3891 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
3893 p = xdr_inline_decode(xdr, 8);
3896 xdr_decode_hyper(p, &maxwrite);
3897 if (maxwrite > 0x7FFFFFFF)
3898 maxwrite = 0x7FFFFFFF;
3899 *res = (uint32_t)maxwrite;
3900 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
3902 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
3906 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
3913 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
3915 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
3916 p = xdr_inline_decode(xdr, 4);
3919 tmp = be32_to_cpup(p);
3920 *mode = tmp & ~S_IFMT;
3921 bitmap[1] &= ~FATTR4_WORD1_MODE;
3922 ret = NFS_ATTR_FATTR_MODE;
3924 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
3928 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
3934 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
3936 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
3937 p = xdr_inline_decode(xdr, 4);
3940 *nlink = be32_to_cpup(p);
3941 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
3942 ret = NFS_ATTR_FATTR_NLINK;
3944 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
3948 static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
3949 struct nfs4_string *name, gfp_t gfp_flags)
3953 ret = xdr_stream_decode_string_dup(xdr, &name->data,
3954 XDR_MAX_NETOBJ, gfp_flags);
3961 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3962 const struct nfs_server *server, kuid_t *uid,
3963 struct nfs4_string *owner_name)
3968 *uid = make_kuid(&init_user_ns, -2);
3969 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3971 if (!(bitmap[1] & FATTR4_WORD1_OWNER))
3973 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3975 if (owner_name != NULL) {
3976 len = decode_nfs4_string(xdr, owner_name, GFP_NOIO);
3979 dprintk("%s: name=%s\n", __func__, owner_name->data);
3980 return NFS_ATTR_FATTR_OWNER_NAME;
3982 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
3984 if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0)
3986 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
3987 return NFS_ATTR_FATTR_OWNER;
3990 if (len == -EBADMSG)
3995 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3996 const struct nfs_server *server, kgid_t *gid,
3997 struct nfs4_string *group_name)
4002 *gid = make_kgid(&init_user_ns, -2);
4003 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
4005 if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP))
4007 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
4009 if (group_name != NULL) {
4010 len = decode_nfs4_string(xdr, group_name, GFP_NOIO);
4013 dprintk("%s: name=%s\n", __func__, group_name->data);
4014 return NFS_ATTR_FATTR_GROUP_NAME;
4016 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
4018 if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0)
4020 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
4021 return NFS_ATTR_FATTR_GROUP;
4024 if (len == -EBADMSG)
4029 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
4031 uint32_t major = 0, minor = 0;
4036 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
4038 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
4041 p = xdr_inline_decode(xdr, 8);
4044 major = be32_to_cpup(p++);
4045 minor = be32_to_cpup(p);
4046 tmp = MKDEV(major, minor);
4047 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
4049 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
4050 ret = NFS_ATTR_FATTR_RDEV;
4052 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
4056 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4062 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
4064 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
4065 p = xdr_inline_decode(xdr, 8);
4068 xdr_decode_hyper(p, res);
4069 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
4071 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
4075 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4081 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
4083 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
4084 p = xdr_inline_decode(xdr, 8);
4087 xdr_decode_hyper(p, res);
4088 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
4090 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
4094 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
4100 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
4102 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
4103 p = xdr_inline_decode(xdr, 8);
4106 xdr_decode_hyper(p, res);
4107 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
4109 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
4113 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
4119 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
4121 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
4122 p = xdr_inline_decode(xdr, 8);
4125 xdr_decode_hyper(p, used);
4126 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
4127 ret = NFS_ATTR_FATTR_SPACE_USED;
4129 dprintk("%s: space used=%Lu\n", __func__,
4130 (unsigned long long)*used);
4135 xdr_decode_nfstime4(__be32 *p, struct timespec64 *t)
4139 p = xdr_decode_hyper(p, &sec);
4141 t->tv_nsec = be32_to_cpup(p++);
4145 static int decode_attr_time(struct xdr_stream *xdr, struct timespec64 *time)
4149 p = xdr_inline_decode(xdr, nfstime4_maxsz << 2);
4152 xdr_decode_nfstime4(p, time);
4156 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
4162 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
4164 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
4165 status = decode_attr_time(xdr, time);
4167 status = NFS_ATTR_FATTR_ATIME;
4168 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
4170 dprintk("%s: atime=%lld\n", __func__, time->tv_sec);
4174 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
4180 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
4182 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
4183 status = decode_attr_time(xdr, time);
4185 status = NFS_ATTR_FATTR_CTIME;
4186 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
4188 dprintk("%s: ctime=%lld\n", __func__, time->tv_sec);
4192 static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
4193 struct timespec64 *time)
4199 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U)))
4201 if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) {
4202 status = decode_attr_time(xdr, time);
4203 bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
4205 dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec,
4210 static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
4211 struct nfs4_label *label)
4219 if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
4221 if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
4222 p = xdr_inline_decode(xdr, 4);
4225 lfs = be32_to_cpup(p++);
4226 p = xdr_inline_decode(xdr, 4);
4229 pi = be32_to_cpup(p++);
4230 p = xdr_inline_decode(xdr, 4);
4233 len = be32_to_cpup(p++);
4234 p = xdr_inline_decode(xdr, len);
4237 if (len < NFS4_MAXLABELLEN) {
4240 if (label->len < len)
4242 memcpy(label->label, p, len);
4247 status = NFS_ATTR_FATTR_V4_SECURITY_LABEL;
4249 bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
4251 printk(KERN_WARNING "%s: label too long (%u)!\n",
4253 if (label && label->label)
4254 dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n",
4255 __func__, label->len, (char *)label->label,
4256 label->len, label->pi, label->lfs);
4261 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
4267 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
4269 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
4270 status = decode_attr_time(xdr, time);
4272 status = NFS_ATTR_FATTR_MTIME;
4273 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
4275 dprintk("%s: mtime=%lld\n", __func__, time->tv_sec);
4279 static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,
4285 if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U)))
4287 if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) {
4288 p = xdr_inline_decode(xdr, 4);
4291 *res = be32_to_cpup(p);
4292 bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT;
4294 dprintk("%s: XATTR support=%s\n", __func__,
4295 *res == 0 ? "false" : "true");
4299 static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
4301 unsigned int attrwords = XDR_QUADLEN(attrlen);
4302 unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2;
4304 if (unlikely(attrwords != nwords)) {
4305 dprintk("%s: server returned incorrect attribute length: "
4309 (attrwords < nwords) ? '<' : '>',
4316 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4320 p = xdr_inline_decode(xdr, 20);
4323 cinfo->atomic = be32_to_cpup(p++);
4324 p = xdr_decode_hyper(p, &cinfo->before);
4325 xdr_decode_hyper(p, &cinfo->after);
4329 static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
4335 status = decode_op_hdr(xdr, OP_ACCESS);
4338 p = xdr_inline_decode(xdr, 8);
4341 supp = be32_to_cpup(p++);
4342 acc = be32_to_cpup(p);
4348 static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
4350 ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
4351 if (unlikely(ret < 0))
4356 static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4358 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4361 static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4363 stateid->type = NFS4_OPEN_STATEID_TYPE;
4364 return decode_stateid(xdr, stateid);
4367 static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4369 stateid->type = NFS4_LOCK_STATEID_TYPE;
4370 return decode_stateid(xdr, stateid);
4373 static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4375 stateid->type = NFS4_DELEGATION_STATEID_TYPE;
4376 return decode_stateid(xdr, stateid);
4379 static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4383 nfs4_stateid_copy(stateid, &invalid_stateid);
4384 return decode_stateid(xdr, &dummy);
4387 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4391 status = decode_op_hdr(xdr, OP_CLOSE);
4393 nfs_increment_open_seqid(status, res->seqid);
4395 status = decode_invalid_stateid(xdr, &res->stateid);
4399 static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4401 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4404 static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
4406 return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
4409 static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
4411 struct nfs_writeverf *verf = res->verf;
4414 status = decode_op_hdr(xdr, OP_COMMIT);
4416 status = decode_write_verifier(xdr, &verf->verifier);
4418 verf->committed = NFS_FILE_SYNC;
4422 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4428 status = decode_op_hdr(xdr, OP_CREATE);
4431 if ((status = decode_change_info(xdr, cinfo)))
4433 p = xdr_inline_decode(xdr, 4);
4436 bmlen = be32_to_cpup(p);
4437 p = xdr_inline_decode(xdr, bmlen << 2);
4443 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
4446 uint32_t attrlen, bitmap[3] = {0};
4449 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4451 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4453 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4455 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
4457 if ((status = decode_attr_fh_expire_type(xdr, bitmap,
4458 &res->fh_expire_type)) != 0)
4460 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
4462 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
4464 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
4466 if ((status = decode_attr_case_insensitive(xdr, bitmap, &res->case_insensitive)) != 0)
4468 if ((status = decode_attr_case_preserving(xdr, bitmap, &res->case_preserving)) != 0)
4470 if ((status = decode_attr_exclcreat_supported(xdr, bitmap,
4471 res->exclcreat_bitmask)) != 0)
4473 status = verify_attr_len(xdr, savep, attrlen);
4475 dprintk("%s: xdr returned %d!\n", __func__, -status);
4479 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
4482 uint32_t attrlen, bitmap[3] = {0};
4485 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4487 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4489 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4492 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
4494 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
4496 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
4500 if (unlikely(bitmap[0]))
4503 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
4505 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
4507 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
4510 status = verify_attr_len(xdr, savep, attrlen);
4512 dprintk("%s: xdr returned %d!\n", __func__, -status);
4516 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
4519 uint32_t attrlen, bitmap[3] = {0};
4522 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4524 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4526 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4529 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
4531 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
4534 status = verify_attr_len(xdr, savep, attrlen);
4536 dprintk("%s: xdr returned %d!\n", __func__, -status);
4540 static int decode_threshold_hint(struct xdr_stream *xdr,
4548 if (likely(bitmap[0] & hint_bit)) {
4549 p = xdr_inline_decode(xdr, 8);
4552 xdr_decode_hyper(p, res);
4557 static int decode_first_threshold_item4(struct xdr_stream *xdr,
4558 struct nfs4_threshold *res)
4562 uint32_t bitmap[3] = {0,}, attrlen;
4566 p = xdr_inline_decode(xdr, 4);
4569 res->l_type = be32_to_cpup(p);
4571 /* thi_hintset bitmap */
4572 status = decode_attr_bitmap(xdr, bitmap);
4576 /* thi_hintlist length */
4577 status = decode_attr_length(xdr, &attrlen, &savep);
4581 status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD);
4584 status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR);
4587 status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz,
4591 status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz,
4596 status = verify_attr_len(xdr, savep, attrlen);
4597 res->bm = bitmap[0];
4599 dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n",
4600 __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz,
4603 dprintk("%s ret=%d!\n", __func__, status);
4608 * Thresholds on pNFS direct I/O vrs MDS I/O
4610 static int decode_attr_mdsthreshold(struct xdr_stream *xdr,
4612 struct nfs4_threshold *res)
4618 if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U)))
4620 if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) {
4621 /* Did the server return an unrequested attribute? */
4622 if (unlikely(res == NULL))
4624 p = xdr_inline_decode(xdr, 4);
4627 num = be32_to_cpup(p);
4631 printk(KERN_INFO "%s: Warning: Multiple pNFS layout "
4632 "drivers per filesystem not supported\n",
4635 status = decode_first_threshold_item4(xdr, res);
4636 bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
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, const struct nfs_server *server)
4650 status = decode_attr_type(xdr, bitmap, &type);
4655 fattr->mode |= nfs_type2fmt[type];
4656 fattr->valid |= status;
4659 status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
4662 fattr->valid |= status;
4664 status = decode_attr_size(xdr, bitmap, &fattr->size);
4667 fattr->valid |= status;
4669 status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
4672 fattr->valid |= status;
4675 status = decode_attr_error(xdr, bitmap, &err);
4679 status = decode_attr_filehandle(xdr, bitmap, fh);
4683 status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
4686 fattr->valid |= status;
4688 status = decode_attr_fs_locations(xdr, bitmap, fs_loc);
4691 fattr->valid |= status;
4694 if (unlikely(bitmap[0]))
4697 status = decode_attr_mode(xdr, bitmap, &fmode);
4701 fattr->mode |= fmode;
4702 fattr->valid |= status;
4705 status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
4708 fattr->valid |= status;
4710 status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name);
4713 fattr->valid |= status;
4715 status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name);
4718 fattr->valid |= status;
4720 status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
4723 fattr->valid |= status;
4725 status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
4728 fattr->valid |= status;
4730 status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
4733 fattr->valid |= status;
4735 status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
4738 fattr->valid |= status;
4740 status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
4743 fattr->valid |= status;
4745 status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid);
4748 fattr->valid |= status;
4751 if (unlikely(bitmap[1]))
4754 status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold);
4759 status = decode_attr_security_label(xdr, bitmap, fattr->label);
4762 fattr->valid |= status;
4766 dprintk("%s: xdr returned %d\n", __func__, -status);
4770 static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4771 struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc,
4772 const struct nfs_server *server)
4779 status = decode_op_hdr(xdr, OP_GETATTR);
4783 status = decode_attr_bitmap(xdr, bitmap);
4787 status = decode_attr_length(xdr, &attrlen, &savep);
4791 status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server);
4795 status = verify_attr_len(xdr, savep, attrlen);
4797 dprintk("%s: xdr returned %d\n", __func__, -status);
4801 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
4802 const struct nfs_server *server)
4804 return decode_getfattr_generic(xdr, fattr, NULL, NULL, server);
4808 * Decode potentially multiple layout types.
4810 static int decode_pnfs_layout_types(struct xdr_stream *xdr,
4811 struct nfs_fsinfo *fsinfo)
4816 p = xdr_inline_decode(xdr, 4);
4819 fsinfo->nlayouttypes = be32_to_cpup(p);
4821 /* pNFS is not supported by the underlying file system */
4822 if (fsinfo->nlayouttypes == 0)
4825 /* Decode and set first layout type, move xdr->p past unused types */
4826 p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
4830 /* If we get too many, then just cap it at the max */
4831 if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
4832 printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n",
4833 __func__, fsinfo->nlayouttypes);
4834 fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES;
4837 for(i = 0; i < fsinfo->nlayouttypes; ++i)
4838 fsinfo->layouttype[i] = be32_to_cpup(p++);
4843 * The type of file system exported.
4844 * Note we must ensure that layouttype is set in any non-error case.
4846 static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
4847 struct nfs_fsinfo *fsinfo)
4851 dprintk("%s: bitmap is %x\n", __func__, bitmap[1]);
4852 if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U)))
4854 if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) {
4855 status = decode_pnfs_layout_types(xdr, fsinfo);
4856 bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES;
4862 * The prefered block size for layout directed io
4864 static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4869 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4871 if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) {
4872 p = xdr_inline_decode(xdr, 4);
4875 *res = be32_to_cpup(p);
4876 bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE;
4882 * The granularity of a CLONE operation.
4884 static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4889 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4891 if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
4892 p = xdr_inline_decode(xdr, 4);
4895 *res = be32_to_cpup(p);
4896 bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE;
4901 static int decode_attr_change_attr_type(struct xdr_stream *xdr,
4903 enum nfs4_change_attr_type *res)
4905 u32 tmp = NFS4_CHANGE_TYPE_IS_UNDEFINED;
4907 dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
4908 if (bitmap[2] & FATTR4_WORD2_CHANGE_ATTR_TYPE) {
4909 if (xdr_stream_decode_u32(xdr, &tmp))
4911 bitmap[2] &= ~FATTR4_WORD2_CHANGE_ATTR_TYPE;
4915 case NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR:
4916 case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER:
4917 case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS:
4918 case NFS4_CHANGE_TYPE_IS_TIME_METADATA:
4922 *res = NFS4_CHANGE_TYPE_IS_UNDEFINED;
4927 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
4930 uint32_t attrlen, bitmap[3];
4933 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4935 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4937 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4940 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
4942 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
4944 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
4946 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
4948 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
4949 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
4951 fsinfo->wtpref = fsinfo->wtmax;
4954 if (unlikely(bitmap[0]))
4957 status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta);
4960 status = decode_attr_pnfstype(xdr, bitmap, fsinfo);
4965 if (unlikely(bitmap[1]))
4968 status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize);
4971 status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize);
4975 status = decode_attr_change_attr_type(xdr, bitmap,
4976 &fsinfo->change_attr_type);
4980 status = decode_attr_xattrsupport(xdr, bitmap,
4981 &fsinfo->xattr_support);
4985 status = verify_attr_len(xdr, savep, attrlen);
4987 dprintk("%s: xdr returned %d!\n", __func__, -status);
4991 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
4997 /* Zero handle first to allow comparisons */
4998 memset(fh, 0, sizeof(*fh));
5000 status = decode_op_hdr(xdr, OP_GETFH);
5004 p = xdr_inline_decode(xdr, 4);
5007 len = be32_to_cpup(p);
5008 if (len > NFS4_FHSIZE || len == 0) {
5009 trace_nfs4_xdr_bad_filehandle(xdr, OP_GETFH, NFS4ERR_BADHANDLE);
5013 p = xdr_inline_decode(xdr, len);
5016 memcpy(fh->data, p, len);
5020 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5024 status = decode_op_hdr(xdr, OP_LINK);
5027 return decode_change_info(xdr, cinfo);
5031 * We create the owner, so we know a proper owner.id length is 4.
5033 static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
5035 uint64_t offset, length, clientid;
5037 uint32_t namelen, type;
5039 p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
5042 p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
5043 p = xdr_decode_hyper(p, &length);
5044 type = be32_to_cpup(p++); /* 4 byte read */
5045 if (fl != NULL) { /* manipulate file lock */
5046 fl->fl_start = (loff_t)offset;
5047 fl->fl_end = fl->fl_start + (loff_t)length - 1;
5048 if (length == ~(uint64_t)0)
5049 fl->fl_end = OFFSET_MAX;
5050 fl->fl_type = F_WRLCK;
5052 fl->fl_type = F_RDLCK;
5055 p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
5056 namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */
5057 p = xdr_inline_decode(xdr, namelen); /* variable size field */
5060 return -NFS4ERR_DENIED;
5063 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
5067 status = decode_op_hdr(xdr, OP_LOCK);
5071 status = decode_lock_stateid(xdr, &res->stateid);
5072 if (unlikely(status))
5074 } else if (status == -NFS4ERR_DENIED)
5075 status = decode_lock_denied(xdr, NULL);
5076 if (res->open_seqid != NULL)
5077 nfs_increment_open_seqid(status, res->open_seqid);
5078 nfs_increment_lock_seqid(status, res->lock_seqid);
5083 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
5086 status = decode_op_hdr(xdr, OP_LOCKT);
5087 if (status == -NFS4ERR_DENIED)
5088 return decode_lock_denied(xdr, res->denied);
5092 static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
5096 status = decode_op_hdr(xdr, OP_LOCKU);
5098 nfs_increment_lock_seqid(status, res->seqid);
5100 status = decode_lock_stateid(xdr, &res->stateid);
5104 static int decode_release_lockowner(struct xdr_stream *xdr)
5106 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
5109 static int decode_lookup(struct xdr_stream *xdr)
5111 return decode_op_hdr(xdr, OP_LOOKUP);
5114 static int decode_lookupp(struct xdr_stream *xdr)
5116 return decode_op_hdr(xdr, OP_LOOKUPP);
5119 /* This is too sick! */
5120 static int decode_space_limit(struct xdr_stream *xdr,
5121 unsigned long *pagemod_limit)
5124 uint32_t limit_type, nblocks, blocksize;
5127 p = xdr_inline_decode(xdr, 12);
5130 limit_type = be32_to_cpup(p++);
5131 switch (limit_type) {
5132 case NFS4_LIMIT_SIZE:
5133 xdr_decode_hyper(p, &maxsize);
5135 case NFS4_LIMIT_BLOCKS:
5136 nblocks = be32_to_cpup(p++);
5137 blocksize = be32_to_cpup(p);
5138 maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
5140 maxsize >>= PAGE_SHIFT;
5141 *pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
5145 static int decode_rw_delegation(struct xdr_stream *xdr,
5146 uint32_t delegation_type,
5147 struct nfs_openres *res)
5152 status = decode_delegation_stateid(xdr, &res->delegation);
5153 if (unlikely(status))
5155 p = xdr_inline_decode(xdr, 4);
5158 res->do_recall = be32_to_cpup(p);
5160 switch (delegation_type) {
5161 case NFS4_OPEN_DELEGATE_READ:
5162 res->delegation_type = FMODE_READ;
5164 case NFS4_OPEN_DELEGATE_WRITE:
5165 res->delegation_type = FMODE_WRITE|FMODE_READ;
5166 if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
5169 return decode_ace(xdr, NULL);
5172 static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5175 uint32_t why_no_delegation;
5177 p = xdr_inline_decode(xdr, 4);
5180 why_no_delegation = be32_to_cpup(p);
5181 switch (why_no_delegation) {
5182 case WND4_CONTENTION:
5184 xdr_inline_decode(xdr, 4);
5185 /* Ignore for now */
5190 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
5193 uint32_t delegation_type;
5195 p = xdr_inline_decode(xdr, 4);
5198 delegation_type = be32_to_cpup(p);
5199 res->delegation_type = 0;
5200 switch (delegation_type) {
5201 case NFS4_OPEN_DELEGATE_NONE:
5203 case NFS4_OPEN_DELEGATE_READ:
5204 case NFS4_OPEN_DELEGATE_WRITE:
5205 return decode_rw_delegation(xdr, delegation_type, res);
5206 case NFS4_OPEN_DELEGATE_NONE_EXT:
5207 return decode_no_delegation(xdr, res);
5212 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
5215 uint32_t savewords, bmlen, i;
5218 if (!__decode_op_hdr(xdr, OP_OPEN, &status))
5220 nfs_increment_open_seqid(status, res->seqid);
5223 status = decode_open_stateid(xdr, &res->stateid);
5224 if (unlikely(status))
5227 decode_change_info(xdr, &res->cinfo);
5229 p = xdr_inline_decode(xdr, 8);
5232 res->rflags = be32_to_cpup(p++);
5233 bmlen = be32_to_cpup(p);
5237 p = xdr_inline_decode(xdr, bmlen << 2);
5240 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
5241 for (i = 0; i < savewords; ++i)
5242 res->attrset[i] = be32_to_cpup(p++);
5243 for (; i < NFS4_BITMAP_SIZE; i++)
5244 res->attrset[i] = 0;
5246 return decode_delegation(xdr, res);
5248 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
5252 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
5256 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
5258 nfs_increment_open_seqid(status, res->seqid);
5260 status = decode_open_stateid(xdr, &res->stateid);
5264 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
5268 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
5270 nfs_increment_open_seqid(status, res->seqid);
5272 status = decode_open_stateid(xdr, &res->stateid);
5276 static int decode_putfh(struct xdr_stream *xdr)
5278 return decode_op_hdr(xdr, OP_PUTFH);
5281 static int decode_putrootfh(struct xdr_stream *xdr)
5283 return decode_op_hdr(xdr, OP_PUTROOTFH);
5286 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req,
5287 struct nfs_pgio_res *res)
5290 uint32_t count, eof, recvd;
5293 status = decode_op_hdr(xdr, OP_READ);
5296 p = xdr_inline_decode(xdr, 8);
5299 eof = be32_to_cpup(p++);
5300 count = be32_to_cpup(p);
5301 recvd = xdr_read_pages(xdr, count);
5302 if (count > recvd) {
5303 dprintk("NFS: server cheating in read reply: "
5304 "count %u > recvd %u\n", count, recvd);
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 null-terminate the text (the VFS expects
5360 * null-termination).
5362 xdr_terminate_string(rcvbuf, len);
5366 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
5370 status = decode_op_hdr(xdr, OP_REMOVE);
5373 status = decode_change_info(xdr, cinfo);
5378 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
5379 struct nfs4_change_info *new_cinfo)
5383 status = decode_op_hdr(xdr, OP_RENAME);
5386 if ((status = decode_change_info(xdr, old_cinfo)))
5388 status = decode_change_info(xdr, new_cinfo);
5393 static int decode_renew(struct xdr_stream *xdr)
5395 return decode_op_hdr(xdr, OP_RENEW);
5399 decode_restorefh(struct xdr_stream *xdr)
5401 return decode_op_hdr(xdr, OP_RESTOREFH);
5404 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
5405 struct nfs_getaclres *res, enum nfs4_acl_type type)
5413 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
5416 xdr_enter_page(xdr, xdr->buf->page_len);
5418 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
5420 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
5425 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
5427 if (!(bitmap[0] & FATTR4_WORD0_ACL))
5431 if (unlikely(bitmap[0] || bitmap[1] & (FATTR4_WORD1_DACL - 1U)))
5433 if (!(bitmap[1] & FATTR4_WORD1_DACL))
5437 if (unlikely(bitmap[0] || bitmap[1] & (FATTR4_WORD1_SACL - 1U)))
5439 if (!(bitmap[1] & FATTR4_WORD1_SACL))
5443 /* The bitmap (xdr len + bitmaps) and the attr xdr len words
5444 * are stored with the acl data to handle the problem of
5445 * variable length bitmaps.*/
5446 res->acl_data_offset = xdr_page_pos(xdr);
5447 res->acl_len = attrlen;
5449 /* Check for receive buffer overflow */
5450 if (res->acl_len > xdr_stream_remaining(xdr) ||
5451 res->acl_len + res->acl_data_offset > xdr->buf->page_len) {
5452 res->acl_flags |= NFS4_ACL_TRUNC;
5453 dprintk("NFS: acl reply: attrlen %u > page_len %zu\n",
5454 attrlen, xdr_stream_remaining(xdr));
5461 decode_savefh(struct xdr_stream *xdr)
5463 return decode_op_hdr(xdr, OP_SAVEFH);
5466 static int decode_setattr(struct xdr_stream *xdr)
5470 status = decode_op_hdr(xdr, OP_SETATTR);
5473 if (decode_bitmap4(xdr, NULL, 0) >= 0)
5478 static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
5484 p = xdr_inline_decode(xdr, 8);
5487 opnum = be32_to_cpup(p++);
5488 if (opnum != OP_SETCLIENTID) {
5489 dprintk("nfs: decode_setclientid: Server returned operation"
5493 nfserr = be32_to_cpup(p);
5494 if (nfserr == NFS_OK) {
5495 p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
5498 p = xdr_decode_hyper(p, &res->clientid);
5499 memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
5500 } else if (nfserr == NFSERR_CLID_INUSE) {
5503 /* skip netid string */
5504 p = xdr_inline_decode(xdr, 4);
5507 len = be32_to_cpup(p);
5508 p = xdr_inline_decode(xdr, len);
5512 /* skip uaddr string */
5513 p = xdr_inline_decode(xdr, 4);
5516 len = be32_to_cpup(p);
5517 p = xdr_inline_decode(xdr, len);
5520 return -NFSERR_CLID_INUSE;
5522 return nfs4_stat_to_errno(nfserr);
5527 static int decode_setclientid_confirm(struct xdr_stream *xdr)
5529 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
5532 static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res)
5537 status = decode_op_hdr(xdr, OP_WRITE);
5541 p = xdr_inline_decode(xdr, 8);
5544 res->count = be32_to_cpup(p++);
5545 res->verf->committed = be32_to_cpup(p++);
5546 return decode_write_verifier(xdr, &res->verf->verifier);
5549 static int decode_delegreturn(struct xdr_stream *xdr)
5551 return decode_op_hdr(xdr, OP_DELEGRETURN);
5554 static int decode_secinfo_gss(struct xdr_stream *xdr,
5555 struct nfs4_secinfo4 *flavor)
5560 p = xdr_inline_decode(xdr, 4);
5563 oid_len = be32_to_cpup(p);
5564 if (oid_len > GSS_OID_MAX_LEN)
5567 p = xdr_inline_decode(xdr, oid_len);
5570 memcpy(flavor->flavor_info.oid.data, p, oid_len);
5571 flavor->flavor_info.oid.len = oid_len;
5573 p = xdr_inline_decode(xdr, 8);
5576 flavor->flavor_info.qop = be32_to_cpup(p++);
5577 flavor->flavor_info.service = be32_to_cpup(p);
5582 static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5584 struct nfs4_secinfo4 *sec_flavor;
5585 unsigned int i, num_flavors;
5589 p = xdr_inline_decode(xdr, 4);
5593 res->flavors->num_flavors = 0;
5594 num_flavors = be32_to_cpup(p);
5596 for (i = 0; i < num_flavors; i++) {
5597 sec_flavor = &res->flavors->flavors[i];
5598 if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE)
5601 p = xdr_inline_decode(xdr, 4);
5604 sec_flavor->flavor = be32_to_cpup(p);
5606 if (sec_flavor->flavor == RPC_AUTH_GSS) {
5607 status = decode_secinfo_gss(xdr, sec_flavor);
5611 res->flavors->num_flavors++;
5619 static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5621 int status = decode_op_hdr(xdr, OP_SECINFO);
5624 return decode_secinfo_common(xdr, res);
5627 #if defined(CONFIG_NFS_V4_1)
5628 static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
5630 int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME);
5633 return decode_secinfo_common(xdr, res);
5636 static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map)
5638 if (xdr_stream_decode_uint32_array(xdr, op_map->u.words,
5639 ARRAY_SIZE(op_map->u.words)) < 0)
5644 static int decode_exchange_id(struct xdr_stream *xdr,
5645 struct nfs41_exchange_id_res *res)
5651 uint32_t impl_id_count;
5653 status = decode_op_hdr(xdr, OP_EXCHANGE_ID);
5657 p = xdr_inline_decode(xdr, 8);
5660 xdr_decode_hyper(p, &res->clientid);
5661 p = xdr_inline_decode(xdr, 12);
5664 res->seqid = be32_to_cpup(p++);
5665 res->flags = be32_to_cpup(p++);
5667 res->state_protect.how = be32_to_cpup(p);
5668 switch (res->state_protect.how) {
5672 status = decode_op_map(xdr, &res->state_protect.enforce);
5675 status = decode_op_map(xdr, &res->state_protect.allow);
5684 /* server_owner4.so_minor_id */
5685 p = xdr_inline_decode(xdr, 8);
5688 p = xdr_decode_hyper(p, &res->server_owner->minor_id);
5690 /* server_owner4.so_major_id */
5691 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5692 if (unlikely(status))
5694 memcpy(res->server_owner->major_id, dummy_str, dummy);
5695 res->server_owner->major_id_sz = dummy;
5698 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5699 if (unlikely(status))
5701 memcpy(res->server_scope->server_scope, dummy_str, dummy);
5702 res->server_scope->server_scope_sz = dummy;
5704 /* Implementation Id */
5705 p = xdr_inline_decode(xdr, 4);
5708 impl_id_count = be32_to_cpup(p++);
5710 if (impl_id_count) {
5712 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5713 if (unlikely(status))
5715 memcpy(res->impl_id->domain, dummy_str, dummy);
5718 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5719 if (unlikely(status))
5721 memcpy(res->impl_id->name, dummy_str, dummy);
5724 p = xdr_inline_decode(xdr, 12);
5727 p = xdr_decode_hyper(p, &res->impl_id->date.seconds);
5728 res->impl_id->date.nseconds = be32_to_cpup(p);
5730 /* if there's more than one entry, ignore the rest */
5735 static int decode_chan_attrs(struct xdr_stream *xdr,
5736 struct nfs4_channel_attrs *attrs)
5741 p = xdr_inline_decode(xdr, 28);
5744 val = be32_to_cpup(p++); /* headerpadsz */
5746 return -EINVAL; /* no support for header padding yet */
5747 attrs->max_rqst_sz = be32_to_cpup(p++);
5748 attrs->max_resp_sz = be32_to_cpup(p++);
5749 attrs->max_resp_sz_cached = be32_to_cpup(p++);
5750 attrs->max_ops = be32_to_cpup(p++);
5751 attrs->max_reqs = be32_to_cpup(p++);
5752 nr_attrs = be32_to_cpup(p);
5753 if (unlikely(nr_attrs > 1)) {
5754 printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs "
5755 "count %u\n", __func__, nr_attrs);
5758 if (nr_attrs == 1) {
5759 p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
5766 static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
5768 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
5771 static int decode_bind_conn_to_session(struct xdr_stream *xdr,
5772 struct nfs41_bind_conn_to_session_res *res)
5777 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
5779 status = decode_sessionid(xdr, &res->sessionid);
5780 if (unlikely(status))
5783 /* dir flags, rdma mode bool */
5784 p = xdr_inline_decode(xdr, 8);
5788 res->dir = be32_to_cpup(p++);
5789 if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
5791 if (be32_to_cpup(p) == 0)
5792 res->use_conn_in_rdma_mode = false;
5794 res->use_conn_in_rdma_mode = true;
5799 static int decode_create_session(struct xdr_stream *xdr,
5800 struct nfs41_create_session_res *res)
5805 status = decode_op_hdr(xdr, OP_CREATE_SESSION);
5807 status = decode_sessionid(xdr, &res->sessionid);
5808 if (unlikely(status))
5812 p = xdr_inline_decode(xdr, 8);
5815 res->seqid = be32_to_cpup(p++);
5816 res->flags = be32_to_cpup(p);
5818 /* Channel attributes */
5819 status = decode_chan_attrs(xdr, &res->fc_attrs);
5821 status = decode_chan_attrs(xdr, &res->bc_attrs);
5825 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
5827 return decode_op_hdr(xdr, OP_DESTROY_SESSION);
5830 static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy)
5832 return decode_op_hdr(xdr, OP_DESTROY_CLIENTID);
5835 static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
5837 return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
5839 #endif /* CONFIG_NFS_V4_1 */
5841 static int decode_sequence(struct xdr_stream *xdr,
5842 struct nfs4_sequence_res *res,
5843 struct rpc_rqst *rqstp)
5845 #if defined(CONFIG_NFS_V4_1)
5846 struct nfs4_session *session;
5847 struct nfs4_sessionid id;
5852 if (res->sr_slot == NULL)
5854 if (!res->sr_slot->table->session)
5857 status = decode_op_hdr(xdr, OP_SEQUENCE);
5859 status = decode_sessionid(xdr, &id);
5860 if (unlikely(status))
5864 * If the server returns different values for sessionID, slotID or
5865 * sequence number, the server is looney tunes.
5867 status = -EREMOTEIO;
5868 session = res->sr_slot->table->session;
5870 if (memcmp(id.data, session->sess_id.data,
5871 NFS4_MAX_SESSIONID_LEN)) {
5872 dprintk("%s Invalid session id\n", __func__);
5876 p = xdr_inline_decode(xdr, 20);
5881 dummy = be32_to_cpup(p++);
5882 if (dummy != res->sr_slot->seq_nr) {
5883 dprintk("%s Invalid sequence number\n", __func__);
5887 dummy = be32_to_cpup(p++);
5888 if (dummy != res->sr_slot->slot_nr) {
5889 dprintk("%s Invalid slot id\n", __func__);
5892 /* highest slot id */
5893 res->sr_highest_slotid = be32_to_cpup(p++);
5894 /* target highest slot id */
5895 res->sr_target_highest_slotid = be32_to_cpup(p++);
5897 res->sr_status_flags = be32_to_cpup(p);
5900 res->sr_status = status;
5905 #else /* CONFIG_NFS_V4_1 */
5907 #endif /* CONFIG_NFS_V4_1 */
5910 #if defined(CONFIG_NFS_V4_1)
5911 static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
5913 stateid->type = NFS4_LAYOUT_STATEID_TYPE;
5914 return decode_stateid(xdr, stateid);
5917 static int decode_getdeviceinfo(struct xdr_stream *xdr,
5918 struct nfs4_getdeviceinfo_res *res)
5920 struct pnfs_device *pdev = res->pdev;
5925 status = decode_op_hdr(xdr, OP_GETDEVICEINFO);
5927 if (status == -ETOOSMALL) {
5928 p = xdr_inline_decode(xdr, 4);
5931 pdev->mincount = be32_to_cpup(p);
5932 dprintk("%s: Min count too small. mincnt = %u\n",
5933 __func__, pdev->mincount);
5938 p = xdr_inline_decode(xdr, 8);
5941 type = be32_to_cpup(p++);
5942 if (type != pdev->layout_type) {
5943 dprintk("%s: layout mismatch req: %u pdev: %u\n",
5944 __func__, pdev->layout_type, type);
5948 * Get the length of the opaque device_addr4. xdr_read_pages places
5949 * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages)
5950 * and places the remaining xdr data in xdr_buf->tail
5952 pdev->mincount = be32_to_cpup(p);
5953 if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount)
5956 /* Parse notification bitmap, verifying that it is zero. */
5957 p = xdr_inline_decode(xdr, 4);
5960 len = be32_to_cpup(p);
5964 p = xdr_inline_decode(xdr, 4 * len);
5968 res->notification = be32_to_cpup(p++);
5969 for (i = 1; i < len; i++) {
5970 if (be32_to_cpup(p++)) {
5971 dprintk("%s: unsupported notification\n",
5980 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
5981 struct nfs4_layoutget_res *res)
5988 status = decode_op_hdr(xdr, OP_LAYOUTGET);
5991 p = xdr_inline_decode(xdr, 4);
5994 res->return_on_close = be32_to_cpup(p);
5995 decode_layout_stateid(xdr, &res->stateid);
5996 p = xdr_inline_decode(xdr, 4);
5999 layout_count = be32_to_cpup(p);
6000 if (!layout_count) {
6001 dprintk("%s: server responded with empty layout array\n",
6007 p = xdr_inline_decode(xdr, 28);
6010 p = xdr_decode_hyper(p, &res->range.offset);
6011 p = xdr_decode_hyper(p, &res->range.length);
6012 res->range.iomode = be32_to_cpup(p++);
6013 res->type = be32_to_cpup(p++);
6014 res->layoutp->len = be32_to_cpup(p);
6016 dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n",
6018 (unsigned long)res->range.offset,
6019 (unsigned long)res->range.length,
6024 recvd = xdr_read_pages(xdr, res->layoutp->len);
6025 if (res->layoutp->len > recvd) {
6026 dprintk("NFS: server cheating in layoutget reply: "
6027 "layout len %u > recvd %u\n",
6028 res->layoutp->len, recvd);
6033 if (layout_count > 1) {
6034 /* We only handle a length one array at the moment. Any
6035 * further entries are just ignored. Note that this means
6036 * the client may see a response that is less than the
6037 * minimum it requested.
6039 dprintk("%s: server responded with %d layouts, dropping tail\n",
6040 __func__, layout_count);
6044 res->status = status;
6051 static int decode_layoutreturn(struct xdr_stream *xdr,
6052 struct nfs4_layoutreturn_res *res)
6057 status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
6060 p = xdr_inline_decode(xdr, 4);
6063 res->lrs_present = be32_to_cpup(p);
6064 if (res->lrs_present)
6065 status = decode_layout_stateid(xdr, &res->stateid);
6067 nfs4_stateid_copy(&res->stateid, &invalid_stateid);
6071 static int decode_layoutcommit(struct xdr_stream *xdr,
6072 struct rpc_rqst *req,
6073 struct nfs4_layoutcommit_res *res)
6079 status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT);
6080 res->status = status;
6084 p = xdr_inline_decode(xdr, 4);
6087 sizechanged = be32_to_cpup(p);
6090 /* throw away new size */
6091 p = xdr_inline_decode(xdr, 8);
6098 static int decode_test_stateid(struct xdr_stream *xdr,
6099 struct nfs41_test_stateid_res *res)
6105 status = decode_op_hdr(xdr, OP_TEST_STATEID);
6109 p = xdr_inline_decode(xdr, 4);
6112 num_res = be32_to_cpup(p++);
6116 p = xdr_inline_decode(xdr, 4);
6119 res->status = be32_to_cpup(p++);
6124 static int decode_free_stateid(struct xdr_stream *xdr,
6125 struct nfs41_free_stateid_res *res)
6127 res->status = decode_op_hdr(xdr, OP_FREE_STATEID);
6132 int decode_layoutreturn(struct xdr_stream *xdr,
6133 struct nfs4_layoutreturn_res *res)
6138 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
6139 struct nfs4_layoutget_res *res)
6144 #endif /* CONFIG_NFS_V4_1 */
6147 * END OF "GENERIC" DECODE ROUTINES.
6151 * Decode OPEN_DOWNGRADE response
6153 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp,
6154 struct xdr_stream *xdr,
6157 struct nfs_closeres *res = data;
6158 struct compound_hdr hdr;
6161 status = decode_compound_hdr(xdr, &hdr);
6164 status = decode_sequence(xdr, &res->seq_res, rqstp);
6167 status = decode_putfh(xdr);
6171 status = decode_layoutreturn(xdr, res->lr_res);
6172 res->lr_ret = status;
6176 status = decode_open_downgrade(xdr, res);
6182 * Decode ACCESS response
6184 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6187 struct nfs4_accessres *res = data;
6188 struct compound_hdr hdr;
6191 status = decode_compound_hdr(xdr, &hdr);
6194 status = decode_sequence(xdr, &res->seq_res, rqstp);
6197 status = decode_putfh(xdr);
6200 status = decode_access(xdr, &res->supported, &res->access);
6204 decode_getfattr(xdr, res->fattr, res->server);
6210 * Decode LOOKUP response
6212 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6215 struct nfs4_lookup_res *res = data;
6216 struct compound_hdr hdr;
6219 status = decode_compound_hdr(xdr, &hdr);
6222 status = decode_sequence(xdr, &res->seq_res, rqstp);
6225 status = decode_putfh(xdr);
6228 status = decode_lookup(xdr);
6231 status = decode_getfh(xdr, res->fh);
6234 status = decode_getfattr(xdr, res->fattr, res->server);
6240 * Decode LOOKUPP response
6242 static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6245 struct nfs4_lookupp_res *res = data;
6246 struct compound_hdr hdr;
6249 status = decode_compound_hdr(xdr, &hdr);
6252 status = decode_sequence(xdr, &res->seq_res, rqstp);
6255 status = decode_putfh(xdr);
6258 status = decode_lookupp(xdr);
6261 status = decode_getfh(xdr, res->fh);
6264 status = decode_getfattr(xdr, res->fattr, res->server);
6270 * Decode LOOKUP_ROOT response
6272 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp,
6273 struct xdr_stream *xdr,
6276 struct nfs4_lookup_res *res = data;
6277 struct compound_hdr hdr;
6280 status = decode_compound_hdr(xdr, &hdr);
6283 status = decode_sequence(xdr, &res->seq_res, rqstp);
6286 status = decode_putrootfh(xdr);
6289 status = decode_getfh(xdr, res->fh);
6291 status = decode_getfattr(xdr, res->fattr, res->server);
6297 * Decode REMOVE response
6299 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6302 struct nfs_removeres *res = data;
6303 struct compound_hdr hdr;
6306 status = decode_compound_hdr(xdr, &hdr);
6309 status = decode_sequence(xdr, &res->seq_res, rqstp);
6312 status = decode_putfh(xdr);
6315 status = decode_remove(xdr, &res->cinfo);
6321 * Decode RENAME response
6323 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6326 struct nfs_renameres *res = data;
6327 struct compound_hdr hdr;
6330 status = decode_compound_hdr(xdr, &hdr);
6333 status = decode_sequence(xdr, &res->seq_res, rqstp);
6336 status = decode_putfh(xdr);
6339 status = decode_savefh(xdr);
6342 status = decode_putfh(xdr);
6345 status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo);
6351 * Decode LINK response
6353 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6356 struct nfs4_link_res *res = data;
6357 struct compound_hdr hdr;
6360 status = decode_compound_hdr(xdr, &hdr);
6363 status = decode_sequence(xdr, &res->seq_res, rqstp);
6366 status = decode_putfh(xdr);
6369 status = decode_savefh(xdr);
6372 status = decode_putfh(xdr);
6375 status = decode_link(xdr, &res->cinfo);
6379 * Note order: OP_LINK leaves the directory as the current
6382 status = decode_restorefh(xdr);
6385 decode_getfattr(xdr, res->fattr, res->server);
6391 * Decode CREATE response
6393 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6396 struct nfs4_create_res *res = data;
6397 struct compound_hdr hdr;
6400 status = decode_compound_hdr(xdr, &hdr);
6403 status = decode_sequence(xdr, &res->seq_res, rqstp);
6406 status = decode_putfh(xdr);
6409 status = decode_create(xdr, &res->dir_cinfo);
6412 status = decode_getfh(xdr, res->fh);
6415 decode_getfattr(xdr, res->fattr, res->server);
6421 * Decode SYMLINK response
6423 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6426 return nfs4_xdr_dec_create(rqstp, xdr, res);
6430 * Decode GETATTR response
6432 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6435 struct nfs4_getattr_res *res = data;
6436 struct compound_hdr hdr;
6439 status = decode_compound_hdr(xdr, &hdr);
6442 status = decode_sequence(xdr, &res->seq_res, rqstp);
6445 status = decode_putfh(xdr);
6448 status = decode_getfattr(xdr, res->fattr, res->server);
6454 * Encode an SETACL request
6456 static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr,
6459 const struct nfs_setaclargs *args = data;
6460 struct compound_hdr hdr = {
6461 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
6464 encode_compound_hdr(xdr, req, &hdr);
6465 encode_sequence(xdr, &args->seq_args, &hdr);
6466 encode_putfh(xdr, args->fh, &hdr);
6467 encode_setacl(xdr, args, &hdr);
6472 * Decode SETACL response
6475 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6478 struct nfs_setaclres *res = data;
6479 struct compound_hdr hdr;
6482 status = decode_compound_hdr(xdr, &hdr);
6485 status = decode_sequence(xdr, &res->seq_res, rqstp);
6488 status = decode_putfh(xdr);
6491 status = decode_setattr(xdr);
6497 * Decode GETACL response
6500 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6503 struct nfs_getaclres *res = data;
6504 struct compound_hdr hdr;
6507 if (res->acl_scratch != NULL)
6508 xdr_set_scratch_page(xdr, res->acl_scratch);
6509 status = decode_compound_hdr(xdr, &hdr);
6512 status = decode_sequence(xdr, &res->seq_res, rqstp);
6515 status = decode_putfh(xdr);
6518 status = decode_getacl(xdr, rqstp, res, res->acl_type);
6525 * Decode CLOSE response
6527 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6530 struct nfs_closeres *res = data;
6531 struct compound_hdr hdr;
6534 status = decode_compound_hdr(xdr, &hdr);
6537 status = decode_sequence(xdr, &res->seq_res, rqstp);
6540 status = decode_putfh(xdr);
6544 status = decode_layoutreturn(xdr, res->lr_res);
6545 res->lr_ret = status;
6549 if (res->fattr != NULL) {
6550 status = decode_getfattr(xdr, res->fattr, res->server);
6554 status = decode_close(xdr, res);
6560 * Decode OPEN response
6562 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6565 struct nfs_openres *res = data;
6566 struct compound_hdr hdr;
6569 status = decode_compound_hdr(xdr, &hdr);
6572 status = decode_sequence(xdr, &res->seq_res, rqstp);
6575 status = decode_putfh(xdr);
6578 status = decode_open(xdr, res);
6581 status = decode_getfh(xdr, &res->fh);
6584 if (res->access_request)
6585 decode_access(xdr, &res->access_supported, &res->access_result);
6586 decode_getfattr(xdr, res->f_attr, res->server);
6588 decode_layoutget(xdr, rqstp, res->lg_res);
6594 * Decode OPEN_CONFIRM response
6596 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp,
6597 struct xdr_stream *xdr,
6600 struct nfs_open_confirmres *res = data;
6601 struct compound_hdr hdr;
6604 status = decode_compound_hdr(xdr, &hdr);
6607 status = decode_putfh(xdr);
6610 status = decode_open_confirm(xdr, res);
6616 * Decode OPEN response
6618 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp,
6619 struct xdr_stream *xdr,
6622 struct nfs_openres *res = data;
6623 struct compound_hdr hdr;
6626 status = decode_compound_hdr(xdr, &hdr);
6629 status = decode_sequence(xdr, &res->seq_res, rqstp);
6632 status = decode_putfh(xdr);
6635 status = decode_open(xdr, res);
6638 if (res->access_request)
6639 decode_access(xdr, &res->access_supported, &res->access_result);
6640 decode_getfattr(xdr, res->f_attr, res->server);
6642 decode_layoutget(xdr, rqstp, res->lg_res);
6648 * Decode SETATTR response
6650 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp,
6651 struct xdr_stream *xdr,
6654 struct nfs_setattrres *res = data;
6655 struct compound_hdr hdr;
6658 status = decode_compound_hdr(xdr, &hdr);
6661 status = decode_sequence(xdr, &res->seq_res, rqstp);
6664 status = decode_putfh(xdr);
6667 status = decode_setattr(xdr);
6670 decode_getfattr(xdr, res->fattr, res->server);
6676 * Decode LOCK response
6678 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6681 struct nfs_lock_res *res = data;
6682 struct compound_hdr hdr;
6685 status = decode_compound_hdr(xdr, &hdr);
6688 status = decode_sequence(xdr, &res->seq_res, rqstp);
6691 status = decode_putfh(xdr);
6694 status = decode_lock(xdr, res);
6700 * Decode LOCKT response
6702 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6705 struct nfs_lockt_res *res = data;
6706 struct compound_hdr hdr;
6709 status = decode_compound_hdr(xdr, &hdr);
6712 status = decode_sequence(xdr, &res->seq_res, rqstp);
6715 status = decode_putfh(xdr);
6718 status = decode_lockt(xdr, res);
6724 * Decode LOCKU response
6726 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6729 struct nfs_locku_res *res = data;
6730 struct compound_hdr hdr;
6733 status = decode_compound_hdr(xdr, &hdr);
6736 status = decode_sequence(xdr, &res->seq_res, rqstp);
6739 status = decode_putfh(xdr);
6742 status = decode_locku(xdr, res);
6747 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
6748 struct xdr_stream *xdr, void *dummy)
6750 struct compound_hdr hdr;
6753 status = decode_compound_hdr(xdr, &hdr);
6755 status = decode_release_lockowner(xdr);
6760 * Decode READLINK response
6762 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp,
6763 struct xdr_stream *xdr,
6766 struct nfs4_readlink_res *res = data;
6767 struct compound_hdr hdr;
6770 status = decode_compound_hdr(xdr, &hdr);
6773 status = decode_sequence(xdr, &res->seq_res, rqstp);
6776 status = decode_putfh(xdr);
6779 status = decode_readlink(xdr, rqstp);
6785 * Decode READDIR response
6787 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6790 struct nfs4_readdir_res *res = data;
6791 struct compound_hdr hdr;
6794 status = decode_compound_hdr(xdr, &hdr);
6797 status = decode_sequence(xdr, &res->seq_res, rqstp);
6800 status = decode_putfh(xdr);
6803 status = decode_readdir(xdr, rqstp, res);
6809 * Decode Read response
6811 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6814 struct nfs_pgio_res *res = data;
6815 struct compound_hdr hdr;
6818 status = decode_compound_hdr(xdr, &hdr);
6819 res->op_status = hdr.status;
6822 status = decode_sequence(xdr, &res->seq_res, rqstp);
6825 status = decode_putfh(xdr);
6828 status = decode_read(xdr, rqstp, res);
6830 status = res->count;
6836 * Decode WRITE response
6838 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6841 struct nfs_pgio_res *res = data;
6842 struct compound_hdr hdr;
6845 status = decode_compound_hdr(xdr, &hdr);
6846 res->op_status = hdr.status;
6849 status = decode_sequence(xdr, &res->seq_res, rqstp);
6852 status = decode_putfh(xdr);
6855 status = decode_write(xdr, res);
6859 decode_getfattr(xdr, res->fattr, res->server);
6861 status = res->count;
6867 * Decode COMMIT response
6869 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6872 struct nfs_commitres *res = data;
6873 struct compound_hdr hdr;
6876 status = decode_compound_hdr(xdr, &hdr);
6877 res->op_status = hdr.status;
6880 status = decode_sequence(xdr, &res->seq_res, rqstp);
6883 status = decode_putfh(xdr);
6886 status = decode_commit(xdr, res);
6892 * Decode FSINFO response
6894 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
6897 struct nfs4_fsinfo_res *res = data;
6898 struct compound_hdr hdr;
6901 status = decode_compound_hdr(xdr, &hdr);
6903 status = decode_sequence(xdr, &res->seq_res, req);
6905 status = decode_putfh(xdr);
6907 status = decode_fsinfo(xdr, res->fsinfo);
6912 * Decode PATHCONF response
6914 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
6917 struct nfs4_pathconf_res *res = data;
6918 struct compound_hdr hdr;
6921 status = decode_compound_hdr(xdr, &hdr);
6923 status = decode_sequence(xdr, &res->seq_res, req);
6925 status = decode_putfh(xdr);
6927 status = decode_pathconf(xdr, res->pathconf);
6932 * Decode STATFS response
6934 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
6937 struct nfs4_statfs_res *res = data;
6938 struct compound_hdr hdr;
6941 status = decode_compound_hdr(xdr, &hdr);
6943 status = decode_sequence(xdr, &res->seq_res, req);
6945 status = decode_putfh(xdr);
6947 status = decode_statfs(xdr, res->fsstat);
6952 * Decode GETATTR_BITMAP response
6954 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req,
6955 struct xdr_stream *xdr,
6958 struct nfs4_server_caps_res *res = data;
6959 struct compound_hdr hdr;
6962 status = decode_compound_hdr(xdr, &hdr);
6965 status = decode_sequence(xdr, &res->seq_res, req);
6968 status = decode_putfh(xdr);
6971 status = decode_server_caps(xdr, res);
6977 * Decode RENEW response
6979 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6982 struct compound_hdr hdr;
6985 status = decode_compound_hdr(xdr, &hdr);
6987 status = decode_renew(xdr);
6992 * Decode SETCLIENTID response
6994 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req,
6995 struct xdr_stream *xdr,
6998 struct nfs4_setclientid_res *res = data;
6999 struct compound_hdr hdr;
7002 status = decode_compound_hdr(xdr, &hdr);
7004 status = decode_setclientid(xdr, res);
7009 * Decode SETCLIENTID_CONFIRM response
7011 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
7012 struct xdr_stream *xdr,
7015 struct compound_hdr hdr;
7018 status = decode_compound_hdr(xdr, &hdr);
7020 status = decode_setclientid_confirm(xdr);
7025 * Decode DELEGRETURN response
7027 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp,
7028 struct xdr_stream *xdr,
7031 struct nfs4_delegreturnres *res = data;
7032 struct compound_hdr hdr;
7035 status = decode_compound_hdr(xdr, &hdr);
7038 status = decode_sequence(xdr, &res->seq_res, rqstp);
7041 status = decode_putfh(xdr);
7045 status = decode_layoutreturn(xdr, res->lr_res);
7046 res->lr_ret = status;
7051 status = decode_getfattr(xdr, res->fattr, res->server);
7055 status = decode_delegreturn(xdr);
7061 * Decode FS_LOCATIONS response
7063 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req,
7064 struct xdr_stream *xdr,
7067 struct nfs4_fs_locations_res *res = data;
7068 struct compound_hdr hdr;
7071 status = decode_compound_hdr(xdr, &hdr);
7074 status = decode_sequence(xdr, &res->seq_res, req);
7077 status = decode_putfh(xdr);
7080 if (res->migration) {
7081 xdr_enter_page(xdr, PAGE_SIZE);
7082 status = decode_getfattr_generic(xdr,
7083 res->fs_locations->fattr,
7084 NULL, res->fs_locations,
7085 res->fs_locations->server);
7089 status = decode_renew(xdr);
7091 status = decode_lookup(xdr);
7094 xdr_enter_page(xdr, PAGE_SIZE);
7095 status = decode_getfattr_generic(xdr,
7096 res->fs_locations->fattr,
7097 NULL, res->fs_locations,
7098 res->fs_locations->server);
7105 * Decode SECINFO response
7107 static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp,
7108 struct xdr_stream *xdr,
7111 struct nfs4_secinfo_res *res = data;
7112 struct compound_hdr hdr;
7115 status = decode_compound_hdr(xdr, &hdr);
7118 status = decode_sequence(xdr, &res->seq_res, rqstp);
7121 status = decode_putfh(xdr);
7124 status = decode_secinfo(xdr, res);
7130 * Decode FSID_PRESENT response
7132 static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp,
7133 struct xdr_stream *xdr,
7136 struct nfs4_fsid_present_res *res = data;
7137 struct compound_hdr hdr;
7140 status = decode_compound_hdr(xdr, &hdr);
7143 status = decode_sequence(xdr, &res->seq_res, rqstp);
7146 status = decode_putfh(xdr);
7149 status = decode_getfh(xdr, res->fh);
7153 status = decode_renew(xdr);
7158 #if defined(CONFIG_NFS_V4_1)
7160 * Decode BIND_CONN_TO_SESSION response
7162 static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp,
7163 struct xdr_stream *xdr,
7166 struct compound_hdr hdr;
7169 status = decode_compound_hdr(xdr, &hdr);
7171 status = decode_bind_conn_to_session(xdr, res);
7176 * Decode EXCHANGE_ID response
7178 static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp,
7179 struct xdr_stream *xdr,
7182 struct compound_hdr hdr;
7185 status = decode_compound_hdr(xdr, &hdr);
7187 status = decode_exchange_id(xdr, res);
7192 * Decode CREATE_SESSION response
7194 static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp,
7195 struct xdr_stream *xdr,
7198 struct compound_hdr hdr;
7201 status = decode_compound_hdr(xdr, &hdr);
7203 status = decode_create_session(xdr, res);
7208 * Decode DESTROY_SESSION response
7210 static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp,
7211 struct xdr_stream *xdr,
7214 struct compound_hdr hdr;
7217 status = decode_compound_hdr(xdr, &hdr);
7219 status = decode_destroy_session(xdr, res);
7224 * Decode DESTROY_CLIENTID response
7226 static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp,
7227 struct xdr_stream *xdr,
7230 struct compound_hdr hdr;
7233 status = decode_compound_hdr(xdr, &hdr);
7235 status = decode_destroy_clientid(xdr, res);
7240 * Decode SEQUENCE response
7242 static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp,
7243 struct xdr_stream *xdr,
7246 struct compound_hdr hdr;
7249 status = decode_compound_hdr(xdr, &hdr);
7251 status = decode_sequence(xdr, res, rqstp);
7258 * Decode GET_LEASE_TIME response
7260 static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp,
7261 struct xdr_stream *xdr,
7264 struct nfs4_get_lease_time_res *res = data;
7265 struct compound_hdr hdr;
7268 status = decode_compound_hdr(xdr, &hdr);
7270 status = decode_sequence(xdr, &res->lr_seq_res, rqstp);
7272 status = decode_putrootfh(xdr);
7274 status = decode_fsinfo(xdr, res->lr_fsinfo);
7278 #ifdef CONFIG_NFS_V4_1
7281 * Decode RECLAIM_COMPLETE response
7283 static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp,
7284 struct xdr_stream *xdr,
7287 struct nfs41_reclaim_complete_res *res = data;
7288 struct compound_hdr hdr;
7291 status = decode_compound_hdr(xdr, &hdr);
7293 status = decode_sequence(xdr, &res->seq_res, rqstp);
7295 status = decode_reclaim_complete(xdr, NULL);
7300 * Decode GETDEVINFO response
7302 static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp,
7303 struct xdr_stream *xdr,
7306 struct nfs4_getdeviceinfo_res *res = data;
7307 struct compound_hdr hdr;
7310 status = decode_compound_hdr(xdr, &hdr);
7313 status = decode_sequence(xdr, &res->seq_res, rqstp);
7316 status = decode_getdeviceinfo(xdr, res);
7322 * Decode LAYOUTGET response
7324 static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp,
7325 struct xdr_stream *xdr,
7328 struct nfs4_layoutget_res *res = data;
7329 struct compound_hdr hdr;
7332 status = decode_compound_hdr(xdr, &hdr);
7335 status = decode_sequence(xdr, &res->seq_res, rqstp);
7338 status = decode_putfh(xdr);
7341 status = decode_layoutget(xdr, rqstp, res);
7347 * Decode LAYOUTRETURN response
7349 static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp,
7350 struct xdr_stream *xdr,
7353 struct nfs4_layoutreturn_res *res = data;
7354 struct compound_hdr hdr;
7357 status = decode_compound_hdr(xdr, &hdr);
7360 status = decode_sequence(xdr, &res->seq_res, rqstp);
7363 status = decode_putfh(xdr);
7366 status = decode_layoutreturn(xdr, res);
7372 * Decode LAYOUTCOMMIT response
7374 static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp,
7375 struct xdr_stream *xdr,
7378 struct nfs4_layoutcommit_res *res = data;
7379 struct compound_hdr hdr;
7382 status = decode_compound_hdr(xdr, &hdr);
7385 status = decode_sequence(xdr, &res->seq_res, rqstp);
7388 status = decode_putfh(xdr);
7391 status = decode_layoutcommit(xdr, rqstp, res);
7394 decode_getfattr(xdr, res->fattr, res->server);
7400 * Decode SECINFO_NO_NAME response
7402 static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp,
7403 struct xdr_stream *xdr,
7406 struct nfs4_secinfo_res *res = data;
7407 struct compound_hdr hdr;
7410 status = decode_compound_hdr(xdr, &hdr);
7413 status = decode_sequence(xdr, &res->seq_res, rqstp);
7416 status = decode_putrootfh(xdr);
7419 status = decode_secinfo_no_name(xdr, res);
7425 * Decode TEST_STATEID response
7427 static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp,
7428 struct xdr_stream *xdr,
7431 struct nfs41_test_stateid_res *res = data;
7432 struct compound_hdr hdr;
7435 status = decode_compound_hdr(xdr, &hdr);
7438 status = decode_sequence(xdr, &res->seq_res, rqstp);
7441 status = decode_test_stateid(xdr, res);
7447 * Decode FREE_STATEID response
7449 static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp,
7450 struct xdr_stream *xdr,
7453 struct nfs41_free_stateid_res *res = data;
7454 struct compound_hdr hdr;
7457 status = decode_compound_hdr(xdr, &hdr);
7460 status = decode_sequence(xdr, &res->seq_res, rqstp);
7463 status = decode_free_stateid(xdr, res);
7467 #endif /* CONFIG_NFS_V4_1 */
7470 * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in
7471 * the local page cache.
7472 * @xdr: XDR stream where entry resides
7473 * @entry: buffer to fill in with entry data
7474 * @plus: boolean indicating whether this should be a readdirplus entry
7476 * Returns zero if successful, otherwise a negative errno value is
7479 * This function is not invoked during READDIR reply decoding, but
7480 * rather whenever an application invokes the getdents(2) system call
7481 * on a directory already in our cache.
7483 int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
7487 uint32_t bitmap[3] = {0};
7489 uint64_t new_cookie;
7490 __be32 *p = xdr_inline_decode(xdr, 4);
7493 if (*p == xdr_zero) {
7494 p = xdr_inline_decode(xdr, 4);
7503 p = xdr_inline_decode(xdr, 12);
7506 p = xdr_decode_hyper(p, &new_cookie);
7507 entry->len = be32_to_cpup(p);
7509 p = xdr_inline_decode(xdr, entry->len);
7512 entry->name = (const char *) p;
7515 * In case the server doesn't return an inode number,
7516 * we fake one here. (We don't use inode number 0,
7517 * since glibc seems to choke on it...)
7520 entry->fattr->valid = 0;
7522 if (decode_attr_bitmap(xdr, bitmap) < 0)
7525 if (decode_attr_length(xdr, &len, &savep) < 0)
7528 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,
7529 NULL, entry->server) < 0)
7531 if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
7532 entry->ino = entry->fattr->mounted_on_fileid;
7533 else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
7534 entry->ino = entry->fattr->fileid;
7536 entry->d_type = DT_UNKNOWN;
7537 if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
7538 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
7540 entry->cookie = new_cookie;
7546 * We need to translate between nfs status return values and
7547 * the local errno values which may not be the same.
7554 { NFS4ERR_PERM, -EPERM },
7555 { NFS4ERR_NOENT, -ENOENT },
7556 { NFS4ERR_IO, -errno_NFSERR_IO},
7557 { NFS4ERR_NXIO, -ENXIO },
7558 { NFS4ERR_ACCESS, -EACCES },
7559 { NFS4ERR_EXIST, -EEXIST },
7560 { NFS4ERR_XDEV, -EXDEV },
7561 { NFS4ERR_NOTDIR, -ENOTDIR },
7562 { NFS4ERR_ISDIR, -EISDIR },
7563 { NFS4ERR_INVAL, -EINVAL },
7564 { NFS4ERR_FBIG, -EFBIG },
7565 { NFS4ERR_NOSPC, -ENOSPC },
7566 { NFS4ERR_ROFS, -EROFS },
7567 { NFS4ERR_MLINK, -EMLINK },
7568 { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
7569 { NFS4ERR_NOTEMPTY, -ENOTEMPTY },
7570 { NFS4ERR_DQUOT, -EDQUOT },
7571 { NFS4ERR_STALE, -ESTALE },
7572 { NFS4ERR_BADHANDLE, -EBADHANDLE },
7573 { NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
7574 { NFS4ERR_NOTSUPP, -ENOTSUPP },
7575 { NFS4ERR_TOOSMALL, -ETOOSMALL },
7576 { NFS4ERR_SERVERFAULT, -EREMOTEIO },
7577 { NFS4ERR_BADTYPE, -EBADTYPE },
7578 { NFS4ERR_LOCKED, -EAGAIN },
7579 { NFS4ERR_SYMLINK, -ELOOP },
7580 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
7581 { NFS4ERR_DEADLOCK, -EDEADLK },
7582 { NFS4ERR_NOXATTR, -ENODATA },
7583 { NFS4ERR_XATTR2BIG, -E2BIG },
7588 * Convert an NFS error code to a local one.
7589 * This one is used jointly by NFSv2 and NFSv3.
7592 nfs4_stat_to_errno(int stat)
7595 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
7596 if (nfs_errtbl[i].stat == stat)
7597 return nfs_errtbl[i].errno;
7599 if (stat <= 10000 || stat > 10100) {
7600 /* The server is looney tunes. */
7603 /* If we cannot translate the error, the recovery routines should
7605 * Note: remaining NFSv4 error codes have values > 10000, so should
7606 * not conflict with native Linux error codes.
7611 #ifdef CONFIG_NFS_V4_2
7612 #include "nfs42xdr.c"
7613 #endif /* CONFIG_NFS_V4_2 */
7615 #define PROC(proc, argtype, restype) \
7616 [NFSPROC4_CLNT_##proc] = { \
7617 .p_proc = NFSPROC4_COMPOUND, \
7618 .p_encode = nfs4_xdr_##argtype, \
7619 .p_decode = nfs4_xdr_##restype, \
7620 .p_arglen = NFS4_##argtype##_sz, \
7621 .p_replen = NFS4_##restype##_sz, \
7622 .p_statidx = NFSPROC4_CLNT_##proc, \
7626 #define STUB(proc) \
7627 [NFSPROC4_CLNT_##proc] = { \
7631 #if defined(CONFIG_NFS_V4_1)
7632 #define PROC41(proc, argtype, restype) \
7633 PROC(proc, argtype, restype)
7635 #define PROC41(proc, argtype, restype) \
7639 #if defined(CONFIG_NFS_V4_2)
7640 #define PROC42(proc, argtype, restype) \
7641 PROC(proc, argtype, restype)
7643 #define PROC42(proc, argtype, restype) \
7647 const struct rpc_procinfo nfs4_procedures[] = {
7648 PROC(READ, enc_read, dec_read),
7649 PROC(WRITE, enc_write, dec_write),
7650 PROC(COMMIT, enc_commit, dec_commit),
7651 PROC(OPEN, enc_open, dec_open),
7652 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
7653 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
7654 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
7655 PROC(CLOSE, enc_close, dec_close),
7656 PROC(SETATTR, enc_setattr, dec_setattr),
7657 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
7658 PROC(RENEW, enc_renew, dec_renew),
7659 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
7660 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
7661 PROC(LOCK, enc_lock, dec_lock),
7662 PROC(LOCKT, enc_lockt, dec_lockt),
7663 PROC(LOCKU, enc_locku, dec_locku),
7664 PROC(ACCESS, enc_access, dec_access),
7665 PROC(GETATTR, enc_getattr, dec_getattr),
7666 PROC(LOOKUP, enc_lookup, dec_lookup),
7667 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
7668 PROC(REMOVE, enc_remove, dec_remove),
7669 PROC(RENAME, enc_rename, dec_rename),
7670 PROC(LINK, enc_link, dec_link),
7671 PROC(SYMLINK, enc_symlink, dec_symlink),
7672 PROC(CREATE, enc_create, dec_create),
7673 PROC(PATHCONF, enc_pathconf, dec_pathconf),
7674 PROC(STATFS, enc_statfs, dec_statfs),
7675 PROC(READLINK, enc_readlink, dec_readlink),
7676 PROC(READDIR, enc_readdir, dec_readdir),
7677 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
7678 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
7679 PROC(GETACL, enc_getacl, dec_getacl),
7680 PROC(SETACL, enc_setacl, dec_setacl),
7681 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
7682 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
7683 PROC(SECINFO, enc_secinfo, dec_secinfo),
7684 PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present),
7685 PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
7686 PROC41(CREATE_SESSION, enc_create_session, dec_create_session),
7687 PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
7688 PROC41(SEQUENCE, enc_sequence, dec_sequence),
7689 PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time),
7690 PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete),
7691 PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo),
7692 PROC41(LAYOUTGET, enc_layoutget, dec_layoutget),
7693 PROC41(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit),
7694 PROC41(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn),
7695 PROC41(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name),
7696 PROC41(TEST_STATEID, enc_test_stateid, dec_test_stateid),
7697 PROC41(FREE_STATEID, enc_free_stateid, dec_free_stateid),
7698 STUB(GETDEVICELIST),
7699 PROC41(BIND_CONN_TO_SESSION,
7700 enc_bind_conn_to_session, dec_bind_conn_to_session),
7701 PROC41(DESTROY_CLIENTID,enc_destroy_clientid, dec_destroy_clientid),
7702 PROC42(SEEK, enc_seek, dec_seek),
7703 PROC42(ALLOCATE, enc_allocate, dec_allocate),
7704 PROC42(DEALLOCATE, enc_deallocate, dec_deallocate),
7705 PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats),
7706 PROC42(CLONE, enc_clone, dec_clone),
7707 PROC42(COPY, enc_copy, dec_copy),
7708 PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel),
7709 PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify),
7710 PROC(LOOKUPP, enc_lookupp, dec_lookupp),
7711 PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror),
7712 PROC42(GETXATTR, enc_getxattr, dec_getxattr),
7713 PROC42(SETXATTR, enc_setxattr, dec_setxattr),
7714 PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs),
7715 PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr),
7716 PROC42(READ_PLUS, enc_read_plus, dec_read_plus),
7719 static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
7720 const struct rpc_version nfs_version4 = {
7722 .nrprocs = ARRAY_SIZE(nfs4_procedures),
7723 .procs = nfs4_procedures,
7724 .counts = nfs_version4_counts,