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/sunrpc/clnt.h>
48 #include <linux/sunrpc/msg_prot.h>
49 #include <linux/nfs.h>
50 #include <linux/nfs4.h>
51 #include <linux/nfs_fs.h>
52 #include <linux/nfs_idmap.h>
56 #define NFSDBG_FACILITY NFSDBG_XDR
58 /* Mapping from NFS error code to "errno" error code. */
59 #define errno_NFSERR_IO EIO
61 static int nfs4_stat_to_errno(int);
63 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
65 #define NFS4_MAXTAGLEN 20
67 #define NFS4_MAXTAGLEN 0
70 /* lock,open owner id:
71 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
73 #define open_owner_id_maxsz (1 + 4)
74 #define lock_owner_id_maxsz (1 + 4)
75 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
76 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
77 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
78 #define op_encode_hdr_maxsz (1)
79 #define op_decode_hdr_maxsz (2)
80 #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
81 #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
82 #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
83 #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
84 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
86 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
87 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
88 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
89 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
90 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
91 ((3+NFS4_FHSIZE) >> 2))
92 #define nfs4_fattr_bitmap_maxsz 3
93 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
94 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
95 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
96 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
97 #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
98 /* This is based on getfattr, which uses the most attributes: */
99 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
100 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz))
101 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
102 nfs4_fattr_value_maxsz)
103 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
104 #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
109 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
110 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
111 #define encode_restorefh_maxsz (op_encode_hdr_maxsz)
112 #define decode_restorefh_maxsz (op_decode_hdr_maxsz)
113 #define encode_fsinfo_maxsz (encode_getattr_maxsz)
114 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11)
115 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
116 #define decode_renew_maxsz (op_decode_hdr_maxsz)
117 #define encode_setclientid_maxsz \
118 (op_encode_hdr_maxsz + \
119 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
120 XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \
122 XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
123 XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
125 #define decode_setclientid_maxsz \
126 (op_decode_hdr_maxsz + \
128 1024) /* large value for CLID_INUSE */
129 #define encode_setclientid_confirm_maxsz \
130 (op_encode_hdr_maxsz + \
131 3 + (NFS4_VERIFIER_SIZE >> 2))
132 #define decode_setclientid_confirm_maxsz \
133 (op_decode_hdr_maxsz)
134 #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
135 #define decode_lookup_maxsz (op_decode_hdr_maxsz)
136 #define encode_share_access_maxsz \
138 #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
139 #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
140 #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
141 #define encode_open_maxsz (op_encode_hdr_maxsz + \
142 2 + encode_share_access_maxsz + 2 + \
143 open_owner_id_maxsz + \
144 encode_opentype_maxsz + \
145 encode_claim_null_maxsz)
146 #define decode_ace_maxsz (3 + nfs4_owner_maxsz)
147 #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
149 #define decode_change_info_maxsz (5)
150 #define decode_open_maxsz (op_decode_hdr_maxsz + \
151 decode_stateid_maxsz + \
152 decode_change_info_maxsz + 1 + \
153 nfs4_fattr_bitmap_maxsz + \
154 decode_delegation_maxsz)
155 #define encode_open_confirm_maxsz \
156 (op_encode_hdr_maxsz + \
157 encode_stateid_maxsz + 1)
158 #define decode_open_confirm_maxsz \
159 (op_decode_hdr_maxsz + \
160 decode_stateid_maxsz)
161 #define encode_open_downgrade_maxsz \
162 (op_encode_hdr_maxsz + \
163 encode_stateid_maxsz + 1 + \
164 encode_share_access_maxsz)
165 #define decode_open_downgrade_maxsz \
166 (op_decode_hdr_maxsz + \
167 decode_stateid_maxsz)
168 #define encode_close_maxsz (op_encode_hdr_maxsz + \
169 1 + encode_stateid_maxsz)
170 #define decode_close_maxsz (op_decode_hdr_maxsz + \
171 decode_stateid_maxsz)
172 #define encode_setattr_maxsz (op_encode_hdr_maxsz + \
173 encode_stateid_maxsz + \
175 #define decode_setattr_maxsz (op_decode_hdr_maxsz + \
176 nfs4_fattr_bitmap_maxsz)
177 #define encode_read_maxsz (op_encode_hdr_maxsz + \
178 encode_stateid_maxsz + 3)
179 #define decode_read_maxsz (op_decode_hdr_maxsz + 2)
180 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
181 2 + encode_verifier_maxsz + 5)
182 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
183 decode_verifier_maxsz)
184 #define encode_readlink_maxsz (op_encode_hdr_maxsz)
185 #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1)
186 #define encode_write_maxsz (op_encode_hdr_maxsz + \
187 encode_stateid_maxsz + 4)
188 #define decode_write_maxsz (op_decode_hdr_maxsz + \
189 2 + decode_verifier_maxsz)
190 #define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
191 #define decode_commit_maxsz (op_decode_hdr_maxsz + \
192 decode_verifier_maxsz)
193 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
195 #define decode_remove_maxsz (op_decode_hdr_maxsz + \
196 decode_change_info_maxsz)
197 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
199 #define decode_rename_maxsz (op_decode_hdr_maxsz + \
200 decode_change_info_maxsz + \
201 decode_change_info_maxsz)
202 #define encode_link_maxsz (op_encode_hdr_maxsz + \
204 #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
205 #define encode_lockowner_maxsz (7)
206 #define encode_lock_maxsz (op_encode_hdr_maxsz + \
208 1 + encode_stateid_maxsz + 1 + \
209 encode_lockowner_maxsz)
210 #define decode_lock_denied_maxsz \
211 (8 + decode_lockowner_maxsz)
212 #define decode_lock_maxsz (op_decode_hdr_maxsz + \
213 decode_lock_denied_maxsz)
214 #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \
215 encode_lockowner_maxsz)
216 #define decode_lockt_maxsz (op_decode_hdr_maxsz + \
217 decode_lock_denied_maxsz)
218 #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
219 encode_stateid_maxsz + \
221 #define decode_locku_maxsz (op_decode_hdr_maxsz + \
222 decode_stateid_maxsz)
223 #define encode_release_lockowner_maxsz \
224 (op_encode_hdr_maxsz + \
225 encode_lockowner_maxsz)
226 #define decode_release_lockowner_maxsz \
227 (op_decode_hdr_maxsz)
228 #define encode_access_maxsz (op_encode_hdr_maxsz + 1)
229 #define decode_access_maxsz (op_decode_hdr_maxsz + 2)
230 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
231 1 + nfs4_name_maxsz + \
234 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
235 #define encode_create_maxsz (op_encode_hdr_maxsz + \
236 1 + 2 + nfs4_name_maxsz + \
238 #define decode_create_maxsz (op_decode_hdr_maxsz + \
239 decode_change_info_maxsz + \
240 nfs4_fattr_bitmap_maxsz)
241 #define encode_statfs_maxsz (encode_getattr_maxsz)
242 #define decode_statfs_maxsz (decode_getattr_maxsz)
243 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
244 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
245 #define encode_getacl_maxsz (encode_getattr_maxsz)
246 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
247 nfs4_fattr_bitmap_maxsz + 1)
248 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
249 encode_stateid_maxsz + 3)
250 #define decode_setacl_maxsz (decode_setattr_maxsz)
251 #define encode_fs_locations_maxsz \
252 (encode_getattr_maxsz)
253 #define decode_fs_locations_maxsz \
256 #if defined(CONFIG_NFS_V4_1)
257 #define NFS4_MAX_MACHINE_NAME_LEN (64)
259 #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
260 encode_verifier_maxsz + \
261 1 /* co_ownerid.len */ + \
262 XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \
265 0 /* SP4_NONE (for now) */ + \
266 1 /* zero implemetation id array */)
267 #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
268 2 /* eir_clientid */ + \
269 1 /* eir_sequenceid */ + \
270 1 /* eir_flags */ + \
272 0 /* SP4_NONE (for now) */ + \
273 2 /* eir_server_owner.so_minor_id */ + \
274 /* eir_server_owner.so_major_id<> */ \
275 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
276 /* eir_server_scope<> */ \
277 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
278 1 /* eir_server_impl_id array length */ + \
279 0 /* ignored eir_server_impl_id contents */)
280 #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */)
281 #define decode_channel_attrs_maxsz (6 + \
282 1 /* ca_rdma_ird.len */ + \
284 #define encode_create_session_maxsz (op_encode_hdr_maxsz + \
285 2 /* csa_clientid */ + \
286 1 /* csa_sequence */ + \
287 1 /* csa_flags */ + \
288 encode_channel_attrs_maxsz + \
289 encode_channel_attrs_maxsz + \
290 1 /* csa_cb_program */ + \
291 1 /* csa_sec_parms.len (1) */ + \
292 1 /* cb_secflavor (AUTH_SYS) */ + \
294 1 /* machinename.len */ + \
295 XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \
298 1 /* gids.len (0) */)
299 #define decode_create_session_maxsz (op_decode_hdr_maxsz + \
300 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
301 1 /* csr_sequence */ + \
302 1 /* csr_flags */ + \
303 decode_channel_attrs_maxsz + \
304 decode_channel_attrs_maxsz)
305 #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)
306 #define decode_destroy_session_maxsz (op_decode_hdr_maxsz)
307 #define encode_sequence_maxsz (op_encode_hdr_maxsz + \
308 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
309 #define decode_sequence_maxsz (op_decode_hdr_maxsz + \
310 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
311 #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
312 #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
313 #else /* CONFIG_NFS_V4_1 */
314 #define encode_sequence_maxsz 0
315 #define decode_sequence_maxsz 0
316 #endif /* CONFIG_NFS_V4_1 */
318 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
319 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
320 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
321 encode_sequence_maxsz + \
322 encode_putfh_maxsz + \
324 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
325 decode_sequence_maxsz + \
326 decode_putfh_maxsz + \
328 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
329 encode_sequence_maxsz + \
330 encode_putfh_maxsz + \
331 encode_readlink_maxsz)
332 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
333 decode_sequence_maxsz + \
334 decode_putfh_maxsz + \
335 decode_readlink_maxsz)
336 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
337 encode_sequence_maxsz + \
338 encode_putfh_maxsz + \
339 encode_readdir_maxsz)
340 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
341 decode_sequence_maxsz + \
342 decode_putfh_maxsz + \
343 decode_readdir_maxsz)
344 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
345 encode_sequence_maxsz + \
346 encode_putfh_maxsz + \
347 encode_write_maxsz + \
348 encode_getattr_maxsz)
349 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
350 decode_sequence_maxsz + \
351 decode_putfh_maxsz + \
352 decode_write_maxsz + \
353 decode_getattr_maxsz)
354 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
355 encode_sequence_maxsz + \
356 encode_putfh_maxsz + \
357 encode_commit_maxsz + \
358 encode_getattr_maxsz)
359 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
360 decode_sequence_maxsz + \
361 decode_putfh_maxsz + \
362 decode_commit_maxsz + \
363 decode_getattr_maxsz)
364 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
365 encode_sequence_maxsz + \
366 encode_putfh_maxsz + \
367 encode_savefh_maxsz + \
368 encode_open_maxsz + \
369 encode_getfh_maxsz + \
370 encode_getattr_maxsz + \
371 encode_restorefh_maxsz + \
372 encode_getattr_maxsz)
373 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
374 decode_sequence_maxsz + \
375 decode_putfh_maxsz + \
376 decode_savefh_maxsz + \
377 decode_open_maxsz + \
378 decode_getfh_maxsz + \
379 decode_getattr_maxsz + \
380 decode_restorefh_maxsz + \
381 decode_getattr_maxsz)
382 #define NFS4_enc_open_confirm_sz \
383 (compound_encode_hdr_maxsz + \
384 encode_putfh_maxsz + \
385 encode_open_confirm_maxsz)
386 #define NFS4_dec_open_confirm_sz \
387 (compound_decode_hdr_maxsz + \
388 decode_putfh_maxsz + \
389 decode_open_confirm_maxsz)
390 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
391 encode_sequence_maxsz + \
392 encode_putfh_maxsz + \
393 encode_open_maxsz + \
394 encode_getattr_maxsz)
395 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
396 decode_sequence_maxsz + \
397 decode_putfh_maxsz + \
398 decode_open_maxsz + \
399 decode_getattr_maxsz)
400 #define NFS4_enc_open_downgrade_sz \
401 (compound_encode_hdr_maxsz + \
402 encode_sequence_maxsz + \
403 encode_putfh_maxsz + \
404 encode_open_downgrade_maxsz + \
405 encode_getattr_maxsz)
406 #define NFS4_dec_open_downgrade_sz \
407 (compound_decode_hdr_maxsz + \
408 decode_sequence_maxsz + \
409 decode_putfh_maxsz + \
410 decode_open_downgrade_maxsz + \
411 decode_getattr_maxsz)
412 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
413 encode_sequence_maxsz + \
414 encode_putfh_maxsz + \
415 encode_close_maxsz + \
416 encode_getattr_maxsz)
417 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
418 decode_sequence_maxsz + \
419 decode_putfh_maxsz + \
420 decode_close_maxsz + \
421 decode_getattr_maxsz)
422 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
423 encode_sequence_maxsz + \
424 encode_putfh_maxsz + \
425 encode_setattr_maxsz + \
426 encode_getattr_maxsz)
427 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
428 decode_sequence_maxsz + \
429 decode_putfh_maxsz + \
430 decode_setattr_maxsz + \
431 decode_getattr_maxsz)
432 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
433 encode_sequence_maxsz + \
434 encode_putfh_maxsz + \
436 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
437 decode_sequence_maxsz + \
438 decode_putfh_maxsz + \
440 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
442 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
444 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
445 encode_setclientid_maxsz)
446 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
447 decode_setclientid_maxsz)
448 #define NFS4_enc_setclientid_confirm_sz \
449 (compound_encode_hdr_maxsz + \
450 encode_setclientid_confirm_maxsz + \
451 encode_putrootfh_maxsz + \
453 #define NFS4_dec_setclientid_confirm_sz \
454 (compound_decode_hdr_maxsz + \
455 decode_setclientid_confirm_maxsz + \
456 decode_putrootfh_maxsz + \
458 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
459 encode_sequence_maxsz + \
460 encode_putfh_maxsz + \
462 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
463 decode_sequence_maxsz + \
464 decode_putfh_maxsz + \
466 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
467 encode_sequence_maxsz + \
468 encode_putfh_maxsz + \
470 #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
471 decode_sequence_maxsz + \
472 decode_putfh_maxsz + \
474 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
475 encode_sequence_maxsz + \
476 encode_putfh_maxsz + \
478 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
479 decode_sequence_maxsz + \
480 decode_putfh_maxsz + \
482 #define NFS4_enc_release_lockowner_sz \
483 (compound_encode_hdr_maxsz + \
484 encode_lockowner_maxsz)
485 #define NFS4_dec_release_lockowner_sz \
486 (compound_decode_hdr_maxsz + \
487 decode_lockowner_maxsz)
488 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
489 encode_sequence_maxsz + \
490 encode_putfh_maxsz + \
491 encode_access_maxsz + \
492 encode_getattr_maxsz)
493 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
494 decode_sequence_maxsz + \
495 decode_putfh_maxsz + \
496 decode_access_maxsz + \
497 decode_getattr_maxsz)
498 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
499 encode_sequence_maxsz + \
500 encode_putfh_maxsz + \
501 encode_getattr_maxsz)
502 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
503 decode_sequence_maxsz + \
504 decode_putfh_maxsz + \
505 decode_getattr_maxsz)
506 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
507 encode_sequence_maxsz + \
508 encode_putfh_maxsz + \
509 encode_lookup_maxsz + \
510 encode_getattr_maxsz + \
512 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
513 decode_sequence_maxsz + \
514 decode_putfh_maxsz + \
515 decode_lookup_maxsz + \
516 decode_getattr_maxsz + \
518 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
519 encode_sequence_maxsz + \
520 encode_putrootfh_maxsz + \
521 encode_getattr_maxsz + \
523 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
524 decode_sequence_maxsz + \
525 decode_putrootfh_maxsz + \
526 decode_getattr_maxsz + \
528 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
529 encode_sequence_maxsz + \
530 encode_putfh_maxsz + \
531 encode_remove_maxsz + \
532 encode_getattr_maxsz)
533 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
534 decode_sequence_maxsz + \
535 decode_putfh_maxsz + \
536 decode_remove_maxsz + \
537 decode_getattr_maxsz)
538 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
539 encode_sequence_maxsz + \
540 encode_putfh_maxsz + \
541 encode_savefh_maxsz + \
542 encode_putfh_maxsz + \
543 encode_rename_maxsz + \
544 encode_getattr_maxsz + \
545 encode_restorefh_maxsz + \
546 encode_getattr_maxsz)
547 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
548 decode_sequence_maxsz + \
549 decode_putfh_maxsz + \
550 decode_savefh_maxsz + \
551 decode_putfh_maxsz + \
552 decode_rename_maxsz + \
553 decode_getattr_maxsz + \
554 decode_restorefh_maxsz + \
555 decode_getattr_maxsz)
556 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
557 encode_sequence_maxsz + \
558 encode_putfh_maxsz + \
559 encode_savefh_maxsz + \
560 encode_putfh_maxsz + \
561 encode_link_maxsz + \
562 decode_getattr_maxsz + \
563 encode_restorefh_maxsz + \
564 decode_getattr_maxsz)
565 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
566 decode_sequence_maxsz + \
567 decode_putfh_maxsz + \
568 decode_savefh_maxsz + \
569 decode_putfh_maxsz + \
570 decode_link_maxsz + \
571 decode_getattr_maxsz + \
572 decode_restorefh_maxsz + \
573 decode_getattr_maxsz)
574 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
575 encode_sequence_maxsz + \
576 encode_putfh_maxsz + \
577 encode_symlink_maxsz + \
578 encode_getattr_maxsz + \
580 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
581 decode_sequence_maxsz + \
582 decode_putfh_maxsz + \
583 decode_symlink_maxsz + \
584 decode_getattr_maxsz + \
586 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
587 encode_sequence_maxsz + \
588 encode_putfh_maxsz + \
589 encode_savefh_maxsz + \
590 encode_create_maxsz + \
591 encode_getfh_maxsz + \
592 encode_getattr_maxsz + \
593 encode_restorefh_maxsz + \
594 encode_getattr_maxsz)
595 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
596 decode_sequence_maxsz + \
597 decode_putfh_maxsz + \
598 decode_savefh_maxsz + \
599 decode_create_maxsz + \
600 decode_getfh_maxsz + \
601 decode_getattr_maxsz + \
602 decode_restorefh_maxsz + \
603 decode_getattr_maxsz)
604 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
605 encode_sequence_maxsz + \
606 encode_putfh_maxsz + \
607 encode_getattr_maxsz)
608 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
609 decode_sequence_maxsz + \
610 decode_putfh_maxsz + \
611 decode_getattr_maxsz)
612 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
613 encode_sequence_maxsz + \
614 encode_putfh_maxsz + \
616 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
617 decode_sequence_maxsz + \
618 decode_putfh_maxsz + \
620 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
621 encode_sequence_maxsz + \
622 encode_putfh_maxsz + \
623 encode_getattr_maxsz)
624 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
625 decode_sequence_maxsz + \
626 decode_putfh_maxsz + \
627 decode_getattr_maxsz)
628 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
629 encode_sequence_maxsz + \
630 encode_putfh_maxsz + \
631 encode_delegreturn_maxsz + \
632 encode_getattr_maxsz)
633 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
634 decode_sequence_maxsz + \
635 decode_delegreturn_maxsz + \
636 decode_getattr_maxsz)
637 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
638 encode_sequence_maxsz + \
639 encode_putfh_maxsz + \
641 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
642 decode_sequence_maxsz + \
643 decode_putfh_maxsz + \
645 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
646 encode_sequence_maxsz + \
647 encode_putfh_maxsz + \
649 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
650 decode_sequence_maxsz + \
651 decode_putfh_maxsz + \
653 #define NFS4_enc_fs_locations_sz \
654 (compound_encode_hdr_maxsz + \
655 encode_sequence_maxsz + \
656 encode_putfh_maxsz + \
657 encode_lookup_maxsz + \
658 encode_fs_locations_maxsz)
659 #define NFS4_dec_fs_locations_sz \
660 (compound_decode_hdr_maxsz + \
661 decode_sequence_maxsz + \
662 decode_putfh_maxsz + \
663 decode_lookup_maxsz + \
664 decode_fs_locations_maxsz)
665 #if defined(CONFIG_NFS_V4_1)
666 #define NFS4_enc_exchange_id_sz \
667 (compound_encode_hdr_maxsz + \
668 encode_exchange_id_maxsz)
669 #define NFS4_dec_exchange_id_sz \
670 (compound_decode_hdr_maxsz + \
671 decode_exchange_id_maxsz)
672 #define NFS4_enc_create_session_sz \
673 (compound_encode_hdr_maxsz + \
674 encode_create_session_maxsz)
675 #define NFS4_dec_create_session_sz \
676 (compound_decode_hdr_maxsz + \
677 decode_create_session_maxsz)
678 #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \
679 encode_destroy_session_maxsz)
680 #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \
681 decode_destroy_session_maxsz)
682 #define NFS4_enc_sequence_sz \
683 (compound_decode_hdr_maxsz + \
684 encode_sequence_maxsz)
685 #define NFS4_dec_sequence_sz \
686 (compound_decode_hdr_maxsz + \
687 decode_sequence_maxsz)
688 #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \
689 encode_sequence_maxsz + \
690 encode_putrootfh_maxsz + \
692 #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \
693 decode_sequence_maxsz + \
694 decode_putrootfh_maxsz + \
696 #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
697 encode_sequence_maxsz + \
698 encode_reclaim_complete_maxsz)
699 #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \
700 decode_sequence_maxsz + \
701 decode_reclaim_complete_maxsz)
703 const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
704 compound_encode_hdr_maxsz +
705 encode_sequence_maxsz +
707 encode_getattr_maxsz) *
710 const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
711 compound_decode_hdr_maxsz +
712 decode_sequence_maxsz +
713 decode_putfh_maxsz) *
715 #endif /* CONFIG_NFS_V4_1 */
717 static const umode_t nfs_type2fmt[] = {
724 [NF4SOCK] = S_IFSOCK,
730 struct compound_hdr {
736 uint32_t replen; /* expected reply words */
740 static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
742 __be32 *p = xdr_reserve_space(xdr, nbytes);
747 static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
751 p = xdr_reserve_space(xdr, 4 + len);
753 xdr_encode_opaque(p, str, len);
756 static void encode_compound_hdr(struct xdr_stream *xdr,
757 struct rpc_rqst *req,
758 struct compound_hdr *hdr)
761 struct rpc_auth *auth = req->rq_cred->cr_auth;
763 /* initialize running count of expected bytes in reply.
764 * NOTE: the replied tag SHOULD be the same is the one sent,
765 * but this is not required as a MUST for the server to do so. */
766 hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen;
768 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
769 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
770 p = reserve_space(xdr, 4 + hdr->taglen + 8);
771 p = xdr_encode_opaque(p, hdr->tag, hdr->taglen);
772 *p++ = cpu_to_be32(hdr->minorversion);
774 *p = cpu_to_be32(hdr->nops);
777 static void encode_nops(struct compound_hdr *hdr)
779 BUG_ON(hdr->nops > NFS4_MAX_OPS);
780 *hdr->nops_p = htonl(hdr->nops);
783 static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
787 p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
789 xdr_encode_opaque_fixed(p, verf->data, NFS4_VERIFIER_SIZE);
792 static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server)
794 char owner_name[IDMAP_NAMESZ];
795 char owner_group[IDMAP_NAMESZ];
796 int owner_namelen = 0;
797 int owner_grouplen = 0;
805 * We reserve enough space to write the entire attribute buffer at once.
806 * In the worst-case, this would be
807 * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime)
808 * = 36 bytes, plus any contribution from variable-length fields
809 * such as owner/group.
814 if (iap->ia_valid & ATTR_SIZE)
816 if (iap->ia_valid & ATTR_MODE)
818 if (iap->ia_valid & ATTR_UID) {
819 owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name, IDMAP_NAMESZ);
820 if (owner_namelen < 0) {
821 dprintk("nfs: couldn't resolve uid %d to string\n",
824 strcpy(owner_name, "nobody");
825 owner_namelen = sizeof("nobody") - 1;
828 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
830 if (iap->ia_valid & ATTR_GID) {
831 owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group, IDMAP_NAMESZ);
832 if (owner_grouplen < 0) {
833 dprintk("nfs: couldn't resolve gid %d to string\n",
835 strcpy(owner_group, "nobody");
836 owner_grouplen = sizeof("nobody") - 1;
839 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
841 if (iap->ia_valid & ATTR_ATIME_SET)
843 else if (iap->ia_valid & ATTR_ATIME)
845 if (iap->ia_valid & ATTR_MTIME_SET)
847 else if (iap->ia_valid & ATTR_MTIME)
849 p = reserve_space(xdr, len);
852 * We write the bitmap length now, but leave the bitmap and the attribute
853 * buffer length to be backfilled at the end of this routine.
855 *p++ = cpu_to_be32(2);
859 if (iap->ia_valid & ATTR_SIZE) {
860 bmval0 |= FATTR4_WORD0_SIZE;
861 p = xdr_encode_hyper(p, iap->ia_size);
863 if (iap->ia_valid & ATTR_MODE) {
864 bmval1 |= FATTR4_WORD1_MODE;
865 *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
867 if (iap->ia_valid & ATTR_UID) {
868 bmval1 |= FATTR4_WORD1_OWNER;
869 p = xdr_encode_opaque(p, owner_name, owner_namelen);
871 if (iap->ia_valid & ATTR_GID) {
872 bmval1 |= FATTR4_WORD1_OWNER_GROUP;
873 p = xdr_encode_opaque(p, owner_group, owner_grouplen);
875 if (iap->ia_valid & ATTR_ATIME_SET) {
876 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
877 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
878 *p++ = cpu_to_be32(0);
879 *p++ = cpu_to_be32(iap->ia_atime.tv_sec);
880 *p++ = cpu_to_be32(iap->ia_atime.tv_nsec);
882 else if (iap->ia_valid & ATTR_ATIME) {
883 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
884 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
886 if (iap->ia_valid & ATTR_MTIME_SET) {
887 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
888 *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
889 *p++ = cpu_to_be32(0);
890 *p++ = cpu_to_be32(iap->ia_mtime.tv_sec);
891 *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec);
893 else if (iap->ia_valid & ATTR_MTIME) {
894 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
895 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
899 * Now we backfill the bitmap and the attribute buffer length.
901 if (len != ((char *)p - (char *)q) + 4) {
902 printk(KERN_ERR "nfs: Attr length error, %u != %Zu\n",
903 len, ((char *)p - (char *)q) + 4);
906 len = (char *)p - (char *)q - 12;
907 *q++ = htonl(bmval0);
908 *q++ = htonl(bmval1);
914 static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
918 p = reserve_space(xdr, 8);
919 *p++ = cpu_to_be32(OP_ACCESS);
920 *p = cpu_to_be32(access);
922 hdr->replen += decode_access_maxsz;
925 static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
929 p = reserve_space(xdr, 8+NFS4_STATEID_SIZE);
930 *p++ = cpu_to_be32(OP_CLOSE);
931 *p++ = cpu_to_be32(arg->seqid->sequence->counter);
932 xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
934 hdr->replen += decode_close_maxsz;
937 static void encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr)
941 p = reserve_space(xdr, 16);
942 *p++ = cpu_to_be32(OP_COMMIT);
943 p = xdr_encode_hyper(p, args->offset);
944 *p = cpu_to_be32(args->count);
946 hdr->replen += decode_commit_maxsz;
949 static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
953 p = reserve_space(xdr, 8);
954 *p++ = cpu_to_be32(OP_CREATE);
955 *p = cpu_to_be32(create->ftype);
957 switch (create->ftype) {
959 p = reserve_space(xdr, 4);
960 *p = cpu_to_be32(create->u.symlink.len);
961 xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len);
964 case NF4BLK: case NF4CHR:
965 p = reserve_space(xdr, 8);
966 *p++ = cpu_to_be32(create->u.device.specdata1);
967 *p = cpu_to_be32(create->u.device.specdata2);
974 encode_string(xdr, create->name->len, create->name->name);
976 hdr->replen += decode_create_maxsz;
978 encode_attrs(xdr, create->attrs, create->server);
981 static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr)
985 p = reserve_space(xdr, 12);
986 *p++ = cpu_to_be32(OP_GETATTR);
987 *p++ = cpu_to_be32(1);
988 *p = cpu_to_be32(bitmap);
990 hdr->replen += decode_getattr_maxsz;
993 static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1, struct compound_hdr *hdr)
997 p = reserve_space(xdr, 16);
998 *p++ = cpu_to_be32(OP_GETATTR);
999 *p++ = cpu_to_be32(2);
1000 *p++ = cpu_to_be32(bm0);
1001 *p = cpu_to_be32(bm1);
1003 hdr->replen += decode_getattr_maxsz;
1006 static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1008 encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0],
1009 bitmask[1] & nfs4_fattr_bitmap[1], hdr);
1012 static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1014 encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0],
1015 bitmask[1] & nfs4_fsinfo_bitmap[1], hdr);
1018 static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
1020 encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0],
1021 bitmask[1] & nfs4_fs_locations_bitmap[1], hdr);
1024 static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1028 p = reserve_space(xdr, 4);
1029 *p = cpu_to_be32(OP_GETFH);
1031 hdr->replen += decode_getfh_maxsz;
1034 static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1038 p = reserve_space(xdr, 8 + name->len);
1039 *p++ = cpu_to_be32(OP_LINK);
1040 xdr_encode_opaque(p, name->name, name->len);
1042 hdr->replen += decode_link_maxsz;
1045 static inline int nfs4_lock_type(struct file_lock *fl, int block)
1047 if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK)
1048 return block ? NFS4_READW_LT : NFS4_READ_LT;
1049 return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
1052 static inline uint64_t nfs4_lock_length(struct file_lock *fl)
1054 if (fl->fl_end == OFFSET_MAX)
1055 return ~(uint64_t)0;
1056 return fl->fl_end - fl->fl_start + 1;
1059 static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner)
1063 p = reserve_space(xdr, 28);
1064 p = xdr_encode_hyper(p, lowner->clientid);
1065 *p++ = cpu_to_be32(16);
1066 p = xdr_encode_opaque_fixed(p, "lock id:", 8);
1067 xdr_encode_hyper(p, lowner->id);
1071 * opcode,type,reclaim,offset,length,new_lock_owner = 32
1072 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
1074 static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
1078 p = reserve_space(xdr, 32);
1079 *p++ = cpu_to_be32(OP_LOCK);
1080 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
1081 *p++ = cpu_to_be32(args->reclaim);
1082 p = xdr_encode_hyper(p, args->fl->fl_start);
1083 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1084 *p = cpu_to_be32(args->new_lock_owner);
1085 if (args->new_lock_owner){
1086 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
1087 *p++ = cpu_to_be32(args->open_seqid->sequence->counter);
1088 p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE);
1089 *p++ = cpu_to_be32(args->lock_seqid->sequence->counter);
1090 encode_lockowner(xdr, &args->lock_owner);
1093 p = reserve_space(xdr, NFS4_STATEID_SIZE+4);
1094 p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE);
1095 *p = cpu_to_be32(args->lock_seqid->sequence->counter);
1098 hdr->replen += decode_lock_maxsz;
1101 static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
1105 p = reserve_space(xdr, 24);
1106 *p++ = cpu_to_be32(OP_LOCKT);
1107 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1108 p = xdr_encode_hyper(p, args->fl->fl_start);
1109 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1110 encode_lockowner(xdr, &args->lock_owner);
1112 hdr->replen += decode_lockt_maxsz;
1115 static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
1119 p = reserve_space(xdr, 12+NFS4_STATEID_SIZE+16);
1120 *p++ = cpu_to_be32(OP_LOCKU);
1121 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1122 *p++ = cpu_to_be32(args->seqid->sequence->counter);
1123 p = xdr_encode_opaque_fixed(p, args->stateid->data, NFS4_STATEID_SIZE);
1124 p = xdr_encode_hyper(p, args->fl->fl_start);
1125 xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1127 hdr->replen += decode_locku_maxsz;
1130 static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
1134 p = reserve_space(xdr, 4);
1135 *p = cpu_to_be32(OP_RELEASE_LOCKOWNER);
1136 encode_lockowner(xdr, lowner);
1138 hdr->replen += decode_release_lockowner_maxsz;
1141 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1143 int len = name->len;
1146 p = reserve_space(xdr, 8 + len);
1147 *p++ = cpu_to_be32(OP_LOOKUP);
1148 xdr_encode_opaque(p, name->name, len);
1150 hdr->replen += decode_lookup_maxsz;
1153 static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
1157 p = reserve_space(xdr, 8);
1158 switch (fmode & (FMODE_READ|FMODE_WRITE)) {
1160 *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ);
1163 *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE);
1165 case FMODE_READ|FMODE_WRITE:
1166 *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH);
1169 *p++ = cpu_to_be32(0);
1171 *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */
1174 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1178 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1181 p = reserve_space(xdr, 8);
1182 *p++ = cpu_to_be32(OP_OPEN);
1183 *p = cpu_to_be32(arg->seqid->sequence->counter);
1184 encode_share_access(xdr, arg->fmode);
1185 p = reserve_space(xdr, 28);
1186 p = xdr_encode_hyper(p, arg->clientid);
1187 *p++ = cpu_to_be32(16);
1188 p = xdr_encode_opaque_fixed(p, "open id:", 8);
1189 xdr_encode_hyper(p, arg->id);
1192 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1195 struct nfs_client *clp;
1197 p = reserve_space(xdr, 4);
1198 switch(arg->open_flags & O_EXCL) {
1200 *p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
1201 encode_attrs(xdr, arg->u.attrs, arg->server);
1204 clp = arg->server->nfs_client;
1205 if (clp->cl_mvops->minor_version > 0) {
1206 if (nfs4_has_persistent_session(clp)) {
1207 *p = cpu_to_be32(NFS4_CREATE_GUARDED);
1208 encode_attrs(xdr, arg->u.attrs, arg->server);
1212 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
1213 encode_nfs4_verifier(xdr, &arg->u.verifier);
1215 encode_attrs(xdr, &dummy, arg->server);
1218 *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
1219 encode_nfs4_verifier(xdr, &arg->u.verifier);
1224 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1228 p = reserve_space(xdr, 4);
1229 switch (arg->open_flags & O_CREAT) {
1231 *p = cpu_to_be32(NFS4_OPEN_NOCREATE);
1234 BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL);
1235 *p = cpu_to_be32(NFS4_OPEN_CREATE);
1236 encode_createmode(xdr, arg);
1240 static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
1244 p = reserve_space(xdr, 4);
1245 switch (delegation_type) {
1247 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
1250 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ);
1252 case FMODE_WRITE|FMODE_READ:
1253 *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE);
1260 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
1264 p = reserve_space(xdr, 4);
1265 *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
1266 encode_string(xdr, name->len, name->name);
1269 static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1273 p = reserve_space(xdr, 4);
1274 *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
1275 encode_delegation_type(xdr, type);
1278 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
1282 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1283 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1284 xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
1285 encode_string(xdr, name->len, name->name);
1288 static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
1290 encode_openhdr(xdr, arg);
1291 encode_opentype(xdr, arg);
1292 switch (arg->claim) {
1293 case NFS4_OPEN_CLAIM_NULL:
1294 encode_claim_null(xdr, arg->name);
1296 case NFS4_OPEN_CLAIM_PREVIOUS:
1297 encode_claim_previous(xdr, arg->u.delegation_type);
1299 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
1300 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
1306 hdr->replen += decode_open_maxsz;
1309 static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
1313 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
1314 *p++ = cpu_to_be32(OP_OPEN_CONFIRM);
1315 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
1316 *p = cpu_to_be32(arg->seqid->sequence->counter);
1318 hdr->replen += decode_open_confirm_maxsz;
1321 static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1325 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
1326 *p++ = cpu_to_be32(OP_OPEN_DOWNGRADE);
1327 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
1328 *p = cpu_to_be32(arg->seqid->sequence->counter);
1329 encode_share_access(xdr, arg->fmode);
1331 hdr->replen += decode_open_downgrade_maxsz;
1335 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1340 p = reserve_space(xdr, 8 + len);
1341 *p++ = cpu_to_be32(OP_PUTFH);
1342 xdr_encode_opaque(p, fh->data, len);
1344 hdr->replen += decode_putfh_maxsz;
1347 static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1351 p = reserve_space(xdr, 4);
1352 *p = cpu_to_be32(OP_PUTROOTFH);
1354 hdr->replen += decode_putrootfh_maxsz;
1357 static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx)
1359 nfs4_stateid stateid;
1362 p = reserve_space(xdr, NFS4_STATEID_SIZE);
1363 if (ctx->state != NULL) {
1364 nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid);
1365 xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE);
1367 xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE);
1370 static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr)
1374 p = reserve_space(xdr, 4);
1375 *p = cpu_to_be32(OP_READ);
1377 encode_stateid(xdr, args->context, args->lock_context);
1379 p = reserve_space(xdr, 12);
1380 p = xdr_encode_hyper(p, args->offset);
1381 *p = cpu_to_be32(args->count);
1383 hdr->replen += decode_read_maxsz;
1386 static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
1388 uint32_t attrs[2] = {0, 0};
1391 if (readdir->plus) {
1392 attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
1393 FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE;
1394 attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
1395 FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
1396 FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
1397 FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
1399 attrs[0] |= FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID;
1400 attrs[1] |= FATTR4_WORD1_MOUNTED_ON_FILEID;
1402 p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20);
1403 *p++ = cpu_to_be32(OP_READDIR);
1404 p = xdr_encode_hyper(p, readdir->cookie);
1405 p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE);
1406 *p++ = cpu_to_be32(readdir->count >> 1); /* We're not doing readdirplus */
1407 *p++ = cpu_to_be32(readdir->count);
1408 *p++ = cpu_to_be32(2);
1410 if (!readdir->plus) {
1411 /* Switch to mounted_on_fileid if the server supports it */
1412 if (readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
1413 attrs[0] &= ~FATTR4_WORD0_FILEID;
1415 attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
1418 *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]);
1419 *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]);
1421 hdr->replen += decode_readdir_maxsz;
1422 dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n",
1424 (unsigned long long)readdir->cookie,
1425 ((u32 *)readdir->verifier.data)[0],
1426 ((u32 *)readdir->verifier.data)[1],
1427 attrs[0] & readdir->bitmask[0],
1428 attrs[1] & readdir->bitmask[1]);
1431 static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
1435 p = reserve_space(xdr, 4);
1436 *p = cpu_to_be32(OP_READLINK);
1438 hdr->replen += decode_readlink_maxsz;
1441 static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1445 p = reserve_space(xdr, 8 + name->len);
1446 *p++ = cpu_to_be32(OP_REMOVE);
1447 xdr_encode_opaque(p, name->name, name->len);
1449 hdr->replen += decode_remove_maxsz;
1452 static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
1456 p = reserve_space(xdr, 4);
1457 *p = cpu_to_be32(OP_RENAME);
1458 encode_string(xdr, oldname->len, oldname->name);
1459 encode_string(xdr, newname->len, newname->name);
1461 hdr->replen += decode_rename_maxsz;
1464 static void encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid, struct compound_hdr *hdr)
1468 p = reserve_space(xdr, 12);
1469 *p++ = cpu_to_be32(OP_RENEW);
1470 xdr_encode_hyper(p, client_stateid->cl_clientid);
1472 hdr->replen += decode_renew_maxsz;
1476 encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1480 p = reserve_space(xdr, 4);
1481 *p = cpu_to_be32(OP_RESTOREFH);
1483 hdr->replen += decode_restorefh_maxsz;
1487 encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr)
1491 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1492 *p++ = cpu_to_be32(OP_SETATTR);
1493 xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE);
1494 p = reserve_space(xdr, 2*4);
1495 *p++ = cpu_to_be32(1);
1496 *p = cpu_to_be32(FATTR4_WORD0_ACL);
1497 if (arg->acl_len % 4)
1499 p = reserve_space(xdr, 4);
1500 *p = cpu_to_be32(arg->acl_len);
1501 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1503 hdr->replen += decode_setacl_maxsz;
1508 encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1512 p = reserve_space(xdr, 4);
1513 *p = cpu_to_be32(OP_SAVEFH);
1515 hdr->replen += decode_savefh_maxsz;
1518 static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
1522 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1523 *p++ = cpu_to_be32(OP_SETATTR);
1524 xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE);
1526 hdr->replen += decode_setattr_maxsz;
1527 encode_attrs(xdr, arg->iap, server);
1530 static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
1534 p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE);
1535 *p++ = cpu_to_be32(OP_SETCLIENTID);
1536 xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
1538 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1539 p = reserve_space(xdr, 4);
1540 *p = cpu_to_be32(setclientid->sc_prog);
1541 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1542 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1543 p = reserve_space(xdr, 4);
1544 *p = cpu_to_be32(setclientid->sc_cb_ident);
1546 hdr->replen += decode_setclientid_maxsz;
1549 static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
1553 p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE);
1554 *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM);
1555 p = xdr_encode_hyper(p, arg->clientid);
1556 xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE);
1558 hdr->replen += decode_setclientid_confirm_maxsz;
1561 static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr)
1565 p = reserve_space(xdr, 4);
1566 *p = cpu_to_be32(OP_WRITE);
1568 encode_stateid(xdr, args->context, args->lock_context);
1570 p = reserve_space(xdr, 16);
1571 p = xdr_encode_hyper(p, args->offset);
1572 *p++ = cpu_to_be32(args->stable);
1573 *p = cpu_to_be32(args->count);
1575 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1577 hdr->replen += decode_write_maxsz;
1580 static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
1584 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1586 *p++ = cpu_to_be32(OP_DELEGRETURN);
1587 xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
1589 hdr->replen += decode_delegreturn_maxsz;
1592 #if defined(CONFIG_NFS_V4_1)
1593 /* NFSv4.1 operations */
1594 static void encode_exchange_id(struct xdr_stream *xdr,
1595 struct nfs41_exchange_id_args *args,
1596 struct compound_hdr *hdr)
1600 p = reserve_space(xdr, 4 + sizeof(args->verifier->data));
1601 *p++ = cpu_to_be32(OP_EXCHANGE_ID);
1602 xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data));
1604 encode_string(xdr, args->id_len, args->id);
1606 p = reserve_space(xdr, 12);
1607 *p++ = cpu_to_be32(args->flags);
1608 *p++ = cpu_to_be32(0); /* zero length state_protect4_a */
1609 *p = cpu_to_be32(0); /* zero length implementation id array */
1611 hdr->replen += decode_exchange_id_maxsz;
1614 static void encode_create_session(struct xdr_stream *xdr,
1615 struct nfs41_create_session_args *args,
1616 struct compound_hdr *hdr)
1619 char machine_name[NFS4_MAX_MACHINE_NAME_LEN];
1621 struct nfs_client *clp = args->client;
1622 u32 max_resp_sz_cached;
1625 * Assumes OPEN is the biggest non-idempotent compound.
1626 * 2 is the verifier.
1628 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE +
1629 RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT;
1631 len = scnprintf(machine_name, sizeof(machine_name), "%s",
1634 p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12);
1635 *p++ = cpu_to_be32(OP_CREATE_SESSION);
1636 p = xdr_encode_hyper(p, clp->cl_ex_clid);
1637 *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */
1638 *p++ = cpu_to_be32(args->flags); /*flags */
1641 *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */
1642 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */
1643 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */
1644 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */
1645 *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */
1646 *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */
1647 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1650 *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */
1651 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */
1652 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */
1653 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */
1654 *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */
1655 *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */
1656 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1658 *p++ = cpu_to_be32(args->cb_program); /* cb_program */
1659 *p++ = cpu_to_be32(1);
1660 *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
1662 /* authsys_parms rfc1831 */
1663 *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */
1664 p = xdr_encode_opaque(p, machine_name, len);
1665 *p++ = cpu_to_be32(0); /* UID */
1666 *p++ = cpu_to_be32(0); /* GID */
1667 *p = cpu_to_be32(0); /* No more gids */
1669 hdr->replen += decode_create_session_maxsz;
1672 static void encode_destroy_session(struct xdr_stream *xdr,
1673 struct nfs4_session *session,
1674 struct compound_hdr *hdr)
1677 p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN);
1678 *p++ = cpu_to_be32(OP_DESTROY_SESSION);
1679 xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1681 hdr->replen += decode_destroy_session_maxsz;
1684 static void encode_reclaim_complete(struct xdr_stream *xdr,
1685 struct nfs41_reclaim_complete_args *args,
1686 struct compound_hdr *hdr)
1690 p = reserve_space(xdr, 8);
1691 *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE);
1692 *p++ = cpu_to_be32(args->one_fs);
1694 hdr->replen += decode_reclaim_complete_maxsz;
1696 #endif /* CONFIG_NFS_V4_1 */
1698 static void encode_sequence(struct xdr_stream *xdr,
1699 const struct nfs4_sequence_args *args,
1700 struct compound_hdr *hdr)
1702 #if defined(CONFIG_NFS_V4_1)
1703 struct nfs4_session *session = args->sa_session;
1704 struct nfs4_slot_table *tp;
1705 struct nfs4_slot *slot;
1711 tp = &session->fc_slot_table;
1713 WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE);
1714 slot = tp->slots + args->sa_slotid;
1716 p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16);
1717 *p++ = cpu_to_be32(OP_SEQUENCE);
1720 * Sessionid + seqid + slotid + max slotid + cache_this
1722 dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
1723 "max_slotid=%d cache_this=%d\n",
1725 ((u32 *)session->sess_id.data)[0],
1726 ((u32 *)session->sess_id.data)[1],
1727 ((u32 *)session->sess_id.data)[2],
1728 ((u32 *)session->sess_id.data)[3],
1729 slot->seq_nr, args->sa_slotid,
1730 tp->highest_used_slotid, args->sa_cache_this);
1731 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1732 *p++ = cpu_to_be32(slot->seq_nr);
1733 *p++ = cpu_to_be32(args->sa_slotid);
1734 *p++ = cpu_to_be32(tp->highest_used_slotid);
1735 *p = cpu_to_be32(args->sa_cache_this);
1737 hdr->replen += decode_sequence_maxsz;
1738 #endif /* CONFIG_NFS_V4_1 */
1742 * END OF "GENERIC" ENCODE ROUTINES.
1745 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
1747 #if defined(CONFIG_NFS_V4_1)
1748 if (args->sa_session)
1749 return args->sa_session->clp->cl_mvops->minor_version;
1750 #endif /* CONFIG_NFS_V4_1 */
1755 * Encode an ACCESS request
1757 static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args)
1759 struct xdr_stream xdr;
1760 struct compound_hdr hdr = {
1761 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1764 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1765 encode_compound_hdr(&xdr, req, &hdr);
1766 encode_sequence(&xdr, &args->seq_args, &hdr);
1767 encode_putfh(&xdr, args->fh, &hdr);
1768 encode_access(&xdr, args->access, &hdr);
1769 encode_getfattr(&xdr, args->bitmask, &hdr);
1775 * Encode LOOKUP request
1777 static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args)
1779 struct xdr_stream xdr;
1780 struct compound_hdr hdr = {
1781 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1784 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1785 encode_compound_hdr(&xdr, req, &hdr);
1786 encode_sequence(&xdr, &args->seq_args, &hdr);
1787 encode_putfh(&xdr, args->dir_fh, &hdr);
1788 encode_lookup(&xdr, args->name, &hdr);
1789 encode_getfh(&xdr, &hdr);
1790 encode_getfattr(&xdr, args->bitmask, &hdr);
1796 * Encode LOOKUP_ROOT request
1798 static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args)
1800 struct xdr_stream xdr;
1801 struct compound_hdr hdr = {
1802 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1805 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1806 encode_compound_hdr(&xdr, req, &hdr);
1807 encode_sequence(&xdr, &args->seq_args, &hdr);
1808 encode_putrootfh(&xdr, &hdr);
1809 encode_getfh(&xdr, &hdr);
1810 encode_getfattr(&xdr, args->bitmask, &hdr);
1816 * Encode REMOVE request
1818 static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
1820 struct xdr_stream xdr;
1821 struct compound_hdr hdr = {
1822 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1825 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1826 encode_compound_hdr(&xdr, req, &hdr);
1827 encode_sequence(&xdr, &args->seq_args, &hdr);
1828 encode_putfh(&xdr, args->fh, &hdr);
1829 encode_remove(&xdr, &args->name, &hdr);
1830 encode_getfattr(&xdr, args->bitmask, &hdr);
1836 * Encode RENAME request
1838 static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs_renameargs *args)
1840 struct xdr_stream xdr;
1841 struct compound_hdr hdr = {
1842 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1845 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1846 encode_compound_hdr(&xdr, req, &hdr);
1847 encode_sequence(&xdr, &args->seq_args, &hdr);
1848 encode_putfh(&xdr, args->old_dir, &hdr);
1849 encode_savefh(&xdr, &hdr);
1850 encode_putfh(&xdr, args->new_dir, &hdr);
1851 encode_rename(&xdr, args->old_name, args->new_name, &hdr);
1852 encode_getfattr(&xdr, args->bitmask, &hdr);
1853 encode_restorefh(&xdr, &hdr);
1854 encode_getfattr(&xdr, args->bitmask, &hdr);
1860 * Encode LINK request
1862 static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args)
1864 struct xdr_stream xdr;
1865 struct compound_hdr hdr = {
1866 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1869 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1870 encode_compound_hdr(&xdr, req, &hdr);
1871 encode_sequence(&xdr, &args->seq_args, &hdr);
1872 encode_putfh(&xdr, args->fh, &hdr);
1873 encode_savefh(&xdr, &hdr);
1874 encode_putfh(&xdr, args->dir_fh, &hdr);
1875 encode_link(&xdr, args->name, &hdr);
1876 encode_getfattr(&xdr, args->bitmask, &hdr);
1877 encode_restorefh(&xdr, &hdr);
1878 encode_getfattr(&xdr, args->bitmask, &hdr);
1884 * Encode CREATE request
1886 static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1888 struct xdr_stream xdr;
1889 struct compound_hdr hdr = {
1890 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1893 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1894 encode_compound_hdr(&xdr, req, &hdr);
1895 encode_sequence(&xdr, &args->seq_args, &hdr);
1896 encode_putfh(&xdr, args->dir_fh, &hdr);
1897 encode_savefh(&xdr, &hdr);
1898 encode_create(&xdr, args, &hdr);
1899 encode_getfh(&xdr, &hdr);
1900 encode_getfattr(&xdr, args->bitmask, &hdr);
1901 encode_restorefh(&xdr, &hdr);
1902 encode_getfattr(&xdr, args->bitmask, &hdr);
1908 * Encode SYMLINK request
1910 static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1912 return nfs4_xdr_enc_create(req, p, args);
1916 * Encode GETATTR request
1918 static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args)
1920 struct xdr_stream xdr;
1921 struct compound_hdr hdr = {
1922 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1925 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1926 encode_compound_hdr(&xdr, req, &hdr);
1927 encode_sequence(&xdr, &args->seq_args, &hdr);
1928 encode_putfh(&xdr, args->fh, &hdr);
1929 encode_getfattr(&xdr, args->bitmask, &hdr);
1935 * Encode a CLOSE request
1937 static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
1939 struct xdr_stream xdr;
1940 struct compound_hdr hdr = {
1941 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1944 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1945 encode_compound_hdr(&xdr, req, &hdr);
1946 encode_sequence(&xdr, &args->seq_args, &hdr);
1947 encode_putfh(&xdr, args->fh, &hdr);
1948 encode_close(&xdr, args, &hdr);
1949 encode_getfattr(&xdr, args->bitmask, &hdr);
1955 * Encode an OPEN request
1957 static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
1959 struct xdr_stream xdr;
1960 struct compound_hdr hdr = {
1961 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1964 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1965 encode_compound_hdr(&xdr, req, &hdr);
1966 encode_sequence(&xdr, &args->seq_args, &hdr);
1967 encode_putfh(&xdr, args->fh, &hdr);
1968 encode_savefh(&xdr, &hdr);
1969 encode_open(&xdr, args, &hdr);
1970 encode_getfh(&xdr, &hdr);
1971 encode_getfattr(&xdr, args->bitmask, &hdr);
1972 encode_restorefh(&xdr, &hdr);
1973 encode_getfattr(&xdr, args->bitmask, &hdr);
1979 * Encode an OPEN_CONFIRM request
1981 static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args)
1983 struct xdr_stream xdr;
1984 struct compound_hdr hdr = {
1988 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1989 encode_compound_hdr(&xdr, req, &hdr);
1990 encode_putfh(&xdr, args->fh, &hdr);
1991 encode_open_confirm(&xdr, args, &hdr);
1997 * Encode an OPEN request with no attributes.
1999 static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
2001 struct xdr_stream xdr;
2002 struct compound_hdr hdr = {
2003 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2006 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2007 encode_compound_hdr(&xdr, req, &hdr);
2008 encode_sequence(&xdr, &args->seq_args, &hdr);
2009 encode_putfh(&xdr, args->fh, &hdr);
2010 encode_open(&xdr, args, &hdr);
2011 encode_getfattr(&xdr, args->bitmask, &hdr);
2017 * Encode an OPEN_DOWNGRADE request
2019 static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
2021 struct xdr_stream xdr;
2022 struct compound_hdr hdr = {
2023 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2026 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2027 encode_compound_hdr(&xdr, req, &hdr);
2028 encode_sequence(&xdr, &args->seq_args, &hdr);
2029 encode_putfh(&xdr, args->fh, &hdr);
2030 encode_open_downgrade(&xdr, args, &hdr);
2031 encode_getfattr(&xdr, args->bitmask, &hdr);
2037 * Encode a LOCK request
2039 static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args)
2041 struct xdr_stream xdr;
2042 struct compound_hdr hdr = {
2043 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2046 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2047 encode_compound_hdr(&xdr, req, &hdr);
2048 encode_sequence(&xdr, &args->seq_args, &hdr);
2049 encode_putfh(&xdr, args->fh, &hdr);
2050 encode_lock(&xdr, args, &hdr);
2056 * Encode a LOCKT request
2058 static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args)
2060 struct xdr_stream xdr;
2061 struct compound_hdr hdr = {
2062 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2065 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2066 encode_compound_hdr(&xdr, req, &hdr);
2067 encode_sequence(&xdr, &args->seq_args, &hdr);
2068 encode_putfh(&xdr, args->fh, &hdr);
2069 encode_lockt(&xdr, args, &hdr);
2075 * Encode a LOCKU request
2077 static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args)
2079 struct xdr_stream xdr;
2080 struct compound_hdr hdr = {
2081 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2084 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2085 encode_compound_hdr(&xdr, req, &hdr);
2086 encode_sequence(&xdr, &args->seq_args, &hdr);
2087 encode_putfh(&xdr, args->fh, &hdr);
2088 encode_locku(&xdr, args, &hdr);
2093 static int nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, __be32 *p, struct nfs_release_lockowner_args *args)
2095 struct xdr_stream xdr;
2096 struct compound_hdr hdr = {
2100 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2101 encode_compound_hdr(&xdr, req, &hdr);
2102 encode_release_lockowner(&xdr, &args->lock_owner, &hdr);
2108 * Encode a READLINK request
2110 static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args)
2112 struct xdr_stream xdr;
2113 struct compound_hdr hdr = {
2114 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2117 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2118 encode_compound_hdr(&xdr, req, &hdr);
2119 encode_sequence(&xdr, &args->seq_args, &hdr);
2120 encode_putfh(&xdr, args->fh, &hdr);
2121 encode_readlink(&xdr, args, req, &hdr);
2123 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2124 args->pgbase, args->pglen);
2130 * Encode a READDIR request
2132 static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args)
2134 struct xdr_stream xdr;
2135 struct compound_hdr hdr = {
2136 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2139 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2140 encode_compound_hdr(&xdr, req, &hdr);
2141 encode_sequence(&xdr, &args->seq_args, &hdr);
2142 encode_putfh(&xdr, args->fh, &hdr);
2143 encode_readdir(&xdr, args, req, &hdr);
2145 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2146 args->pgbase, args->count);
2147 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
2148 __func__, hdr.replen << 2, args->pages,
2149 args->pgbase, args->count);
2155 * Encode a READ request
2157 static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
2159 struct xdr_stream xdr;
2160 struct compound_hdr hdr = {
2161 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2164 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2165 encode_compound_hdr(&xdr, req, &hdr);
2166 encode_sequence(&xdr, &args->seq_args, &hdr);
2167 encode_putfh(&xdr, args->fh, &hdr);
2168 encode_read(&xdr, args, &hdr);
2170 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
2171 args->pages, args->pgbase, args->count);
2172 req->rq_rcv_buf.flags |= XDRBUF_READ;
2178 * Encode an SETATTR request
2180 static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args)
2182 struct xdr_stream xdr;
2183 struct compound_hdr hdr = {
2184 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2187 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2188 encode_compound_hdr(&xdr, req, &hdr);
2189 encode_sequence(&xdr, &args->seq_args, &hdr);
2190 encode_putfh(&xdr, args->fh, &hdr);
2191 encode_setattr(&xdr, args, args->server, &hdr);
2192 encode_getfattr(&xdr, args->bitmask, &hdr);
2198 * Encode a GETACL request
2201 nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
2202 struct nfs_getaclargs *args)
2204 struct xdr_stream xdr;
2205 struct compound_hdr hdr = {
2206 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2210 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2211 encode_compound_hdr(&xdr, req, &hdr);
2212 encode_sequence(&xdr, &args->seq_args, &hdr);
2213 encode_putfh(&xdr, args->fh, &hdr);
2214 replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1;
2215 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr);
2217 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2218 args->acl_pages, args->acl_pgbase, args->acl_len);
2224 * Encode a WRITE request
2226 static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
2228 struct xdr_stream xdr;
2229 struct compound_hdr hdr = {
2230 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2233 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2234 encode_compound_hdr(&xdr, req, &hdr);
2235 encode_sequence(&xdr, &args->seq_args, &hdr);
2236 encode_putfh(&xdr, args->fh, &hdr);
2237 encode_write(&xdr, args, &hdr);
2238 req->rq_snd_buf.flags |= XDRBUF_WRITE;
2239 encode_getfattr(&xdr, args->bitmask, &hdr);
2247 static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
2249 struct xdr_stream xdr;
2250 struct compound_hdr hdr = {
2251 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2254 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2255 encode_compound_hdr(&xdr, req, &hdr);
2256 encode_sequence(&xdr, &args->seq_args, &hdr);
2257 encode_putfh(&xdr, args->fh, &hdr);
2258 encode_commit(&xdr, args, &hdr);
2259 encode_getfattr(&xdr, args->bitmask, &hdr);
2267 static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args)
2269 struct xdr_stream xdr;
2270 struct compound_hdr hdr = {
2271 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2274 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2275 encode_compound_hdr(&xdr, req, &hdr);
2276 encode_sequence(&xdr, &args->seq_args, &hdr);
2277 encode_putfh(&xdr, args->fh, &hdr);
2278 encode_fsinfo(&xdr, args->bitmask, &hdr);
2284 * a PATHCONF request
2286 static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args)
2288 struct xdr_stream xdr;
2289 struct compound_hdr hdr = {
2290 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2293 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2294 encode_compound_hdr(&xdr, req, &hdr);
2295 encode_sequence(&xdr, &args->seq_args, &hdr);
2296 encode_putfh(&xdr, args->fh, &hdr);
2297 encode_getattr_one(&xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0],
2306 static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args)
2308 struct xdr_stream xdr;
2309 struct compound_hdr hdr = {
2310 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2313 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2314 encode_compound_hdr(&xdr, req, &hdr);
2315 encode_sequence(&xdr, &args->seq_args, &hdr);
2316 encode_putfh(&xdr, args->fh, &hdr);
2317 encode_getattr_two(&xdr, args->bitmask[0] & nfs4_statfs_bitmap[0],
2318 args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr);
2324 * GETATTR_BITMAP request
2326 static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p,
2327 struct nfs4_server_caps_arg *args)
2329 struct xdr_stream xdr;
2330 struct compound_hdr hdr = {
2331 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2334 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2335 encode_compound_hdr(&xdr, req, &hdr);
2336 encode_sequence(&xdr, &args->seq_args, &hdr);
2337 encode_putfh(&xdr, args->fhandle, &hdr);
2338 encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS|
2339 FATTR4_WORD0_LINK_SUPPORT|
2340 FATTR4_WORD0_SYMLINK_SUPPORT|
2341 FATTR4_WORD0_ACLSUPPORT, &hdr);
2349 static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)
2351 struct xdr_stream xdr;
2352 struct compound_hdr hdr = {
2356 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2357 encode_compound_hdr(&xdr, req, &hdr);
2358 encode_renew(&xdr, clp, &hdr);
2364 * a SETCLIENTID request
2366 static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc)
2368 struct xdr_stream xdr;
2369 struct compound_hdr hdr = {
2373 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2374 encode_compound_hdr(&xdr, req, &hdr);
2375 encode_setclientid(&xdr, sc, &hdr);
2381 * a SETCLIENTID_CONFIRM request
2383 static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg)
2385 struct xdr_stream xdr;
2386 struct compound_hdr hdr = {
2389 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
2391 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2392 encode_compound_hdr(&xdr, req, &hdr);
2393 encode_setclientid_confirm(&xdr, arg, &hdr);
2394 encode_putrootfh(&xdr, &hdr);
2395 encode_fsinfo(&xdr, lease_bitmap, &hdr);
2401 * DELEGRETURN request
2403 static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args)
2405 struct xdr_stream xdr;
2406 struct compound_hdr hdr = {
2407 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2410 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2411 encode_compound_hdr(&xdr, req, &hdr);
2412 encode_sequence(&xdr, &args->seq_args, &hdr);
2413 encode_putfh(&xdr, args->fhandle, &hdr);
2414 encode_delegreturn(&xdr, args->stateid, &hdr);
2415 encode_getfattr(&xdr, args->bitmask, &hdr);
2421 * Encode FS_LOCATIONS request
2423 static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args)
2425 struct xdr_stream xdr;
2426 struct compound_hdr hdr = {
2427 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2431 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2432 encode_compound_hdr(&xdr, req, &hdr);
2433 encode_sequence(&xdr, &args->seq_args, &hdr);
2434 encode_putfh(&xdr, args->dir_fh, &hdr);
2435 encode_lookup(&xdr, args->name, &hdr);
2436 replen = hdr.replen; /* get the attribute into args->page */
2437 encode_fs_locations(&xdr, args->bitmask, &hdr);
2439 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page,
2445 #if defined(CONFIG_NFS_V4_1)
2447 * EXCHANGE_ID request
2449 static int nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, uint32_t *p,
2450 struct nfs41_exchange_id_args *args)
2452 struct xdr_stream xdr;
2453 struct compound_hdr hdr = {
2454 .minorversion = args->client->cl_mvops->minor_version,
2457 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2458 encode_compound_hdr(&xdr, req, &hdr);
2459 encode_exchange_id(&xdr, args, &hdr);
2465 * a CREATE_SESSION request
2467 static int nfs4_xdr_enc_create_session(struct rpc_rqst *req, uint32_t *p,
2468 struct nfs41_create_session_args *args)
2470 struct xdr_stream xdr;
2471 struct compound_hdr hdr = {
2472 .minorversion = args->client->cl_mvops->minor_version,
2475 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2476 encode_compound_hdr(&xdr, req, &hdr);
2477 encode_create_session(&xdr, args, &hdr);
2483 * a DESTROY_SESSION request
2485 static int nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, uint32_t *p,
2486 struct nfs4_session *session)
2488 struct xdr_stream xdr;
2489 struct compound_hdr hdr = {
2490 .minorversion = session->clp->cl_mvops->minor_version,
2493 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2494 encode_compound_hdr(&xdr, req, &hdr);
2495 encode_destroy_session(&xdr, session, &hdr);
2501 * a SEQUENCE request
2503 static int nfs4_xdr_enc_sequence(struct rpc_rqst *req, uint32_t *p,
2504 struct nfs4_sequence_args *args)
2506 struct xdr_stream xdr;
2507 struct compound_hdr hdr = {
2508 .minorversion = nfs4_xdr_minorversion(args),
2511 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2512 encode_compound_hdr(&xdr, req, &hdr);
2513 encode_sequence(&xdr, args, &hdr);
2519 * a GET_LEASE_TIME request
2521 static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p,
2522 struct nfs4_get_lease_time_args *args)
2524 struct xdr_stream xdr;
2525 struct compound_hdr hdr = {
2526 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
2528 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
2530 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2531 encode_compound_hdr(&xdr, req, &hdr);
2532 encode_sequence(&xdr, &args->la_seq_args, &hdr);
2533 encode_putrootfh(&xdr, &hdr);
2534 encode_fsinfo(&xdr, lease_bitmap, &hdr);
2540 * a RECLAIM_COMPLETE request
2542 static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p,
2543 struct nfs41_reclaim_complete_args *args)
2545 struct xdr_stream xdr;
2546 struct compound_hdr hdr = {
2547 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
2550 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2551 encode_compound_hdr(&xdr, req, &hdr);
2552 encode_sequence(&xdr, &args->seq_args, &hdr);
2553 encode_reclaim_complete(&xdr, args, &hdr);
2558 #endif /* CONFIG_NFS_V4_1 */
2560 static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
2562 dprintk("nfs: %s: prematurely hit end of receive buffer. "
2563 "Remaining buffer length is %tu words.\n",
2564 func, xdr->end - xdr->p);
2567 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
2571 p = xdr_inline_decode(xdr, 4);
2574 *len = be32_to_cpup(p);
2575 p = xdr_inline_decode(xdr, *len);
2578 *string = (char *)p;
2581 print_overflow_msg(__func__, xdr);
2585 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
2589 p = xdr_inline_decode(xdr, 8);
2592 hdr->status = be32_to_cpup(p++);
2593 hdr->taglen = be32_to_cpup(p);
2595 p = xdr_inline_decode(xdr, hdr->taglen + 4);
2598 hdr->tag = (char *)p;
2599 p += XDR_QUADLEN(hdr->taglen);
2600 hdr->nops = be32_to_cpup(p);
2601 if (unlikely(hdr->nops < 1))
2602 return nfs4_stat_to_errno(hdr->status);
2605 print_overflow_msg(__func__, xdr);
2609 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
2615 p = xdr_inline_decode(xdr, 8);
2618 opnum = be32_to_cpup(p++);
2619 if (opnum != expected) {
2620 dprintk("nfs: Server returned operation"
2621 " %d but we issued a request for %d\n",
2625 nfserr = be32_to_cpup(p);
2626 if (nfserr != NFS_OK)
2627 return nfs4_stat_to_errno(nfserr);
2630 print_overflow_msg(__func__, xdr);
2635 static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp)
2638 unsigned int strlen;
2641 p = xdr_inline_decode(xdr, 12);
2643 return decode_opaque_inline(xdr, &strlen, &str);
2644 print_overflow_msg(__func__, xdr);
2648 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
2653 p = xdr_inline_decode(xdr, 4);
2656 bmlen = be32_to_cpup(p);
2658 bitmap[0] = bitmap[1] = 0;
2659 p = xdr_inline_decode(xdr, (bmlen << 2));
2663 bitmap[0] = be32_to_cpup(p++);
2665 bitmap[1] = be32_to_cpup(p);
2669 print_overflow_msg(__func__, xdr);
2673 static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, __be32 **savep)
2677 p = xdr_inline_decode(xdr, 4);
2680 *attrlen = be32_to_cpup(p);
2684 print_overflow_msg(__func__, xdr);
2688 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
2690 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
2691 decode_attr_bitmap(xdr, bitmask);
2692 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
2694 bitmask[0] = bitmask[1] = 0;
2695 dprintk("%s: bitmask=%08x:%08x\n", __func__, bitmask[0], bitmask[1]);
2699 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
2705 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
2707 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
2708 p = xdr_inline_decode(xdr, 4);
2711 *type = be32_to_cpup(p);
2712 if (*type < NF4REG || *type > NF4NAMEDATTR) {
2713 dprintk("%s: bad type %d\n", __func__, *type);
2716 bitmap[0] &= ~FATTR4_WORD0_TYPE;
2717 ret = NFS_ATTR_FATTR_TYPE;
2719 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
2722 print_overflow_msg(__func__, xdr);
2726 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
2732 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
2734 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
2735 p = xdr_inline_decode(xdr, 8);
2738 xdr_decode_hyper(p, change);
2739 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
2740 ret = NFS_ATTR_FATTR_CHANGE;
2742 dprintk("%s: change attribute=%Lu\n", __func__,
2743 (unsigned long long)*change);
2746 print_overflow_msg(__func__, xdr);
2750 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
2756 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
2758 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
2759 p = xdr_inline_decode(xdr, 8);
2762 xdr_decode_hyper(p, size);
2763 bitmap[0] &= ~FATTR4_WORD0_SIZE;
2764 ret = NFS_ATTR_FATTR_SIZE;
2766 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
2769 print_overflow_msg(__func__, xdr);
2773 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2778 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
2780 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
2781 p = xdr_inline_decode(xdr, 4);
2784 *res = be32_to_cpup(p);
2785 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
2787 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
2790 print_overflow_msg(__func__, xdr);
2794 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2799 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
2801 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
2802 p = xdr_inline_decode(xdr, 4);
2805 *res = be32_to_cpup(p);
2806 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
2808 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
2811 print_overflow_msg(__func__, xdr);
2815 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
2822 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
2824 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
2825 p = xdr_inline_decode(xdr, 16);
2828 p = xdr_decode_hyper(p, &fsid->major);
2829 xdr_decode_hyper(p, &fsid->minor);
2830 bitmap[0] &= ~FATTR4_WORD0_FSID;
2831 ret = NFS_ATTR_FATTR_FSID;
2833 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
2834 (unsigned long long)fsid->major,
2835 (unsigned long long)fsid->minor);
2838 print_overflow_msg(__func__, xdr);
2842 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2847 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
2849 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
2850 p = xdr_inline_decode(xdr, 4);
2853 *res = be32_to_cpup(p);
2854 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
2856 dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
2859 print_overflow_msg(__func__, xdr);
2863 static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap)
2867 if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U)))
2869 if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
2870 p = xdr_inline_decode(xdr, 4);
2873 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
2877 print_overflow_msg(__func__, xdr);
2881 static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
2887 memset(fh, 0, sizeof(*fh));
2889 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
2891 if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
2892 p = xdr_inline_decode(xdr, 4);
2895 len = be32_to_cpup(p);
2896 if (len > NFS4_FHSIZE)
2898 p = xdr_inline_decode(xdr, len);
2902 memcpy(fh->data, p, len);
2905 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
2909 print_overflow_msg(__func__, xdr);
2913 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2917 *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL;
2918 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
2920 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
2921 p = xdr_inline_decode(xdr, 4);
2924 *res = be32_to_cpup(p);
2925 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
2927 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
2930 print_overflow_msg(__func__, xdr);
2934 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2940 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
2942 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
2943 p = xdr_inline_decode(xdr, 8);
2946 xdr_decode_hyper(p, fileid);
2947 bitmap[0] &= ~FATTR4_WORD0_FILEID;
2948 ret = NFS_ATTR_FATTR_FILEID;
2950 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2953 print_overflow_msg(__func__, xdr);
2957 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2963 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
2965 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
2966 p = xdr_inline_decode(xdr, 8);
2969 xdr_decode_hyper(p, fileid);
2970 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
2971 ret = NFS_ATTR_FATTR_FILEID;
2973 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2976 print_overflow_msg(__func__, xdr);
2980 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2986 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
2988 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
2989 p = xdr_inline_decode(xdr, 8);
2992 xdr_decode_hyper(p, res);
2993 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
2995 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
2998 print_overflow_msg(__func__, xdr);
3002 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3008 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
3010 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
3011 p = xdr_inline_decode(xdr, 8);
3014 xdr_decode_hyper(p, res);
3015 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
3017 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
3020 print_overflow_msg(__func__, xdr);
3024 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3030 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
3032 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
3033 p = xdr_inline_decode(xdr, 8);
3036 xdr_decode_hyper(p, res);
3037 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
3039 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
3042 print_overflow_msg(__func__, xdr);
3046 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3052 p = xdr_inline_decode(xdr, 4);
3055 n = be32_to_cpup(p);
3059 path->ncomponents = 0;
3060 while (path->ncomponents < n) {
3061 struct nfs4_string *component = &path->components[path->ncomponents];
3062 status = decode_opaque_inline(xdr, &component->len, &component->data);
3063 if (unlikely(status != 0))
3065 if (path->ncomponents != n)
3067 dprintk("%s", component->data);
3068 if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS)
3069 path->ncomponents++;
3071 dprintk("cannot parse %d components in path\n", n);
3079 /* a root pathname is sent as a zero component4 */
3080 path->ncomponents = 1;
3081 path->components[0].len=0;
3082 path->components[0].data=NULL;
3083 dprintk("path /\n");
3086 dprintk(" status %d", status);
3090 print_overflow_msg(__func__, xdr);
3094 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
3100 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
3103 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
3105 dprintk("%s: fsroot ", __func__);
3106 status = decode_pathname(xdr, &res->fs_path);
3107 if (unlikely(status != 0))
3109 p = xdr_inline_decode(xdr, 4);
3112 n = be32_to_cpup(p);
3115 res->nlocations = 0;
3116 while (res->nlocations < n) {
3118 struct nfs4_fs_location *loc = &res->locations[res->nlocations];
3120 p = xdr_inline_decode(xdr, 4);
3123 m = be32_to_cpup(p);
3126 dprintk("%s: servers ", __func__);
3127 while (loc->nservers < m) {
3128 struct nfs4_string *server = &loc->servers[loc->nservers];
3129 status = decode_opaque_inline(xdr, &server->len, &server->data);
3130 if (unlikely(status != 0))
3132 dprintk("%s ", server->data);
3133 if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS)
3137 dprintk("%s: using first %u of %u servers "
3138 "returned for location %u\n",
3140 NFS4_FS_LOCATION_MAXSERVERS,
3141 m, res->nlocations);
3142 for (i = loc->nservers; i < m; i++) {
3145 status = decode_opaque_inline(xdr, &len, &data);
3146 if (unlikely(status != 0))
3151 status = decode_pathname(xdr, &loc->rootpath);
3152 if (unlikely(status != 0))
3154 if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES)
3157 if (res->nlocations != 0)
3158 status = NFS_ATTR_FATTR_V4_REFERRAL;
3160 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
3163 print_overflow_msg(__func__, xdr);
3169 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3175 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
3177 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
3178 p = xdr_inline_decode(xdr, 8);
3181 xdr_decode_hyper(p, res);
3182 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
3184 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
3187 print_overflow_msg(__func__, xdr);
3191 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
3197 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
3199 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
3200 p = xdr_inline_decode(xdr, 4);
3203 *maxlink = be32_to_cpup(p);
3204 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
3206 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
3209 print_overflow_msg(__func__, xdr);
3213 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
3219 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
3221 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
3222 p = xdr_inline_decode(xdr, 4);
3225 *maxname = be32_to_cpup(p);
3226 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
3228 dprintk("%s: maxname=%u\n", __func__, *maxname);
3231 print_overflow_msg(__func__, xdr);
3235 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3241 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
3243 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
3245 p = xdr_inline_decode(xdr, 8);
3248 xdr_decode_hyper(p, &maxread);
3249 if (maxread > 0x7FFFFFFF)
3250 maxread = 0x7FFFFFFF;
3251 *res = (uint32_t)maxread;
3252 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
3254 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
3257 print_overflow_msg(__func__, xdr);
3261 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
3267 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
3269 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
3271 p = xdr_inline_decode(xdr, 8);
3274 xdr_decode_hyper(p, &maxwrite);
3275 if (maxwrite > 0x7FFFFFFF)
3276 maxwrite = 0x7FFFFFFF;
3277 *res = (uint32_t)maxwrite;
3278 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
3280 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
3283 print_overflow_msg(__func__, xdr);
3287 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
3294 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
3296 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
3297 p = xdr_inline_decode(xdr, 4);
3300 tmp = be32_to_cpup(p);
3301 *mode = tmp & ~S_IFMT;
3302 bitmap[1] &= ~FATTR4_WORD1_MODE;
3303 ret = NFS_ATTR_FATTR_MODE;
3305 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
3308 print_overflow_msg(__func__, xdr);
3312 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
3318 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
3320 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
3321 p = xdr_inline_decode(xdr, 4);
3324 *nlink = be32_to_cpup(p);
3325 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
3326 ret = NFS_ATTR_FATTR_NLINK;
3328 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
3331 print_overflow_msg(__func__, xdr);
3335 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3336 struct nfs_client *clp, uint32_t *uid, int may_sleep)
3343 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3345 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) {
3346 p = xdr_inline_decode(xdr, 4);
3349 len = be32_to_cpup(p);
3350 p = xdr_inline_decode(xdr, len);
3355 } else if (len < XDR_MAX_NETOBJ) {
3356 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0)
3357 ret = NFS_ATTR_FATTR_OWNER;
3359 dprintk("%s: nfs_map_name_to_uid failed!\n",
3362 dprintk("%s: name too long (%u)!\n",
3364 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3366 dprintk("%s: uid=%d\n", __func__, (int)*uid);
3369 print_overflow_msg(__func__, xdr);
3373 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3374 struct nfs_client *clp, uint32_t *gid, int may_sleep)
3381 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
3383 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) {
3384 p = xdr_inline_decode(xdr, 4);
3387 len = be32_to_cpup(p);
3388 p = xdr_inline_decode(xdr, len);
3393 } else if (len < XDR_MAX_NETOBJ) {
3394 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0)
3395 ret = NFS_ATTR_FATTR_GROUP;
3397 dprintk("%s: nfs_map_group_to_gid failed!\n",
3400 dprintk("%s: name too long (%u)!\n",
3402 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
3404 dprintk("%s: gid=%d\n", __func__, (int)*gid);
3407 print_overflow_msg(__func__, xdr);
3411 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
3413 uint32_t major = 0, minor = 0;
3418 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
3420 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
3423 p = xdr_inline_decode(xdr, 8);
3426 major = be32_to_cpup(p++);
3427 minor = be32_to_cpup(p);
3428 tmp = MKDEV(major, minor);
3429 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
3431 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
3432 ret = NFS_ATTR_FATTR_RDEV;
3434 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
3437 print_overflow_msg(__func__, xdr);
3441 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3447 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
3449 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
3450 p = xdr_inline_decode(xdr, 8);
3453 xdr_decode_hyper(p, res);
3454 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
3456 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
3459 print_overflow_msg(__func__, xdr);
3463 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3469 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
3471 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
3472 p = xdr_inline_decode(xdr, 8);
3475 xdr_decode_hyper(p, res);
3476 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
3478 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
3481 print_overflow_msg(__func__, xdr);
3485 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
3491 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
3493 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
3494 p = xdr_inline_decode(xdr, 8);
3497 xdr_decode_hyper(p, res);
3498 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
3500 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
3503 print_overflow_msg(__func__, xdr);
3507 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
3513 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
3515 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
3516 p = xdr_inline_decode(xdr, 8);
3519 xdr_decode_hyper(p, used);
3520 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
3521 ret = NFS_ATTR_FATTR_SPACE_USED;
3523 dprintk("%s: space used=%Lu\n", __func__,
3524 (unsigned long long)*used);
3527 print_overflow_msg(__func__, xdr);
3531 static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
3537 p = xdr_inline_decode(xdr, 12);
3540 p = xdr_decode_hyper(p, &sec);
3541 nsec = be32_to_cpup(p);
3542 time->tv_sec = (time_t)sec;
3543 time->tv_nsec = (long)nsec;
3546 print_overflow_msg(__func__, xdr);
3550 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
3556 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
3558 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
3559 status = decode_attr_time(xdr, time);
3561 status = NFS_ATTR_FATTR_ATIME;
3562 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
3564 dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
3568 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
3574 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
3576 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
3577 status = decode_attr_time(xdr, time);
3579 status = NFS_ATTR_FATTR_CTIME;
3580 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
3582 dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
3586 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
3592 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
3594 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
3595 status = decode_attr_time(xdr, time);
3597 status = NFS_ATTR_FATTR_MTIME;
3598 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
3600 dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
3604 static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrlen)
3606 unsigned int attrwords = XDR_QUADLEN(attrlen);
3607 unsigned int nwords = xdr->p - savep;
3609 if (unlikely(attrwords != nwords)) {
3610 dprintk("%s: server returned incorrect attribute length: "
3614 (attrwords < nwords) ? '<' : '>',
3621 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3625 p = xdr_inline_decode(xdr, 20);
3628 cinfo->atomic = be32_to_cpup(p++);
3629 p = xdr_decode_hyper(p, &cinfo->before);
3630 xdr_decode_hyper(p, &cinfo->after);
3633 print_overflow_msg(__func__, xdr);
3637 static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
3643 status = decode_op_hdr(xdr, OP_ACCESS);
3646 p = xdr_inline_decode(xdr, 8);
3649 supp = be32_to_cpup(p++);
3650 acc = be32_to_cpup(p);
3651 access->supported = supp;
3652 access->access = acc;
3655 print_overflow_msg(__func__, xdr);
3659 static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
3663 p = xdr_inline_decode(xdr, len);
3665 memcpy(buf, p, len);
3668 print_overflow_msg(__func__, xdr);
3672 static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
3674 return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);
3677 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
3681 status = decode_op_hdr(xdr, OP_CLOSE);
3683 nfs_increment_open_seqid(status, res->seqid);
3685 status = decode_stateid(xdr, &res->stateid);
3689 static int decode_verifier(struct xdr_stream *xdr, void *verifier)
3691 return decode_opaque_fixed(xdr, verifier, 8);
3694 static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
3698 status = decode_op_hdr(xdr, OP_COMMIT);
3700 status = decode_verifier(xdr, res->verf->verifier);
3704 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3710 status = decode_op_hdr(xdr, OP_CREATE);
3713 if ((status = decode_change_info(xdr, cinfo)))
3715 p = xdr_inline_decode(xdr, 4);
3718 bmlen = be32_to_cpup(p);
3719 p = xdr_inline_decode(xdr, bmlen << 2);
3723 print_overflow_msg(__func__, xdr);
3727 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
3730 uint32_t attrlen, bitmap[2] = {0};
3733 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3735 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3737 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3739 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
3741 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
3743 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
3745 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
3747 status = verify_attr_len(xdr, savep, attrlen);
3749 dprintk("%s: xdr returned %d!\n", __func__, -status);
3753 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
3756 uint32_t attrlen, bitmap[2] = {0};
3759 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3761 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3763 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3766 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
3768 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
3770 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
3772 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
3774 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
3776 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
3779 status = verify_attr_len(xdr, savep, attrlen);
3781 dprintk("%s: xdr returned %d!\n", __func__, -status);
3785 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
3788 uint32_t attrlen, bitmap[2] = {0};
3791 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3793 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3795 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3798 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
3800 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
3803 status = verify_attr_len(xdr, savep, attrlen);
3805 dprintk("%s: xdr returned %d!\n", __func__, -status);
3809 static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
3810 struct nfs_fattr *fattr, struct nfs_fh *fh,
3811 const struct nfs_server *server, int may_sleep)
3818 status = decode_attr_type(xdr, bitmap, &type);
3823 fattr->mode |= nfs_type2fmt[type];
3824 fattr->valid |= status;
3827 status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
3830 fattr->valid |= status;
3832 status = decode_attr_size(xdr, bitmap, &fattr->size);
3835 fattr->valid |= status;
3837 status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
3840 fattr->valid |= status;
3842 status = decode_attr_error(xdr, bitmap);
3846 status = decode_attr_filehandle(xdr, bitmap, fh);
3850 status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
3853 fattr->valid |= status;
3855 status = decode_attr_fs_locations(xdr, bitmap, container_of(fattr,
3856 struct nfs4_fs_locations,
3860 fattr->valid |= status;
3862 status = decode_attr_mode(xdr, bitmap, &fmode);
3866 fattr->mode |= fmode;
3867 fattr->valid |= status;
3870 status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
3873 fattr->valid |= status;
3875 status = decode_attr_owner(xdr, bitmap, server->nfs_client,
3876 &fattr->uid, may_sleep);
3879 fattr->valid |= status;
3881 status = decode_attr_group(xdr, bitmap, server->nfs_client,
3882 &fattr->gid, may_sleep);
3885 fattr->valid |= status;
3887 status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
3890 fattr->valid |= status;
3892 status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
3895 fattr->valid |= status;
3897 status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
3900 fattr->valid |= status;
3902 status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
3905 fattr->valid |= status;
3907 status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
3910 fattr->valid |= status;
3912 status = decode_attr_mounted_on_fileid(xdr, bitmap, &fileid);
3916 fattr->fileid = fileid;
3917 fattr->valid |= status;
3921 dprintk("%s: xdr returned %d\n", __func__, -status);
3925 static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr,
3926 struct nfs_fh *fh, const struct nfs_server *server, int may_sleep)
3933 status = decode_op_hdr(xdr, OP_GETATTR);
3937 status = decode_attr_bitmap(xdr, bitmap);
3941 status = decode_attr_length(xdr, &attrlen, &savep);
3945 status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, server, may_sleep);
3949 status = verify_attr_len(xdr, savep, attrlen);
3951 dprintk("%s: xdr returned %d\n", __func__, -status);
3955 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
3956 const struct nfs_server *server, int may_sleep)
3958 return decode_getfattr_generic(xdr, fattr, NULL, server, may_sleep);
3961 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
3964 uint32_t attrlen, bitmap[2];
3967 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3969 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3971 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3974 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
3976 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
3978 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
3980 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
3982 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
3983 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
3985 fsinfo->wtpref = fsinfo->wtmax;
3987 status = verify_attr_len(xdr, savep, attrlen);
3989 dprintk("%s: xdr returned %d!\n", __func__, -status);
3993 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
3999 /* Zero handle first to allow comparisons */
4000 memset(fh, 0, sizeof(*fh));
4002 status = decode_op_hdr(xdr, OP_GETFH);
4006 p = xdr_inline_decode(xdr, 4);
4009 len = be32_to_cpup(p);
4010 if (len > NFS4_FHSIZE)
4013 p = xdr_inline_decode(xdr, len);
4016 memcpy(fh->data, p, len);
4019 print_overflow_msg(__func__, xdr);
4023 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4027 status = decode_op_hdr(xdr, OP_LINK);
4030 return decode_change_info(xdr, cinfo);
4034 * We create the owner, so we know a proper owner.id length is 4.
4036 static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
4038 uint64_t offset, length, clientid;
4040 uint32_t namelen, type;
4042 p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
4045 p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
4046 p = xdr_decode_hyper(p, &length);
4047 type = be32_to_cpup(p++); /* 4 byte read */
4048 if (fl != NULL) { /* manipulate file lock */
4049 fl->fl_start = (loff_t)offset;
4050 fl->fl_end = fl->fl_start + (loff_t)length - 1;
4051 if (length == ~(uint64_t)0)
4052 fl->fl_end = OFFSET_MAX;
4053 fl->fl_type = F_WRLCK;
4055 fl->fl_type = F_RDLCK;
4058 p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
4059 namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */
4060 p = xdr_inline_decode(xdr, namelen); /* variable size field */
4062 return -NFS4ERR_DENIED;
4064 print_overflow_msg(__func__, xdr);
4068 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
4072 status = decode_op_hdr(xdr, OP_LOCK);
4076 status = decode_stateid(xdr, &res->stateid);
4077 if (unlikely(status))
4079 } else if (status == -NFS4ERR_DENIED)
4080 status = decode_lock_denied(xdr, NULL);
4081 if (res->open_seqid != NULL)
4082 nfs_increment_open_seqid(status, res->open_seqid);
4083 nfs_increment_lock_seqid(status, res->lock_seqid);
4088 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
4091 status = decode_op_hdr(xdr, OP_LOCKT);
4092 if (status == -NFS4ERR_DENIED)
4093 return decode_lock_denied(xdr, res->denied);
4097 static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
4101 status = decode_op_hdr(xdr, OP_LOCKU);
4103 nfs_increment_lock_seqid(status, res->seqid);
4105 status = decode_stateid(xdr, &res->stateid);
4109 static int decode_release_lockowner(struct xdr_stream *xdr)
4111 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
4114 static int decode_lookup(struct xdr_stream *xdr)
4116 return decode_op_hdr(xdr, OP_LOOKUP);
4119 /* This is too sick! */
4120 static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
4123 uint32_t limit_type, nblocks, blocksize;
4125 p = xdr_inline_decode(xdr, 12);
4128 limit_type = be32_to_cpup(p++);
4129 switch (limit_type) {
4131 xdr_decode_hyper(p, maxsize);
4134 nblocks = be32_to_cpup(p++);
4135 blocksize = be32_to_cpup(p);
4136 *maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
4140 print_overflow_msg(__func__, xdr);
4144 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
4147 uint32_t delegation_type;
4150 p = xdr_inline_decode(xdr, 4);
4153 delegation_type = be32_to_cpup(p);
4154 if (delegation_type == NFS4_OPEN_DELEGATE_NONE) {
4155 res->delegation_type = 0;
4158 status = decode_stateid(xdr, &res->delegation);
4159 if (unlikely(status))
4161 p = xdr_inline_decode(xdr, 4);
4164 res->do_recall = be32_to_cpup(p);
4166 switch (delegation_type) {
4167 case NFS4_OPEN_DELEGATE_READ:
4168 res->delegation_type = FMODE_READ;
4170 case NFS4_OPEN_DELEGATE_WRITE:
4171 res->delegation_type = FMODE_WRITE|FMODE_READ;
4172 if (decode_space_limit(xdr, &res->maxsize) < 0)
4175 return decode_ace(xdr, NULL, res->server->nfs_client);
4177 print_overflow_msg(__func__, xdr);
4181 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
4184 uint32_t savewords, bmlen, i;
4187 status = decode_op_hdr(xdr, OP_OPEN);
4189 nfs_increment_open_seqid(status, res->seqid);
4191 status = decode_stateid(xdr, &res->stateid);
4192 if (unlikely(status))
4195 decode_change_info(xdr, &res->cinfo);
4197 p = xdr_inline_decode(xdr, 8);
4200 res->rflags = be32_to_cpup(p++);
4201 bmlen = be32_to_cpup(p);
4205 p = xdr_inline_decode(xdr, bmlen << 2);
4208 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
4209 for (i = 0; i < savewords; ++i)
4210 res->attrset[i] = be32_to_cpup(p++);
4211 for (; i < NFS4_BITMAP_SIZE; i++)
4212 res->attrset[i] = 0;
4214 return decode_delegation(xdr, res);
4216 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
4219 print_overflow_msg(__func__, xdr);
4223 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
4227 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
4229 nfs_increment_open_seqid(status, res->seqid);
4231 status = decode_stateid(xdr, &res->stateid);
4235 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
4239 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
4241 nfs_increment_open_seqid(status, res->seqid);
4243 status = decode_stateid(xdr, &res->stateid);
4247 static int decode_putfh(struct xdr_stream *xdr)
4249 return decode_op_hdr(xdr, OP_PUTFH);
4252 static int decode_putrootfh(struct xdr_stream *xdr)
4254 return decode_op_hdr(xdr, OP_PUTROOTFH);
4257 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res)
4259 struct kvec *iov = req->rq_rcv_buf.head;
4261 uint32_t count, eof, recvd, hdrlen;
4264 status = decode_op_hdr(xdr, OP_READ);
4267 p = xdr_inline_decode(xdr, 8);
4270 eof = be32_to_cpup(p++);
4271 count = be32_to_cpup(p);
4272 hdrlen = (u8 *) p - (u8 *) iov->iov_base;
4273 recvd = req->rq_rcv_buf.len - hdrlen;
4274 if (count > recvd) {
4275 dprintk("NFS: server cheating in read reply: "
4276 "count %u > recvd %u\n", count, recvd);
4280 xdr_read_pages(xdr, count);
4285 print_overflow_msg(__func__, xdr);
4289 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
4291 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
4292 struct kvec *iov = rcvbuf->head;
4294 u32 recvd, pglen = rcvbuf->page_len;
4297 status = decode_op_hdr(xdr, OP_READDIR);
4299 status = decode_verifier(xdr, readdir->verifier.data);
4300 if (unlikely(status))
4302 dprintk("%s: verifier = %08x:%08x\n",
4304 ((u32 *)readdir->verifier.data)[0],
4305 ((u32 *)readdir->verifier.data)[1]);
4308 hdrlen = (char *) xdr->p - (char *) iov->iov_base;
4309 recvd = rcvbuf->len - hdrlen;
4312 xdr_read_pages(xdr, pglen);
4318 static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
4320 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
4321 struct kvec *iov = rcvbuf->head;
4327 status = decode_op_hdr(xdr, OP_READLINK);
4331 /* Convert length of symlink */
4332 p = xdr_inline_decode(xdr, 4);
4335 len = be32_to_cpup(p);
4336 if (len >= rcvbuf->page_len || len <= 0) {
4337 dprintk("nfs: server returned giant symlink!\n");
4338 return -ENAMETOOLONG;
4340 hdrlen = (char *) xdr->p - (char *) iov->iov_base;
4341 recvd = req->rq_rcv_buf.len - hdrlen;
4343 dprintk("NFS: server cheating in readlink reply: "
4344 "count %u > recvd %u\n", len, recvd);
4347 xdr_read_pages(xdr, len);
4349 * The XDR encode routine has set things up so that
4350 * the link text will be copied directly into the
4351 * buffer. We just have to do overflow-checking,
4352 * and and null-terminate the text (the VFS expects
4353 * null-termination).
4355 xdr_terminate_string(rcvbuf, len);
4358 print_overflow_msg(__func__, xdr);
4362 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
4366 status = decode_op_hdr(xdr, OP_REMOVE);
4369 status = decode_change_info(xdr, cinfo);
4374 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
4375 struct nfs4_change_info *new_cinfo)
4379 status = decode_op_hdr(xdr, OP_RENAME);
4382 if ((status = decode_change_info(xdr, old_cinfo)))
4384 status = decode_change_info(xdr, new_cinfo);
4389 static int decode_renew(struct xdr_stream *xdr)
4391 return decode_op_hdr(xdr, OP_RENEW);
4395 decode_restorefh(struct xdr_stream *xdr)
4397 return decode_op_hdr(xdr, OP_RESTOREFH);
4400 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
4406 struct kvec *iov = req->rq_rcv_buf.head;
4410 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
4412 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
4414 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
4417 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
4419 if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
4423 /* We ignore &savep and don't do consistency checks on
4424 * the attr length. Let userspace figure it out.... */
4425 hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
4426 recvd = req->rq_rcv_buf.len - hdrlen;
4427 if (attrlen > recvd) {
4428 dprintk("NFS: server cheating in getattr"
4429 " acl reply: attrlen %u > recvd %u\n",
4433 xdr_read_pages(xdr, attrlen);
4436 status = -EOPNOTSUPP;
4443 decode_savefh(struct xdr_stream *xdr)
4445 return decode_op_hdr(xdr, OP_SAVEFH);
4448 static int decode_setattr(struct xdr_stream *xdr)
4454 status = decode_op_hdr(xdr, OP_SETATTR);
4457 p = xdr_inline_decode(xdr, 4);
4460 bmlen = be32_to_cpup(p);
4461 p = xdr_inline_decode(xdr, bmlen << 2);
4465 print_overflow_msg(__func__, xdr);
4469 static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
4475 p = xdr_inline_decode(xdr, 8);
4478 opnum = be32_to_cpup(p++);
4479 if (opnum != OP_SETCLIENTID) {
4480 dprintk("nfs: decode_setclientid: Server returned operation"
4484 nfserr = be32_to_cpup(p);
4485 if (nfserr == NFS_OK) {
4486 p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
4489 p = xdr_decode_hyper(p, &res->clientid);
4490 memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
4491 } else if (nfserr == NFSERR_CLID_INUSE) {
4494 /* skip netid string */
4495 p = xdr_inline_decode(xdr, 4);
4498 len = be32_to_cpup(p);
4499 p = xdr_inline_decode(xdr, len);
4503 /* skip uaddr string */
4504 p = xdr_inline_decode(xdr, 4);
4507 len = be32_to_cpup(p);
4508 p = xdr_inline_decode(xdr, len);
4511 return -NFSERR_CLID_INUSE;
4513 return nfs4_stat_to_errno(nfserr);
4517 print_overflow_msg(__func__, xdr);
4521 static int decode_setclientid_confirm(struct xdr_stream *xdr)
4523 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
4526 static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
4531 status = decode_op_hdr(xdr, OP_WRITE);
4535 p = xdr_inline_decode(xdr, 16);
4538 res->count = be32_to_cpup(p++);
4539 res->verf->committed = be32_to_cpup(p++);
4540 memcpy(res->verf->verifier, p, 8);
4543 print_overflow_msg(__func__, xdr);
4547 static int decode_delegreturn(struct xdr_stream *xdr)
4549 return decode_op_hdr(xdr, OP_DELEGRETURN);
4552 #if defined(CONFIG_NFS_V4_1)
4553 static int decode_exchange_id(struct xdr_stream *xdr,
4554 struct nfs41_exchange_id_res *res)
4560 struct nfs_client *clp = res->client;
4562 status = decode_op_hdr(xdr, OP_EXCHANGE_ID);
4566 p = xdr_inline_decode(xdr, 8);
4569 xdr_decode_hyper(p, &clp->cl_ex_clid);
4570 p = xdr_inline_decode(xdr, 12);
4573 clp->cl_seqid = be32_to_cpup(p++);
4574 clp->cl_exchange_flags = be32_to_cpup(p++);
4576 /* We ask for SP4_NONE */
4577 dummy = be32_to_cpup(p);
4578 if (dummy != SP4_NONE)
4581 /* Throw away minor_id */
4582 p = xdr_inline_decode(xdr, 8);
4586 /* Throw away Major id */
4587 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
4588 if (unlikely(status))
4591 /* Throw away server_scope */
4592 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
4593 if (unlikely(status))
4596 /* Throw away Implementation id array */
4597 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
4598 if (unlikely(status))
4603 print_overflow_msg(__func__, xdr);
4607 static int decode_chan_attrs(struct xdr_stream *xdr,
4608 struct nfs4_channel_attrs *attrs)
4613 p = xdr_inline_decode(xdr, 28);
4616 attrs->headerpadsz = be32_to_cpup(p++);
4617 attrs->max_rqst_sz = be32_to_cpup(p++);
4618 attrs->max_resp_sz = be32_to_cpup(p++);
4619 attrs->max_resp_sz_cached = be32_to_cpup(p++);
4620 attrs->max_ops = be32_to_cpup(p++);
4621 attrs->max_reqs = be32_to_cpup(p++);
4622 nr_attrs = be32_to_cpup(p);
4623 if (unlikely(nr_attrs > 1)) {
4624 printk(KERN_WARNING "%s: Invalid rdma channel attrs count %u\n",
4625 __func__, nr_attrs);
4628 if (nr_attrs == 1) {
4629 p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
4635 print_overflow_msg(__func__, xdr);
4639 static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
4641 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
4644 static int decode_create_session(struct xdr_stream *xdr,
4645 struct nfs41_create_session_res *res)
4649 struct nfs_client *clp = res->client;
4650 struct nfs4_session *session = clp->cl_session;
4652 status = decode_op_hdr(xdr, OP_CREATE_SESSION);
4654 status = decode_sessionid(xdr, &session->sess_id);
4655 if (unlikely(status))
4659 p = xdr_inline_decode(xdr, 8);
4662 clp->cl_seqid = be32_to_cpup(p++);
4663 session->flags = be32_to_cpup(p);
4665 /* Channel attributes */
4666 status = decode_chan_attrs(xdr, &session->fc_attrs);
4668 status = decode_chan_attrs(xdr, &session->bc_attrs);
4671 print_overflow_msg(__func__, xdr);
4675 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
4677 return decode_op_hdr(xdr, OP_DESTROY_SESSION);
4680 static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
4682 return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
4684 #endif /* CONFIG_NFS_V4_1 */
4686 static int decode_sequence(struct xdr_stream *xdr,
4687 struct nfs4_sequence_res *res,
4688 struct rpc_rqst *rqstp)
4690 #if defined(CONFIG_NFS_V4_1)
4691 struct nfs4_sessionid id;
4696 if (!res->sr_session)
4699 status = decode_op_hdr(xdr, OP_SEQUENCE);
4701 status = decode_sessionid(xdr, &id);
4702 if (unlikely(status))
4706 * If the server returns different values for sessionID, slotID or
4707 * sequence number, the server is looney tunes.
4709 status = -EREMOTEIO;
4711 if (memcmp(id.data, res->sr_session->sess_id.data,
4712 NFS4_MAX_SESSIONID_LEN)) {
4713 dprintk("%s Invalid session id\n", __func__);
4717 p = xdr_inline_decode(xdr, 20);
4722 dummy = be32_to_cpup(p++);
4723 if (dummy != res->sr_slot->seq_nr) {
4724 dprintk("%s Invalid sequence number\n", __func__);
4728 dummy = be32_to_cpup(p++);
4729 if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) {
4730 dprintk("%s Invalid slot id\n", __func__);
4733 /* highest slot id - currently not processed */
4734 dummy = be32_to_cpup(p++);
4735 /* target highest slot id - currently not processed */
4736 dummy = be32_to_cpup(p++);
4738 res->sr_status_flags = be32_to_cpup(p);
4741 res->sr_status = status;
4744 print_overflow_msg(__func__, xdr);
4747 #else /* CONFIG_NFS_V4_1 */
4749 #endif /* CONFIG_NFS_V4_1 */
4753 * END OF "GENERIC" DECODE ROUTINES.
4757 * Decode OPEN_DOWNGRADE response
4759 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
4761 struct xdr_stream xdr;
4762 struct compound_hdr hdr;
4765 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4766 status = decode_compound_hdr(&xdr, &hdr);
4769 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4772 status = decode_putfh(&xdr);
4775 status = decode_open_downgrade(&xdr, res);
4778 decode_getfattr(&xdr, res->fattr, res->server,
4779 !RPC_IS_ASYNC(rqstp->rq_task));
4785 * Decode ACCESS response
4787 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_accessres *res)
4789 struct xdr_stream xdr;
4790 struct compound_hdr hdr;
4793 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4794 status = decode_compound_hdr(&xdr, &hdr);
4797 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4800 status = decode_putfh(&xdr);
4803 status = decode_access(&xdr, res);
4806 decode_getfattr(&xdr, res->fattr, res->server,
4807 !RPC_IS_ASYNC(rqstp->rq_task));
4813 * Decode LOOKUP response
4815 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
4817 struct xdr_stream xdr;
4818 struct compound_hdr hdr;
4821 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4822 status = decode_compound_hdr(&xdr, &hdr);
4825 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4828 if ((status = decode_putfh(&xdr)) != 0)
4830 if ((status = decode_lookup(&xdr)) != 0)
4832 if ((status = decode_getfh(&xdr, res->fh)) != 0)
4834 status = decode_getfattr(&xdr, res->fattr, res->server
4835 ,!RPC_IS_ASYNC(rqstp->rq_task));
4841 * Decode LOOKUP_ROOT response
4843 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
4845 struct xdr_stream xdr;
4846 struct compound_hdr hdr;
4849 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4850 status = decode_compound_hdr(&xdr, &hdr);
4853 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4856 if ((status = decode_putrootfh(&xdr)) != 0)
4858 if ((status = decode_getfh(&xdr, res->fh)) == 0)
4859 status = decode_getfattr(&xdr, res->fattr, res->server,
4860 !RPC_IS_ASYNC(rqstp->rq_task));
4866 * Decode REMOVE response
4868 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res)
4870 struct xdr_stream xdr;
4871 struct compound_hdr hdr;
4874 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4875 status = decode_compound_hdr(&xdr, &hdr);
4878 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4881 if ((status = decode_putfh(&xdr)) != 0)
4883 if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
4885 decode_getfattr(&xdr, res->dir_attr, res->server,
4886 !RPC_IS_ASYNC(rqstp->rq_task));
4892 * Decode RENAME response
4894 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, __be32 *p, struct nfs_renameres *res)
4896 struct xdr_stream xdr;
4897 struct compound_hdr hdr;
4900 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4901 status = decode_compound_hdr(&xdr, &hdr);
4904 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4907 if ((status = decode_putfh(&xdr)) != 0)
4909 if ((status = decode_savefh(&xdr)) != 0)
4911 if ((status = decode_putfh(&xdr)) != 0)
4913 if ((status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo)) != 0)
4915 /* Current FH is target directory */
4916 if (decode_getfattr(&xdr, res->new_fattr, res->server,
4917 !RPC_IS_ASYNC(rqstp->rq_task)) != 0)
4919 if ((status = decode_restorefh(&xdr)) != 0)
4921 decode_getfattr(&xdr, res->old_fattr, res->server,
4922 !RPC_IS_ASYNC(rqstp->rq_task));
4928 * Decode LINK response
4930 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_link_res *res)
4932 struct xdr_stream xdr;
4933 struct compound_hdr hdr;
4936 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4937 status = decode_compound_hdr(&xdr, &hdr);
4940 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4943 if ((status = decode_putfh(&xdr)) != 0)
4945 if ((status = decode_savefh(&xdr)) != 0)
4947 if ((status = decode_putfh(&xdr)) != 0)
4949 if ((status = decode_link(&xdr, &res->cinfo)) != 0)
4952 * Note order: OP_LINK leaves the directory as the current
4955 if (decode_getfattr(&xdr, res->dir_attr, res->server,
4956 !RPC_IS_ASYNC(rqstp->rq_task)) != 0)
4958 if ((status = decode_restorefh(&xdr)) != 0)
4960 decode_getfattr(&xdr, res->fattr, res->server,
4961 !RPC_IS_ASYNC(rqstp->rq_task));
4967 * Decode CREATE response
4969 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
4971 struct xdr_stream xdr;
4972 struct compound_hdr hdr;
4975 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4976 status = decode_compound_hdr(&xdr, &hdr);
4979 status = decode_sequence(&xdr, &res->seq_res, rqstp);
4982 if ((status = decode_putfh(&xdr)) != 0)
4984 if ((status = decode_savefh(&xdr)) != 0)
4986 if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0)
4988 if ((status = decode_getfh(&xdr, res->fh)) != 0)
4990 if (decode_getfattr(&xdr, res->fattr, res->server,
4991 !RPC_IS_ASYNC(rqstp->rq_task)) != 0)
4993 if ((status = decode_restorefh(&xdr)) != 0)
4995 decode_getfattr(&xdr, res->dir_fattr, res->server,
4996 !RPC_IS_ASYNC(rqstp->rq_task));
5002 * Decode SYMLINK response
5004 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
5006 return nfs4_xdr_dec_create(rqstp, p, res);
5010 * Decode GETATTR response
5012 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_getattr_res *res)
5014 struct xdr_stream xdr;
5015 struct compound_hdr hdr;
5018 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5019 status = decode_compound_hdr(&xdr, &hdr);
5022 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5025 status = decode_putfh(&xdr);
5028 status = decode_getfattr(&xdr, res->fattr, res->server,
5029 !RPC_IS_ASYNC(rqstp->rq_task));
5035 * Encode an SETACL request
5038 nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args)
5040 struct xdr_stream xdr;
5041 struct compound_hdr hdr = {
5042 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
5046 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
5047 encode_compound_hdr(&xdr, req, &hdr);
5048 encode_sequence(&xdr, &args->seq_args, &hdr);
5049 encode_putfh(&xdr, args->fh, &hdr);
5050 status = encode_setacl(&xdr, args, &hdr);
5056 * Decode SETACL response
5059 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, __be32 *p,
5060 struct nfs_setaclres *res)
5062 struct xdr_stream xdr;
5063 struct compound_hdr hdr;
5066 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5067 status = decode_compound_hdr(&xdr, &hdr);
5070 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5073 status = decode_putfh(&xdr);
5076 status = decode_setattr(&xdr);
5082 * Decode GETACL response
5085 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, __be32 *p,
5086 struct nfs_getaclres *res)
5088 struct xdr_stream xdr;
5089 struct compound_hdr hdr;
5092 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5093 status = decode_compound_hdr(&xdr, &hdr);
5096 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5099 status = decode_putfh(&xdr);
5102 status = decode_getacl(&xdr, rqstp, &res->acl_len);
5109 * Decode CLOSE response
5111 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
5113 struct xdr_stream xdr;
5114 struct compound_hdr hdr;
5117 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5118 status = decode_compound_hdr(&xdr, &hdr);
5121 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5124 status = decode_putfh(&xdr);
5127 status = decode_close(&xdr, res);
5131 * Note: Server may do delete on close for this file
5132 * in which case the getattr call will fail with
5133 * an ESTALE error. Shouldn't be a problem,
5134 * though, since fattr->valid will remain unset.
5136 decode_getfattr(&xdr, res->fattr, res->server,
5137 !RPC_IS_ASYNC(rqstp->rq_task));
5143 * Decode OPEN response
5145 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
5147 struct xdr_stream xdr;
5148 struct compound_hdr hdr;
5151 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5152 status = decode_compound_hdr(&xdr, &hdr);
5155 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5158 status = decode_putfh(&xdr);
5161 status = decode_savefh(&xdr);
5164 status = decode_open(&xdr, res);
5167 if (decode_getfh(&xdr, &res->fh) != 0)
5169 if (decode_getfattr(&xdr, res->f_attr, res->server,
5170 !RPC_IS_ASYNC(rqstp->rq_task)) != 0)
5172 if (decode_restorefh(&xdr) != 0)
5174 decode_getfattr(&xdr, res->dir_attr, res->server,
5175 !RPC_IS_ASYNC(rqstp->rq_task));
5181 * Decode OPEN_CONFIRM response
5183 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, __be32 *p, struct nfs_open_confirmres *res)
5185 struct xdr_stream xdr;
5186 struct compound_hdr hdr;
5189 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5190 status = decode_compound_hdr(&xdr, &hdr);
5193 status = decode_putfh(&xdr);
5196 status = decode_open_confirm(&xdr, res);
5202 * Decode OPEN response
5204 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
5206 struct xdr_stream xdr;
5207 struct compound_hdr hdr;
5210 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5211 status = decode_compound_hdr(&xdr, &hdr);
5214 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5217 status = decode_putfh(&xdr);
5220 status = decode_open(&xdr, res);
5223 decode_getfattr(&xdr, res->f_attr, res->server,
5224 !RPC_IS_ASYNC(rqstp->rq_task));
5230 * Decode SETATTR response
5232 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_setattrres *res)
5234 struct xdr_stream xdr;
5235 struct compound_hdr hdr;
5238 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5239 status = decode_compound_hdr(&xdr, &hdr);
5242 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5245 status = decode_putfh(&xdr);
5248 status = decode_setattr(&xdr);
5251 decode_getfattr(&xdr, res->fattr, res->server,
5252 !RPC_IS_ASYNC(rqstp->rq_task));
5258 * Decode LOCK response
5260 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lock_res *res)
5262 struct xdr_stream xdr;
5263 struct compound_hdr hdr;
5266 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5267 status = decode_compound_hdr(&xdr, &hdr);
5270 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5273 status = decode_putfh(&xdr);
5276 status = decode_lock(&xdr, res);
5282 * Decode LOCKT response
5284 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res)
5286 struct xdr_stream xdr;
5287 struct compound_hdr hdr;
5290 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5291 status = decode_compound_hdr(&xdr, &hdr);
5294 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5297 status = decode_putfh(&xdr);
5300 status = decode_lockt(&xdr, res);
5306 * Decode LOCKU response
5308 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, __be32 *p, struct nfs_locku_res *res)
5310 struct xdr_stream xdr;
5311 struct compound_hdr hdr;
5314 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5315 status = decode_compound_hdr(&xdr, &hdr);
5318 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5321 status = decode_putfh(&xdr);
5324 status = decode_locku(&xdr, res);
5329 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
5331 struct xdr_stream xdr;
5332 struct compound_hdr hdr;
5335 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5336 status = decode_compound_hdr(&xdr, &hdr);
5338 status = decode_release_lockowner(&xdr);
5343 * Decode READLINK response
5345 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, __be32 *p,
5346 struct nfs4_readlink_res *res)
5348 struct xdr_stream xdr;
5349 struct compound_hdr hdr;
5352 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5353 status = decode_compound_hdr(&xdr, &hdr);
5356 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5359 status = decode_putfh(&xdr);
5362 status = decode_readlink(&xdr, rqstp);
5368 * Decode READDIR response
5370 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_readdir_res *res)
5372 struct xdr_stream xdr;
5373 struct compound_hdr hdr;
5376 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5377 status = decode_compound_hdr(&xdr, &hdr);
5380 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5383 status = decode_putfh(&xdr);
5386 status = decode_readdir(&xdr, rqstp, res);
5392 * Decode Read response
5394 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res)
5396 struct xdr_stream xdr;
5397 struct compound_hdr hdr;
5400 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5401 status = decode_compound_hdr(&xdr, &hdr);
5404 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5407 status = decode_putfh(&xdr);
5410 status = decode_read(&xdr, rqstp, res);
5412 status = res->count;
5418 * Decode WRITE response
5420 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
5422 struct xdr_stream xdr;
5423 struct compound_hdr hdr;
5426 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5427 status = decode_compound_hdr(&xdr, &hdr);
5430 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5433 status = decode_putfh(&xdr);
5436 status = decode_write(&xdr, res);
5439 decode_getfattr(&xdr, res->fattr, res->server,
5440 !RPC_IS_ASYNC(rqstp->rq_task));
5442 status = res->count;
5448 * Decode COMMIT response
5450 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
5452 struct xdr_stream xdr;
5453 struct compound_hdr hdr;
5456 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5457 status = decode_compound_hdr(&xdr, &hdr);
5460 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5463 status = decode_putfh(&xdr);
5466 status = decode_commit(&xdr, res);
5469 decode_getfattr(&xdr, res->fattr, res->server,
5470 !RPC_IS_ASYNC(rqstp->rq_task));
5476 * Decode FSINFO response
5478 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p,
5479 struct nfs4_fsinfo_res *res)
5481 struct xdr_stream xdr;
5482 struct compound_hdr hdr;
5485 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5486 status = decode_compound_hdr(&xdr, &hdr);
5488 status = decode_sequence(&xdr, &res->seq_res, req);
5490 status = decode_putfh(&xdr);
5492 status = decode_fsinfo(&xdr, res->fsinfo);
5497 * Decode PATHCONF response
5499 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p,
5500 struct nfs4_pathconf_res *res)
5502 struct xdr_stream xdr;
5503 struct compound_hdr hdr;
5506 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5507 status = decode_compound_hdr(&xdr, &hdr);
5509 status = decode_sequence(&xdr, &res->seq_res, req);
5511 status = decode_putfh(&xdr);
5513 status = decode_pathconf(&xdr, res->pathconf);
5518 * Decode STATFS response
5520 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p,
5521 struct nfs4_statfs_res *res)
5523 struct xdr_stream xdr;
5524 struct compound_hdr hdr;
5527 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5528 status = decode_compound_hdr(&xdr, &hdr);
5530 status = decode_sequence(&xdr, &res->seq_res, req);
5532 status = decode_putfh(&xdr);
5534 status = decode_statfs(&xdr, res->fsstat);
5539 * Decode GETATTR_BITMAP response
5541 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res)
5543 struct xdr_stream xdr;
5544 struct compound_hdr hdr;
5547 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5548 status = decode_compound_hdr(&xdr, &hdr);
5551 status = decode_sequence(&xdr, &res->seq_res, req);
5554 if ((status = decode_putfh(&xdr)) != 0)
5556 status = decode_server_caps(&xdr, res);
5562 * Decode RENEW response
5564 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
5566 struct xdr_stream xdr;
5567 struct compound_hdr hdr;
5570 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5571 status = decode_compound_hdr(&xdr, &hdr);
5573 status = decode_renew(&xdr);
5578 * Decode SETCLIENTID response
5580 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
5581 struct nfs4_setclientid_res *res)
5583 struct xdr_stream xdr;
5584 struct compound_hdr hdr;
5587 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5588 status = decode_compound_hdr(&xdr, &hdr);
5590 status = decode_setclientid(&xdr, res);
5595 * Decode SETCLIENTID_CONFIRM response
5597 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
5599 struct xdr_stream xdr;
5600 struct compound_hdr hdr;
5603 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5604 status = decode_compound_hdr(&xdr, &hdr);
5606 status = decode_setclientid_confirm(&xdr);
5608 status = decode_putrootfh(&xdr);
5610 status = decode_fsinfo(&xdr, fsinfo);
5615 * Decode DELEGRETURN response
5617 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res)
5619 struct xdr_stream xdr;
5620 struct compound_hdr hdr;
5623 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5624 status = decode_compound_hdr(&xdr, &hdr);
5627 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5630 status = decode_putfh(&xdr);
5633 status = decode_delegreturn(&xdr);
5636 decode_getfattr(&xdr, res->fattr, res->server,
5637 !RPC_IS_ASYNC(rqstp->rq_task));
5643 * Decode FS_LOCATIONS response
5645 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p,
5646 struct nfs4_fs_locations_res *res)
5648 struct xdr_stream xdr;
5649 struct compound_hdr hdr;
5652 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
5653 status = decode_compound_hdr(&xdr, &hdr);
5656 status = decode_sequence(&xdr, &res->seq_res, req);
5659 if ((status = decode_putfh(&xdr)) != 0)
5661 if ((status = decode_lookup(&xdr)) != 0)
5663 xdr_enter_page(&xdr, PAGE_SIZE);
5664 status = decode_getfattr(&xdr, &res->fs_locations->fattr,
5665 res->fs_locations->server,
5666 !RPC_IS_ASYNC(req->rq_task));
5671 #if defined(CONFIG_NFS_V4_1)
5673 * Decode EXCHANGE_ID response
5675 static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p,
5678 struct xdr_stream xdr;
5679 struct compound_hdr hdr;
5682 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5683 status = decode_compound_hdr(&xdr, &hdr);
5685 status = decode_exchange_id(&xdr, res);
5690 * Decode CREATE_SESSION response
5692 static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p,
5693 struct nfs41_create_session_res *res)
5695 struct xdr_stream xdr;
5696 struct compound_hdr hdr;
5699 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5700 status = decode_compound_hdr(&xdr, &hdr);
5702 status = decode_create_session(&xdr, res);
5707 * Decode DESTROY_SESSION response
5709 static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p,
5712 struct xdr_stream xdr;
5713 struct compound_hdr hdr;
5716 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5717 status = decode_compound_hdr(&xdr, &hdr);
5719 status = decode_destroy_session(&xdr, dummy);
5724 * Decode SEQUENCE response
5726 static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p,
5727 struct nfs4_sequence_res *res)
5729 struct xdr_stream xdr;
5730 struct compound_hdr hdr;
5733 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5734 status = decode_compound_hdr(&xdr, &hdr);
5736 status = decode_sequence(&xdr, res, rqstp);
5741 * Decode GET_LEASE_TIME response
5743 static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p,
5744 struct nfs4_get_lease_time_res *res)
5746 struct xdr_stream xdr;
5747 struct compound_hdr hdr;
5750 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5751 status = decode_compound_hdr(&xdr, &hdr);
5753 status = decode_sequence(&xdr, &res->lr_seq_res, rqstp);
5755 status = decode_putrootfh(&xdr);
5757 status = decode_fsinfo(&xdr, res->lr_fsinfo);
5762 * Decode RECLAIM_COMPLETE response
5764 static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p,
5765 struct nfs41_reclaim_complete_res *res)
5767 struct xdr_stream xdr;
5768 struct compound_hdr hdr;
5771 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
5772 status = decode_compound_hdr(&xdr, &hdr);
5774 status = decode_sequence(&xdr, &res->seq_res, rqstp);
5776 status = decode_reclaim_complete(&xdr, (void *)NULL);
5779 #endif /* CONFIG_NFS_V4_1 */
5781 __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
5782 struct nfs_server *server, int plus)
5784 uint32_t bitmap[2] = {0};
5786 __be32 *p = xdr_inline_decode(xdr, 4);
5790 p = xdr_inline_decode(xdr, 4);
5794 return ERR_PTR(-EAGAIN);
5796 return ERR_PTR(-EBADCOOKIE);
5799 p = xdr_inline_decode(xdr, 12);
5802 entry->prev_cookie = entry->cookie;
5803 p = xdr_decode_hyper(p, &entry->cookie);
5804 entry->len = ntohl(*p++);
5806 p = xdr_inline_decode(xdr, entry->len + 4);
5809 entry->name = (const char *) p;
5810 p += XDR_QUADLEN(entry->len);
5813 * In case the server doesn't return an inode number,
5814 * we fake one here. (We don't use inode number 0,
5815 * since glibc seems to choke on it...)
5819 len = ntohl(*p++); /* bitmap length */
5821 p = xdr_inline_decode(xdr, 4);
5824 bitmap[0] = ntohl(*p++);
5826 p = xdr_inline_decode(xdr, 4);
5829 bitmap[1] = ntohl(*p++);
5833 p = xdr_inline_decode(xdr, 4);
5836 len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */
5838 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, server, 1) < 0)
5840 if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
5841 entry->ino = entry->fattr->fileid;
5844 p = xdr_inline_peek(xdr, 8);
5846 entry->eof = !p[0] && p[1];
5853 print_overflow_msg(__func__, xdr);
5854 return ERR_PTR(-EIO);
5858 * We need to translate between nfs status return values and
5859 * the local errno values which may not be the same.
5866 { NFS4ERR_PERM, -EPERM },
5867 { NFS4ERR_NOENT, -ENOENT },
5868 { NFS4ERR_IO, -errno_NFSERR_IO},
5869 { NFS4ERR_NXIO, -ENXIO },
5870 { NFS4ERR_ACCESS, -EACCES },
5871 { NFS4ERR_EXIST, -EEXIST },
5872 { NFS4ERR_XDEV, -EXDEV },
5873 { NFS4ERR_NOTDIR, -ENOTDIR },
5874 { NFS4ERR_ISDIR, -EISDIR },
5875 { NFS4ERR_INVAL, -EINVAL },
5876 { NFS4ERR_FBIG, -EFBIG },
5877 { NFS4ERR_NOSPC, -ENOSPC },
5878 { NFS4ERR_ROFS, -EROFS },
5879 { NFS4ERR_MLINK, -EMLINK },
5880 { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
5881 { NFS4ERR_NOTEMPTY, -ENOTEMPTY },
5882 { NFS4ERR_DQUOT, -EDQUOT },
5883 { NFS4ERR_STALE, -ESTALE },
5884 { NFS4ERR_BADHANDLE, -EBADHANDLE },
5885 { NFS4ERR_BADOWNER, -EINVAL },
5886 { NFS4ERR_BADNAME, -EINVAL },
5887 { NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
5888 { NFS4ERR_NOTSUPP, -ENOTSUPP },
5889 { NFS4ERR_TOOSMALL, -ETOOSMALL },
5890 { NFS4ERR_SERVERFAULT, -EREMOTEIO },
5891 { NFS4ERR_BADTYPE, -EBADTYPE },
5892 { NFS4ERR_LOCKED, -EAGAIN },
5893 { NFS4ERR_SYMLINK, -ELOOP },
5894 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
5895 { NFS4ERR_DEADLOCK, -EDEADLK },
5896 { NFS4ERR_WRONGSEC, -EPERM }, /* FIXME: this needs
5897 * to be handled by a
5904 * Convert an NFS error code to a local one.
5905 * This one is used jointly by NFSv2 and NFSv3.
5908 nfs4_stat_to_errno(int stat)
5911 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
5912 if (nfs_errtbl[i].stat == stat)
5913 return nfs_errtbl[i].errno;
5915 if (stat <= 10000 || stat > 10100) {
5916 /* The server is looney tunes. */
5919 /* If we cannot translate the error, the recovery routines should
5921 * Note: remaining NFSv4 error codes have values > 10000, so should
5922 * not conflict with native Linux error codes.
5927 #define PROC(proc, argtype, restype) \
5928 [NFSPROC4_CLNT_##proc] = { \
5929 .p_proc = NFSPROC4_COMPOUND, \
5930 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
5931 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
5932 .p_arglen = NFS4_##argtype##_sz, \
5933 .p_replen = NFS4_##restype##_sz, \
5934 .p_statidx = NFSPROC4_CLNT_##proc, \
5938 struct rpc_procinfo nfs4_procedures[] = {
5939 PROC(READ, enc_read, dec_read),
5940 PROC(WRITE, enc_write, dec_write),
5941 PROC(COMMIT, enc_commit, dec_commit),
5942 PROC(OPEN, enc_open, dec_open),
5943 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
5944 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
5945 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
5946 PROC(CLOSE, enc_close, dec_close),
5947 PROC(SETATTR, enc_setattr, dec_setattr),
5948 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
5949 PROC(RENEW, enc_renew, dec_renew),
5950 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
5951 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
5952 PROC(LOCK, enc_lock, dec_lock),
5953 PROC(LOCKT, enc_lockt, dec_lockt),
5954 PROC(LOCKU, enc_locku, dec_locku),
5955 PROC(ACCESS, enc_access, dec_access),
5956 PROC(GETATTR, enc_getattr, dec_getattr),
5957 PROC(LOOKUP, enc_lookup, dec_lookup),
5958 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
5959 PROC(REMOVE, enc_remove, dec_remove),
5960 PROC(RENAME, enc_rename, dec_rename),
5961 PROC(LINK, enc_link, dec_link),
5962 PROC(SYMLINK, enc_symlink, dec_symlink),
5963 PROC(CREATE, enc_create, dec_create),
5964 PROC(PATHCONF, enc_pathconf, dec_pathconf),
5965 PROC(STATFS, enc_statfs, dec_statfs),
5966 PROC(READLINK, enc_readlink, dec_readlink),
5967 PROC(READDIR, enc_readdir, dec_readdir),
5968 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
5969 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
5970 PROC(GETACL, enc_getacl, dec_getacl),
5971 PROC(SETACL, enc_setacl, dec_setacl),
5972 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
5973 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
5974 #if defined(CONFIG_NFS_V4_1)
5975 PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
5976 PROC(CREATE_SESSION, enc_create_session, dec_create_session),
5977 PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
5978 PROC(SEQUENCE, enc_sequence, dec_sequence),
5979 PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time),
5980 PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete),
5981 #endif /* CONFIG_NFS_V4_1 */
5984 struct rpc_version nfs_version4 = {
5986 .nrprocs = ARRAY_SIZE(nfs4_procedures),
5987 .procs = nfs4_procedures