4 * Client-side XDR for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <linux/param.h>
39 #include <linux/time.h>
41 #include <linux/errno.h>
42 #include <linux/string.h>
44 #include <linux/pagemap.h>
45 #include <linux/proc_fs.h>
46 #include <linux/kdev_t.h>
47 #include <linux/module.h>
48 #include <linux/utsname.h>
49 #include <linux/sunrpc/clnt.h>
50 #include <linux/sunrpc/msg_prot.h>
51 #include <linux/sunrpc/gss_api.h>
52 #include <linux/nfs.h>
53 #include <linux/nfs4.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/nfs_idmap.h>
59 #include "nfs4session.h"
63 #define NFSDBG_FACILITY NFSDBG_XDR
65 /* Mapping from NFS error code to "errno" error code. */
66 #define errno_NFSERR_IO EIO
68 static int nfs4_stat_to_errno(int);
70 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
72 #define NFS4_MAXTAGLEN 20
74 #define NFS4_MAXTAGLEN 0
77 /* lock,open owner id:
78 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
80 #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2)
81 #define lock_owner_id_maxsz (1 + 1 + 4)
82 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
83 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
84 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
85 #define op_encode_hdr_maxsz (1)
86 #define op_decode_hdr_maxsz (2)
87 #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
88 #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
89 #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
90 #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
91 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
93 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
94 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
95 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
96 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
97 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
98 ((3+NFS4_FHSIZE) >> 2))
99 #define nfs4_fattr_bitmap_maxsz 4
100 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
101 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
102 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
103 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
104 #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
105 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
106 /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */
107 #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN))
108 #define encode_readdir_space 24
109 #define encode_readdir_bitmask_sz 3
111 #define nfs4_label_maxsz 0
112 #define encode_readdir_space 20
113 #define encode_readdir_bitmask_sz 2
115 /* We support only one layout type per file system */
116 #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8)
117 /* This is based on getfattr, which uses the most attributes: */
118 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
119 3 + 3 + 3 + nfs4_owner_maxsz + \
120 nfs4_group_maxsz + nfs4_label_maxsz + \
121 decode_mdsthreshold_maxsz))
122 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
123 nfs4_fattr_value_maxsz)
124 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
125 #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
131 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
132 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
133 #define encode_restorefh_maxsz (op_encode_hdr_maxsz)
134 #define decode_restorefh_maxsz (op_decode_hdr_maxsz)
135 #define encode_fsinfo_maxsz (encode_getattr_maxsz)
136 /* The 5 accounts for the PNFS attributes, and assumes that at most three
137 * layout types will be returned.
139 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \
140 nfs4_fattr_bitmap_maxsz + 4 + 8 + 5)
141 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
142 #define decode_renew_maxsz (op_decode_hdr_maxsz)
143 #define encode_setclientid_maxsz \
144 (op_encode_hdr_maxsz + \
145 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
146 XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \
148 XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
149 XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
151 #define decode_setclientid_maxsz \
152 (op_decode_hdr_maxsz + \
154 1024) /* large value for CLID_INUSE */
155 #define encode_setclientid_confirm_maxsz \
156 (op_encode_hdr_maxsz + \
157 3 + (NFS4_VERIFIER_SIZE >> 2))
158 #define decode_setclientid_confirm_maxsz \
159 (op_decode_hdr_maxsz)
160 #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
161 #define decode_lookup_maxsz (op_decode_hdr_maxsz)
162 #define encode_share_access_maxsz \
164 #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
165 #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
166 #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
167 #define encode_open_maxsz (op_encode_hdr_maxsz + \
168 2 + encode_share_access_maxsz + 2 + \
169 open_owner_id_maxsz + \
170 encode_opentype_maxsz + \
171 encode_claim_null_maxsz)
172 #define decode_ace_maxsz (3 + nfs4_owner_maxsz)
173 #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
175 #define decode_change_info_maxsz (5)
176 #define decode_open_maxsz (op_decode_hdr_maxsz + \
177 decode_stateid_maxsz + \
178 decode_change_info_maxsz + 1 + \
179 nfs4_fattr_bitmap_maxsz + \
180 decode_delegation_maxsz)
181 #define encode_open_confirm_maxsz \
182 (op_encode_hdr_maxsz + \
183 encode_stateid_maxsz + 1)
184 #define decode_open_confirm_maxsz \
185 (op_decode_hdr_maxsz + \
186 decode_stateid_maxsz)
187 #define encode_open_downgrade_maxsz \
188 (op_encode_hdr_maxsz + \
189 encode_stateid_maxsz + 1 + \
190 encode_share_access_maxsz)
191 #define decode_open_downgrade_maxsz \
192 (op_decode_hdr_maxsz + \
193 decode_stateid_maxsz)
194 #define encode_close_maxsz (op_encode_hdr_maxsz + \
195 1 + encode_stateid_maxsz)
196 #define decode_close_maxsz (op_decode_hdr_maxsz + \
197 decode_stateid_maxsz)
198 #define encode_setattr_maxsz (op_encode_hdr_maxsz + \
199 encode_stateid_maxsz + \
201 #define decode_setattr_maxsz (op_decode_hdr_maxsz + \
202 nfs4_fattr_bitmap_maxsz)
203 #define encode_read_maxsz (op_encode_hdr_maxsz + \
204 encode_stateid_maxsz + 3)
205 #define decode_read_maxsz (op_decode_hdr_maxsz + 2)
206 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
207 2 + encode_verifier_maxsz + 5 + \
209 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
210 decode_verifier_maxsz + \
211 nfs4_label_maxsz + nfs4_fattr_maxsz)
212 #define encode_readlink_maxsz (op_encode_hdr_maxsz)
213 #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1)
214 #define encode_write_maxsz (op_encode_hdr_maxsz + \
215 encode_stateid_maxsz + 4)
216 #define decode_write_maxsz (op_decode_hdr_maxsz + \
217 2 + decode_verifier_maxsz)
218 #define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
219 #define decode_commit_maxsz (op_decode_hdr_maxsz + \
220 decode_verifier_maxsz)
221 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
223 #define decode_remove_maxsz (op_decode_hdr_maxsz + \
224 decode_change_info_maxsz)
225 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
227 #define decode_rename_maxsz (op_decode_hdr_maxsz + \
228 decode_change_info_maxsz + \
229 decode_change_info_maxsz)
230 #define encode_link_maxsz (op_encode_hdr_maxsz + \
232 #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
233 #define encode_lockowner_maxsz (7)
234 #define encode_lock_maxsz (op_encode_hdr_maxsz + \
236 1 + encode_stateid_maxsz + 1 + \
237 encode_lockowner_maxsz)
238 #define decode_lock_denied_maxsz \
239 (8 + decode_lockowner_maxsz)
240 #define decode_lock_maxsz (op_decode_hdr_maxsz + \
241 decode_lock_denied_maxsz)
242 #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \
243 encode_lockowner_maxsz)
244 #define decode_lockt_maxsz (op_decode_hdr_maxsz + \
245 decode_lock_denied_maxsz)
246 #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
247 encode_stateid_maxsz + \
249 #define decode_locku_maxsz (op_decode_hdr_maxsz + \
250 decode_stateid_maxsz)
251 #define encode_release_lockowner_maxsz \
252 (op_encode_hdr_maxsz + \
253 encode_lockowner_maxsz)
254 #define decode_release_lockowner_maxsz \
255 (op_decode_hdr_maxsz)
256 #define encode_access_maxsz (op_encode_hdr_maxsz + 1)
257 #define decode_access_maxsz (op_decode_hdr_maxsz + 2)
258 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
259 1 + nfs4_name_maxsz + \
262 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
263 #define encode_create_maxsz (op_encode_hdr_maxsz + \
264 1 + 2 + nfs4_name_maxsz + \
266 #define decode_create_maxsz (op_decode_hdr_maxsz + \
267 decode_change_info_maxsz + \
268 nfs4_fattr_bitmap_maxsz)
269 #define encode_statfs_maxsz (encode_getattr_maxsz)
270 #define decode_statfs_maxsz (decode_getattr_maxsz)
271 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
272 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
273 #define encode_getacl_maxsz (encode_getattr_maxsz)
274 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
275 nfs4_fattr_bitmap_maxsz + 1)
276 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
277 encode_stateid_maxsz + 3)
278 #define decode_setacl_maxsz (decode_setattr_maxsz)
279 #define encode_fs_locations_maxsz \
280 (encode_getattr_maxsz)
281 #define decode_fs_locations_maxsz \
283 #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
284 #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
286 #if defined(CONFIG_NFS_V4_1)
287 #define NFS4_MAX_MACHINE_NAME_LEN (64)
288 #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \
289 sizeof(utsname()->version) + sizeof(utsname()->machine) + 8)
291 #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
292 encode_verifier_maxsz + \
293 1 /* co_ownerid.len */ + \
294 XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \
297 0 /* SP4_NONE (for now) */ + \
298 1 /* implementation id array of size 1 */ + \
299 1 /* nii_domain */ + \
300 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
302 XDR_QUADLEN(IMPL_NAME_LIMIT) + \
304 #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
305 2 /* eir_clientid */ + \
306 1 /* eir_sequenceid */ + \
307 1 /* eir_flags */ + \
309 0 /* SP4_NONE (for now) */ + \
310 2 /* eir_server_owner.so_minor_id */ + \
311 /* eir_server_owner.so_major_id<> */ \
312 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
313 /* eir_server_scope<> */ \
314 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
315 1 /* eir_server_impl_id array length */ + \
316 1 /* nii_domain */ + \
317 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
319 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
321 #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */)
322 #define decode_channel_attrs_maxsz (6 + \
323 1 /* ca_rdma_ird.len */ + \
325 #define encode_create_session_maxsz (op_encode_hdr_maxsz + \
326 2 /* csa_clientid */ + \
327 1 /* csa_sequence */ + \
328 1 /* csa_flags */ + \
329 encode_channel_attrs_maxsz + \
330 encode_channel_attrs_maxsz + \
331 1 /* csa_cb_program */ + \
332 1 /* csa_sec_parms.len (1) */ + \
333 1 /* cb_secflavor (AUTH_SYS) */ + \
335 1 /* machinename.len */ + \
336 XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \
339 1 /* gids.len (0) */)
340 #define decode_create_session_maxsz (op_decode_hdr_maxsz + \
341 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
342 1 /* csr_sequence */ + \
343 1 /* csr_flags */ + \
344 decode_channel_attrs_maxsz + \
345 decode_channel_attrs_maxsz)
346 #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \
348 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
349 1 /* bctsa_dir */ + \
350 1 /* bctsa_use_conn_in_rdma_mode */)
351 #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \
353 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
354 1 /* bctsr_dir */ + \
355 1 /* bctsr_use_conn_in_rdma_mode */)
356 #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)
357 #define decode_destroy_session_maxsz (op_decode_hdr_maxsz)
358 #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2)
359 #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz)
360 #define encode_sequence_maxsz (op_encode_hdr_maxsz + \
361 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
362 #define decode_sequence_maxsz (op_decode_hdr_maxsz + \
363 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
364 #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
365 #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
366 #define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \
367 encode_verifier_maxsz)
368 #define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \
369 2 /* nfs_cookie4 gdlr_cookie */ + \
370 decode_verifier_maxsz \
371 /* verifier4 gdlr_verifier */ + \
372 1 /* gdlr_deviceid_list count */ + \
373 XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \
374 NFS4_DEVICEID4_SIZE) \
375 /* gdlr_deviceid_list */ + \
376 1 /* bool gdlr_eof */)
377 #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \
378 XDR_QUADLEN(NFS4_DEVICEID4_SIZE))
379 #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \
380 1 /* layout type */ + \
381 1 /* opaque devaddr4 length */ + \
382 /* devaddr4 payload is read into page */ \
383 1 /* notification bitmap length */ + \
384 1 /* notification bitmap */)
385 #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \
386 encode_stateid_maxsz)
387 #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \
388 decode_stateid_maxsz + \
389 XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE))
390 #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \
394 encode_stateid_maxsz + \
395 1 /* new offset (true) */ + \
396 2 /* last byte written */ + \
397 1 /* nt_timechanged (false) */ + \
398 1 /* layoutupdate4 layout type */ + \
399 1 /* NULL filelayout layoutupdate4 payload */)
400 #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3)
401 #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \
402 encode_stateid_maxsz + \
403 1 /* FIXME: opaque lrf_body always empty at the moment */)
404 #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \
405 1 + decode_stateid_maxsz)
406 #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1)
407 #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz
408 #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \
409 XDR_QUADLEN(NFS4_STATEID_SIZE))
410 #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1)
411 #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \
412 XDR_QUADLEN(NFS4_STATEID_SIZE))
413 #define decode_free_stateid_maxsz (op_decode_hdr_maxsz + 1)
414 #else /* CONFIG_NFS_V4_1 */
415 #define encode_sequence_maxsz 0
416 #define decode_sequence_maxsz 0
417 #endif /* CONFIG_NFS_V4_1 */
419 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
420 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
421 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
422 encode_sequence_maxsz + \
423 encode_putfh_maxsz + \
425 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
426 decode_sequence_maxsz + \
427 decode_putfh_maxsz + \
429 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
430 encode_sequence_maxsz + \
431 encode_putfh_maxsz + \
432 encode_readlink_maxsz)
433 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
434 decode_sequence_maxsz + \
435 decode_putfh_maxsz + \
436 decode_readlink_maxsz)
437 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
438 encode_sequence_maxsz + \
439 encode_putfh_maxsz + \
440 encode_readdir_maxsz)
441 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
442 decode_sequence_maxsz + \
443 decode_putfh_maxsz + \
444 decode_readdir_maxsz)
445 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
446 encode_sequence_maxsz + \
447 encode_putfh_maxsz + \
448 encode_write_maxsz + \
449 encode_getattr_maxsz)
450 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
451 decode_sequence_maxsz + \
452 decode_putfh_maxsz + \
453 decode_write_maxsz + \
454 decode_getattr_maxsz)
455 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
456 encode_sequence_maxsz + \
457 encode_putfh_maxsz + \
459 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
460 decode_sequence_maxsz + \
461 decode_putfh_maxsz + \
463 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
464 encode_sequence_maxsz + \
465 encode_putfh_maxsz + \
466 encode_open_maxsz + \
467 encode_access_maxsz + \
468 encode_getfh_maxsz + \
469 encode_getattr_maxsz)
470 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
471 decode_sequence_maxsz + \
472 decode_putfh_maxsz + \
473 decode_open_maxsz + \
474 decode_access_maxsz + \
475 decode_getfh_maxsz + \
476 decode_getattr_maxsz)
477 #define NFS4_enc_open_confirm_sz \
478 (compound_encode_hdr_maxsz + \
479 encode_putfh_maxsz + \
480 encode_open_confirm_maxsz)
481 #define NFS4_dec_open_confirm_sz \
482 (compound_decode_hdr_maxsz + \
483 decode_putfh_maxsz + \
484 decode_open_confirm_maxsz)
485 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
486 encode_sequence_maxsz + \
487 encode_putfh_maxsz + \
488 encode_open_maxsz + \
489 encode_access_maxsz + \
490 encode_getattr_maxsz)
491 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
492 decode_sequence_maxsz + \
493 decode_putfh_maxsz + \
494 decode_open_maxsz + \
495 decode_access_maxsz + \
496 decode_getattr_maxsz)
497 #define NFS4_enc_open_downgrade_sz \
498 (compound_encode_hdr_maxsz + \
499 encode_sequence_maxsz + \
500 encode_putfh_maxsz + \
501 encode_open_downgrade_maxsz + \
502 encode_getattr_maxsz)
503 #define NFS4_dec_open_downgrade_sz \
504 (compound_decode_hdr_maxsz + \
505 decode_sequence_maxsz + \
506 decode_putfh_maxsz + \
507 decode_open_downgrade_maxsz + \
508 decode_getattr_maxsz)
509 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
510 encode_sequence_maxsz + \
511 encode_putfh_maxsz + \
512 encode_close_maxsz + \
513 encode_getattr_maxsz)
514 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
515 decode_sequence_maxsz + \
516 decode_putfh_maxsz + \
517 decode_close_maxsz + \
518 decode_getattr_maxsz)
519 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
520 encode_sequence_maxsz + \
521 encode_putfh_maxsz + \
522 encode_setattr_maxsz + \
523 encode_getattr_maxsz)
524 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
525 decode_sequence_maxsz + \
526 decode_putfh_maxsz + \
527 decode_setattr_maxsz + \
528 decode_getattr_maxsz)
529 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
530 encode_sequence_maxsz + \
531 encode_putfh_maxsz + \
533 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
534 decode_sequence_maxsz + \
535 decode_putfh_maxsz + \
537 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
539 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
541 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
542 encode_setclientid_maxsz)
543 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
544 decode_setclientid_maxsz)
545 #define NFS4_enc_setclientid_confirm_sz \
546 (compound_encode_hdr_maxsz + \
547 encode_setclientid_confirm_maxsz)
548 #define NFS4_dec_setclientid_confirm_sz \
549 (compound_decode_hdr_maxsz + \
550 decode_setclientid_confirm_maxsz)
551 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
552 encode_sequence_maxsz + \
553 encode_putfh_maxsz + \
555 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
556 decode_sequence_maxsz + \
557 decode_putfh_maxsz + \
559 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
560 encode_sequence_maxsz + \
561 encode_putfh_maxsz + \
563 #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
564 decode_sequence_maxsz + \
565 decode_putfh_maxsz + \
567 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
568 encode_sequence_maxsz + \
569 encode_putfh_maxsz + \
571 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
572 decode_sequence_maxsz + \
573 decode_putfh_maxsz + \
575 #define NFS4_enc_release_lockowner_sz \
576 (compound_encode_hdr_maxsz + \
577 encode_lockowner_maxsz)
578 #define NFS4_dec_release_lockowner_sz \
579 (compound_decode_hdr_maxsz + \
580 decode_lockowner_maxsz)
581 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
582 encode_sequence_maxsz + \
583 encode_putfh_maxsz + \
584 encode_access_maxsz + \
585 encode_getattr_maxsz)
586 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
587 decode_sequence_maxsz + \
588 decode_putfh_maxsz + \
589 decode_access_maxsz + \
590 decode_getattr_maxsz)
591 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
592 encode_sequence_maxsz + \
593 encode_putfh_maxsz + \
594 encode_getattr_maxsz)
595 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
596 decode_sequence_maxsz + \
597 decode_putfh_maxsz + \
598 decode_getattr_maxsz)
599 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
600 encode_sequence_maxsz + \
601 encode_putfh_maxsz + \
602 encode_lookup_maxsz + \
603 encode_getattr_maxsz + \
605 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
606 decode_sequence_maxsz + \
607 decode_putfh_maxsz + \
608 decode_lookup_maxsz + \
609 decode_getattr_maxsz + \
611 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
612 encode_sequence_maxsz + \
613 encode_putrootfh_maxsz + \
614 encode_getattr_maxsz + \
616 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
617 decode_sequence_maxsz + \
618 decode_putrootfh_maxsz + \
619 decode_getattr_maxsz + \
621 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
622 encode_sequence_maxsz + \
623 encode_putfh_maxsz + \
625 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
626 decode_sequence_maxsz + \
627 decode_putfh_maxsz + \
629 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
630 encode_sequence_maxsz + \
631 encode_putfh_maxsz + \
632 encode_savefh_maxsz + \
633 encode_putfh_maxsz + \
635 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
636 decode_sequence_maxsz + \
637 decode_putfh_maxsz + \
638 decode_savefh_maxsz + \
639 decode_putfh_maxsz + \
641 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
642 encode_sequence_maxsz + \
643 encode_putfh_maxsz + \
644 encode_savefh_maxsz + \
645 encode_putfh_maxsz + \
646 encode_link_maxsz + \
647 encode_restorefh_maxsz + \
648 encode_getattr_maxsz)
649 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
650 decode_sequence_maxsz + \
651 decode_putfh_maxsz + \
652 decode_savefh_maxsz + \
653 decode_putfh_maxsz + \
654 decode_link_maxsz + \
655 decode_restorefh_maxsz + \
656 decode_getattr_maxsz)
657 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
658 encode_sequence_maxsz + \
659 encode_putfh_maxsz + \
660 encode_symlink_maxsz + \
661 encode_getattr_maxsz + \
663 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
664 decode_sequence_maxsz + \
665 decode_putfh_maxsz + \
666 decode_symlink_maxsz + \
667 decode_getattr_maxsz + \
669 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
670 encode_sequence_maxsz + \
671 encode_putfh_maxsz + \
672 encode_create_maxsz + \
673 encode_getfh_maxsz + \
674 encode_getattr_maxsz)
675 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
676 decode_sequence_maxsz + \
677 decode_putfh_maxsz + \
678 decode_create_maxsz + \
679 decode_getfh_maxsz + \
680 decode_getattr_maxsz)
681 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
682 encode_sequence_maxsz + \
683 encode_putfh_maxsz + \
684 encode_getattr_maxsz)
685 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
686 decode_sequence_maxsz + \
687 decode_putfh_maxsz + \
688 decode_getattr_maxsz)
689 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
690 encode_sequence_maxsz + \
691 encode_putfh_maxsz + \
693 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
694 decode_sequence_maxsz + \
695 decode_putfh_maxsz + \
697 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
698 encode_sequence_maxsz + \
699 encode_putfh_maxsz + \
700 encode_getattr_maxsz)
701 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
702 decode_sequence_maxsz + \
703 decode_putfh_maxsz + \
704 decode_getattr_maxsz)
705 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
706 encode_sequence_maxsz + \
707 encode_putfh_maxsz + \
708 encode_delegreturn_maxsz + \
709 encode_getattr_maxsz)
710 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
711 decode_sequence_maxsz + \
712 decode_delegreturn_maxsz + \
713 decode_getattr_maxsz)
714 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
715 encode_sequence_maxsz + \
716 encode_putfh_maxsz + \
718 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
719 decode_sequence_maxsz + \
720 decode_putfh_maxsz + \
722 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
723 encode_sequence_maxsz + \
724 encode_putfh_maxsz + \
726 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
727 decode_sequence_maxsz + \
728 decode_putfh_maxsz + \
730 #define NFS4_enc_fs_locations_sz \
731 (compound_encode_hdr_maxsz + \
732 encode_sequence_maxsz + \
733 encode_putfh_maxsz + \
734 encode_lookup_maxsz + \
735 encode_fs_locations_maxsz)
736 #define NFS4_dec_fs_locations_sz \
737 (compound_decode_hdr_maxsz + \
738 decode_sequence_maxsz + \
739 decode_putfh_maxsz + \
740 decode_lookup_maxsz + \
741 decode_fs_locations_maxsz)
742 #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \
743 encode_sequence_maxsz + \
744 encode_putfh_maxsz + \
745 encode_secinfo_maxsz)
746 #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \
747 decode_sequence_maxsz + \
748 decode_putfh_maxsz + \
749 decode_secinfo_maxsz)
750 #if defined(CONFIG_NFS_V4_1)
751 #define NFS4_enc_bind_conn_to_session_sz \
752 (compound_encode_hdr_maxsz + \
753 encode_bind_conn_to_session_maxsz)
754 #define NFS4_dec_bind_conn_to_session_sz \
755 (compound_decode_hdr_maxsz + \
756 decode_bind_conn_to_session_maxsz)
757 #define NFS4_enc_exchange_id_sz \
758 (compound_encode_hdr_maxsz + \
759 encode_exchange_id_maxsz)
760 #define NFS4_dec_exchange_id_sz \
761 (compound_decode_hdr_maxsz + \
762 decode_exchange_id_maxsz)
763 #define NFS4_enc_create_session_sz \
764 (compound_encode_hdr_maxsz + \
765 encode_create_session_maxsz)
766 #define NFS4_dec_create_session_sz \
767 (compound_decode_hdr_maxsz + \
768 decode_create_session_maxsz)
769 #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \
770 encode_destroy_session_maxsz)
771 #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \
772 decode_destroy_session_maxsz)
773 #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \
774 encode_destroy_clientid_maxsz)
775 #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \
776 decode_destroy_clientid_maxsz)
777 #define NFS4_enc_sequence_sz \
778 (compound_decode_hdr_maxsz + \
779 encode_sequence_maxsz)
780 #define NFS4_dec_sequence_sz \
781 (compound_decode_hdr_maxsz + \
782 decode_sequence_maxsz)
783 #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \
784 encode_sequence_maxsz + \
785 encode_putrootfh_maxsz + \
787 #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \
788 decode_sequence_maxsz + \
789 decode_putrootfh_maxsz + \
791 #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
792 encode_sequence_maxsz + \
793 encode_reclaim_complete_maxsz)
794 #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \
795 decode_sequence_maxsz + \
796 decode_reclaim_complete_maxsz)
797 #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \
798 encode_sequence_maxsz + \
799 encode_putfh_maxsz + \
800 encode_getdevicelist_maxsz)
801 #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \
802 decode_sequence_maxsz + \
803 decode_putfh_maxsz + \
804 decode_getdevicelist_maxsz)
805 #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \
806 encode_sequence_maxsz +\
807 encode_getdeviceinfo_maxsz)
808 #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \
809 decode_sequence_maxsz + \
810 decode_getdeviceinfo_maxsz)
811 #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \
812 encode_sequence_maxsz + \
813 encode_putfh_maxsz + \
814 encode_layoutget_maxsz)
815 #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \
816 decode_sequence_maxsz + \
817 decode_putfh_maxsz + \
818 decode_layoutget_maxsz)
819 #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \
820 encode_sequence_maxsz +\
821 encode_putfh_maxsz + \
822 encode_layoutcommit_maxsz + \
823 encode_getattr_maxsz)
824 #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \
825 decode_sequence_maxsz + \
826 decode_putfh_maxsz + \
827 decode_layoutcommit_maxsz + \
828 decode_getattr_maxsz)
829 #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \
830 encode_sequence_maxsz + \
831 encode_putfh_maxsz + \
832 encode_layoutreturn_maxsz)
833 #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \
834 decode_sequence_maxsz + \
835 decode_putfh_maxsz + \
836 decode_layoutreturn_maxsz)
837 #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \
838 encode_sequence_maxsz + \
839 encode_putrootfh_maxsz +\
840 encode_secinfo_no_name_maxsz)
841 #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \
842 decode_sequence_maxsz + \
843 decode_putrootfh_maxsz + \
844 decode_secinfo_no_name_maxsz)
845 #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \
846 encode_sequence_maxsz + \
847 encode_test_stateid_maxsz)
848 #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \
849 decode_sequence_maxsz + \
850 decode_test_stateid_maxsz)
851 #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \
852 encode_sequence_maxsz + \
853 encode_free_stateid_maxsz)
854 #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \
855 decode_sequence_maxsz + \
856 decode_free_stateid_maxsz)
858 const u32 nfs41_maxwrite_overhead
= ((RPC_MAX_HEADER_WITH_AUTH
+
859 compound_encode_hdr_maxsz
+
860 encode_sequence_maxsz
+
862 encode_getattr_maxsz
) *
865 const u32 nfs41_maxread_overhead
= ((RPC_MAX_HEADER_WITH_AUTH
+
866 compound_decode_hdr_maxsz
+
867 decode_sequence_maxsz
+
868 decode_putfh_maxsz
) *
871 const u32 nfs41_maxgetdevinfo_overhead
= ((RPC_MAX_REPHEADER_WITH_AUTH
+
872 compound_decode_hdr_maxsz
+
873 decode_sequence_maxsz
) *
875 EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead
);
876 #endif /* CONFIG_NFS_V4_1 */
878 static const umode_t nfs_type2fmt
[] = {
885 [NF4SOCK
] = S_IFSOCK
,
891 struct compound_hdr
{
897 uint32_t replen
; /* expected reply words */
901 static __be32
*reserve_space(struct xdr_stream
*xdr
, size_t nbytes
)
903 __be32
*p
= xdr_reserve_space(xdr
, nbytes
);
908 static void encode_opaque_fixed(struct xdr_stream
*xdr
, const void *buf
, size_t len
)
912 p
= xdr_reserve_space(xdr
, len
);
913 xdr_encode_opaque_fixed(p
, buf
, len
);
916 static void encode_string(struct xdr_stream
*xdr
, unsigned int len
, const char *str
)
920 p
= reserve_space(xdr
, 4 + len
);
921 xdr_encode_opaque(p
, str
, len
);
924 static void encode_uint32(struct xdr_stream
*xdr
, u32 n
)
928 p
= reserve_space(xdr
, 4);
932 static void encode_uint64(struct xdr_stream
*xdr
, u64 n
)
936 p
= reserve_space(xdr
, 8);
937 xdr_encode_hyper(p
, n
);
940 static void encode_nfs4_seqid(struct xdr_stream
*xdr
,
941 const struct nfs_seqid
*seqid
)
943 encode_uint32(xdr
, seqid
->sequence
->counter
);
946 static void encode_compound_hdr(struct xdr_stream
*xdr
,
947 struct rpc_rqst
*req
,
948 struct compound_hdr
*hdr
)
951 struct rpc_auth
*auth
= req
->rq_cred
->cr_auth
;
953 /* initialize running count of expected bytes in reply.
954 * NOTE: the replied tag SHOULD be the same is the one sent,
955 * but this is not required as a MUST for the server to do so. */
956 hdr
->replen
= RPC_REPHDRSIZE
+ auth
->au_rslack
+ 3 + hdr
->taglen
;
958 WARN_ON_ONCE(hdr
->taglen
> NFS4_MAXTAGLEN
);
959 encode_string(xdr
, hdr
->taglen
, hdr
->tag
);
960 p
= reserve_space(xdr
, 8);
961 *p
++ = cpu_to_be32(hdr
->minorversion
);
963 *p
= cpu_to_be32(hdr
->nops
);
966 static void encode_op_hdr(struct xdr_stream
*xdr
, enum nfs_opnum4 op
,
968 struct compound_hdr
*hdr
)
970 encode_uint32(xdr
, op
);
972 hdr
->replen
+= replen
;
975 static void encode_nops(struct compound_hdr
*hdr
)
977 WARN_ON_ONCE(hdr
->nops
> NFS4_MAX_OPS
);
978 *hdr
->nops_p
= htonl(hdr
->nops
);
981 static void encode_nfs4_stateid(struct xdr_stream
*xdr
, const nfs4_stateid
*stateid
)
983 encode_opaque_fixed(xdr
, stateid
, NFS4_STATEID_SIZE
);
986 static void encode_nfs4_verifier(struct xdr_stream
*xdr
, const nfs4_verifier
*verf
)
988 encode_opaque_fixed(xdr
, verf
->data
, NFS4_VERIFIER_SIZE
);
991 static void encode_attrs(struct xdr_stream
*xdr
, const struct iattr
*iap
,
992 const struct nfs4_label
*label
,
993 const struct nfs_server
*server
)
995 char owner_name
[IDMAP_NAMESZ
];
996 char owner_group
[IDMAP_NAMESZ
];
997 int owner_namelen
= 0;
998 int owner_grouplen
= 0;
1002 uint32_t bmval0
= 0;
1003 uint32_t bmval1
= 0;
1004 uint32_t bmval2
= 0;
1007 * We reserve enough space to write the entire attribute buffer at once.
1008 * In the worst-case, this would be
1009 * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime)
1010 * = 40 bytes, plus any contribution from variable-length fields
1011 * such as owner/group.
1016 if (iap
->ia_valid
& ATTR_SIZE
)
1018 if (iap
->ia_valid
& ATTR_MODE
)
1020 if (iap
->ia_valid
& ATTR_UID
) {
1021 owner_namelen
= nfs_map_uid_to_name(server
, iap
->ia_uid
, owner_name
, IDMAP_NAMESZ
);
1022 if (owner_namelen
< 0) {
1023 dprintk("nfs: couldn't resolve uid %d to string\n",
1024 from_kuid(&init_user_ns
, iap
->ia_uid
));
1026 strcpy(owner_name
, "nobody");
1027 owner_namelen
= sizeof("nobody") - 1;
1030 len
+= 4 + (XDR_QUADLEN(owner_namelen
) << 2);
1032 if (iap
->ia_valid
& ATTR_GID
) {
1033 owner_grouplen
= nfs_map_gid_to_group(server
, iap
->ia_gid
, owner_group
, IDMAP_NAMESZ
);
1034 if (owner_grouplen
< 0) {
1035 dprintk("nfs: couldn't resolve gid %d to string\n",
1036 from_kgid(&init_user_ns
, iap
->ia_gid
));
1037 strcpy(owner_group
, "nobody");
1038 owner_grouplen
= sizeof("nobody") - 1;
1041 len
+= 4 + (XDR_QUADLEN(owner_grouplen
) << 2);
1044 len
+= 4 + 4 + 4 + (XDR_QUADLEN(label
->len
) << 2);
1045 if (iap
->ia_valid
& ATTR_ATIME_SET
)
1047 else if (iap
->ia_valid
& ATTR_ATIME
)
1049 if (iap
->ia_valid
& ATTR_MTIME_SET
)
1051 else if (iap
->ia_valid
& ATTR_MTIME
)
1053 p
= reserve_space(xdr
, len
);
1056 * We write the bitmap length now, but leave the bitmap and the attribute
1057 * buffer length to be backfilled at the end of this routine.
1059 *p
++ = cpu_to_be32(3);
1063 if (iap
->ia_valid
& ATTR_SIZE
) {
1064 bmval0
|= FATTR4_WORD0_SIZE
;
1065 p
= xdr_encode_hyper(p
, iap
->ia_size
);
1067 if (iap
->ia_valid
& ATTR_MODE
) {
1068 bmval1
|= FATTR4_WORD1_MODE
;
1069 *p
++ = cpu_to_be32(iap
->ia_mode
& S_IALLUGO
);
1071 if (iap
->ia_valid
& ATTR_UID
) {
1072 bmval1
|= FATTR4_WORD1_OWNER
;
1073 p
= xdr_encode_opaque(p
, owner_name
, owner_namelen
);
1075 if (iap
->ia_valid
& ATTR_GID
) {
1076 bmval1
|= FATTR4_WORD1_OWNER_GROUP
;
1077 p
= xdr_encode_opaque(p
, owner_group
, owner_grouplen
);
1079 if (iap
->ia_valid
& ATTR_ATIME_SET
) {
1080 bmval1
|= FATTR4_WORD1_TIME_ACCESS_SET
;
1081 *p
++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME
);
1082 p
= xdr_encode_hyper(p
, (s64
)iap
->ia_atime
.tv_sec
);
1083 *p
++ = cpu_to_be32(iap
->ia_atime
.tv_nsec
);
1085 else if (iap
->ia_valid
& ATTR_ATIME
) {
1086 bmval1
|= FATTR4_WORD1_TIME_ACCESS_SET
;
1087 *p
++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME
);
1089 if (iap
->ia_valid
& ATTR_MTIME_SET
) {
1090 bmval1
|= FATTR4_WORD1_TIME_MODIFY_SET
;
1091 *p
++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME
);
1092 p
= xdr_encode_hyper(p
, (s64
)iap
->ia_mtime
.tv_sec
);
1093 *p
++ = cpu_to_be32(iap
->ia_mtime
.tv_nsec
);
1095 else if (iap
->ia_valid
& ATTR_MTIME
) {
1096 bmval1
|= FATTR4_WORD1_TIME_MODIFY_SET
;
1097 *p
++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME
);
1100 bmval2
|= FATTR4_WORD2_SECURITY_LABEL
;
1101 *p
++ = cpu_to_be32(label
->lfs
);
1102 *p
++ = cpu_to_be32(label
->pi
);
1103 *p
++ = cpu_to_be32(label
->len
);
1104 p
= xdr_encode_opaque_fixed(p
, label
->label
, label
->len
);
1108 * Now we backfill the bitmap and the attribute buffer length.
1110 if (len
!= ((char *)p
- (char *)q
) + 4) {
1111 printk(KERN_ERR
"NFS: Attr length error, %u != %Zu\n",
1112 len
, ((char *)p
- (char *)q
) + 4);
1115 len
= (char *)p
- (char *)q
- 16;
1116 *q
++ = htonl(bmval0
);
1117 *q
++ = htonl(bmval1
);
1118 *q
++ = htonl(bmval2
);
1124 static void encode_access(struct xdr_stream
*xdr
, u32 access
, struct compound_hdr
*hdr
)
1126 encode_op_hdr(xdr
, OP_ACCESS
, decode_access_maxsz
, hdr
);
1127 encode_uint32(xdr
, access
);
1130 static void encode_close(struct xdr_stream
*xdr
, const struct nfs_closeargs
*arg
, struct compound_hdr
*hdr
)
1132 encode_op_hdr(xdr
, OP_CLOSE
, decode_close_maxsz
, hdr
);
1133 encode_nfs4_seqid(xdr
, arg
->seqid
);
1134 encode_nfs4_stateid(xdr
, arg
->stateid
);
1137 static void encode_commit(struct xdr_stream
*xdr
, const struct nfs_commitargs
*args
, struct compound_hdr
*hdr
)
1141 encode_op_hdr(xdr
, OP_COMMIT
, decode_commit_maxsz
, hdr
);
1142 p
= reserve_space(xdr
, 12);
1143 p
= xdr_encode_hyper(p
, args
->offset
);
1144 *p
= cpu_to_be32(args
->count
);
1147 static void encode_create(struct xdr_stream
*xdr
, const struct nfs4_create_arg
*create
, struct compound_hdr
*hdr
)
1151 encode_op_hdr(xdr
, OP_CREATE
, decode_create_maxsz
, hdr
);
1152 encode_uint32(xdr
, create
->ftype
);
1154 switch (create
->ftype
) {
1156 p
= reserve_space(xdr
, 4);
1157 *p
= cpu_to_be32(create
->u
.symlink
.len
);
1158 xdr_write_pages(xdr
, create
->u
.symlink
.pages
, 0, create
->u
.symlink
.len
);
1161 case NF4BLK
: case NF4CHR
:
1162 p
= reserve_space(xdr
, 8);
1163 *p
++ = cpu_to_be32(create
->u
.device
.specdata1
);
1164 *p
= cpu_to_be32(create
->u
.device
.specdata2
);
1171 encode_string(xdr
, create
->name
->len
, create
->name
->name
);
1172 encode_attrs(xdr
, create
->attrs
, create
->label
, create
->server
);
1175 static void encode_getattr_one(struct xdr_stream
*xdr
, uint32_t bitmap
, struct compound_hdr
*hdr
)
1179 encode_op_hdr(xdr
, OP_GETATTR
, decode_getattr_maxsz
, hdr
);
1180 p
= reserve_space(xdr
, 8);
1181 *p
++ = cpu_to_be32(1);
1182 *p
= cpu_to_be32(bitmap
);
1185 static void encode_getattr_two(struct xdr_stream
*xdr
, uint32_t bm0
, uint32_t bm1
, struct compound_hdr
*hdr
)
1189 encode_op_hdr(xdr
, OP_GETATTR
, decode_getattr_maxsz
, hdr
);
1190 p
= reserve_space(xdr
, 12);
1191 *p
++ = cpu_to_be32(2);
1192 *p
++ = cpu_to_be32(bm0
);
1193 *p
= cpu_to_be32(bm1
);
1197 encode_getattr_three(struct xdr_stream
*xdr
,
1198 uint32_t bm0
, uint32_t bm1
, uint32_t bm2
,
1199 struct compound_hdr
*hdr
)
1203 encode_op_hdr(xdr
, OP_GETATTR
, decode_getattr_maxsz
, hdr
);
1205 p
= reserve_space(xdr
, 16);
1206 *p
++ = cpu_to_be32(3);
1207 *p
++ = cpu_to_be32(bm0
);
1208 *p
++ = cpu_to_be32(bm1
);
1209 *p
= cpu_to_be32(bm2
);
1211 p
= reserve_space(xdr
, 12);
1212 *p
++ = cpu_to_be32(2);
1213 *p
++ = cpu_to_be32(bm0
);
1214 *p
= cpu_to_be32(bm1
);
1216 p
= reserve_space(xdr
, 8);
1217 *p
++ = cpu_to_be32(1);
1218 *p
= cpu_to_be32(bm0
);
1222 static void encode_getfattr(struct xdr_stream
*xdr
, const u32
* bitmask
, struct compound_hdr
*hdr
)
1224 encode_getattr_three(xdr
, bitmask
[0] & nfs4_fattr_bitmap
[0],
1225 bitmask
[1] & nfs4_fattr_bitmap
[1],
1226 bitmask
[2] & nfs4_fattr_bitmap
[2],
1230 static void encode_getfattr_open(struct xdr_stream
*xdr
, const u32
*bitmask
,
1231 const u32
*open_bitmap
,
1232 struct compound_hdr
*hdr
)
1234 encode_getattr_three(xdr
,
1235 bitmask
[0] & open_bitmap
[0],
1236 bitmask
[1] & open_bitmap
[1],
1237 bitmask
[2] & open_bitmap
[2],
1241 static void encode_fsinfo(struct xdr_stream
*xdr
, const u32
* bitmask
, struct compound_hdr
*hdr
)
1243 encode_getattr_three(xdr
,
1244 bitmask
[0] & nfs4_fsinfo_bitmap
[0],
1245 bitmask
[1] & nfs4_fsinfo_bitmap
[1],
1246 bitmask
[2] & nfs4_fsinfo_bitmap
[2],
1250 static void encode_fs_locations(struct xdr_stream
*xdr
, const u32
* bitmask
, struct compound_hdr
*hdr
)
1252 encode_getattr_two(xdr
, bitmask
[0] & nfs4_fs_locations_bitmap
[0],
1253 bitmask
[1] & nfs4_fs_locations_bitmap
[1], hdr
);
1256 static void encode_getfh(struct xdr_stream
*xdr
, struct compound_hdr
*hdr
)
1258 encode_op_hdr(xdr
, OP_GETFH
, decode_getfh_maxsz
, hdr
);
1261 static void encode_link(struct xdr_stream
*xdr
, const struct qstr
*name
, struct compound_hdr
*hdr
)
1263 encode_op_hdr(xdr
, OP_LINK
, decode_link_maxsz
, hdr
);
1264 encode_string(xdr
, name
->len
, name
->name
);
1267 static inline int nfs4_lock_type(struct file_lock
*fl
, int block
)
1269 if (fl
->fl_type
== F_RDLCK
)
1270 return block
? NFS4_READW_LT
: NFS4_READ_LT
;
1271 return block
? NFS4_WRITEW_LT
: NFS4_WRITE_LT
;
1274 static inline uint64_t nfs4_lock_length(struct file_lock
*fl
)
1276 if (fl
->fl_end
== OFFSET_MAX
)
1277 return ~(uint64_t)0;
1278 return fl
->fl_end
- fl
->fl_start
+ 1;
1281 static void encode_lockowner(struct xdr_stream
*xdr
, const struct nfs_lowner
*lowner
)
1285 p
= reserve_space(xdr
, 32);
1286 p
= xdr_encode_hyper(p
, lowner
->clientid
);
1287 *p
++ = cpu_to_be32(20);
1288 p
= xdr_encode_opaque_fixed(p
, "lock id:", 8);
1289 *p
++ = cpu_to_be32(lowner
->s_dev
);
1290 xdr_encode_hyper(p
, lowner
->id
);
1294 * opcode,type,reclaim,offset,length,new_lock_owner = 32
1295 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
1297 static void encode_lock(struct xdr_stream
*xdr
, const struct nfs_lock_args
*args
, struct compound_hdr
*hdr
)
1301 encode_op_hdr(xdr
, OP_LOCK
, decode_lock_maxsz
, hdr
);
1302 p
= reserve_space(xdr
, 28);
1303 *p
++ = cpu_to_be32(nfs4_lock_type(args
->fl
, args
->block
));
1304 *p
++ = cpu_to_be32(args
->reclaim
);
1305 p
= xdr_encode_hyper(p
, args
->fl
->fl_start
);
1306 p
= xdr_encode_hyper(p
, nfs4_lock_length(args
->fl
));
1307 *p
= cpu_to_be32(args
->new_lock_owner
);
1308 if (args
->new_lock_owner
){
1309 encode_nfs4_seqid(xdr
, args
->open_seqid
);
1310 encode_nfs4_stateid(xdr
, args
->open_stateid
);
1311 encode_nfs4_seqid(xdr
, args
->lock_seqid
);
1312 encode_lockowner(xdr
, &args
->lock_owner
);
1315 encode_nfs4_stateid(xdr
, args
->lock_stateid
);
1316 encode_nfs4_seqid(xdr
, args
->lock_seqid
);
1320 static void encode_lockt(struct xdr_stream
*xdr
, const struct nfs_lockt_args
*args
, struct compound_hdr
*hdr
)
1324 encode_op_hdr(xdr
, OP_LOCKT
, decode_lockt_maxsz
, hdr
);
1325 p
= reserve_space(xdr
, 20);
1326 *p
++ = cpu_to_be32(nfs4_lock_type(args
->fl
, 0));
1327 p
= xdr_encode_hyper(p
, args
->fl
->fl_start
);
1328 p
= xdr_encode_hyper(p
, nfs4_lock_length(args
->fl
));
1329 encode_lockowner(xdr
, &args
->lock_owner
);
1332 static void encode_locku(struct xdr_stream
*xdr
, const struct nfs_locku_args
*args
, struct compound_hdr
*hdr
)
1336 encode_op_hdr(xdr
, OP_LOCKU
, decode_locku_maxsz
, hdr
);
1337 encode_uint32(xdr
, nfs4_lock_type(args
->fl
, 0));
1338 encode_nfs4_seqid(xdr
, args
->seqid
);
1339 encode_nfs4_stateid(xdr
, args
->stateid
);
1340 p
= reserve_space(xdr
, 16);
1341 p
= xdr_encode_hyper(p
, args
->fl
->fl_start
);
1342 xdr_encode_hyper(p
, nfs4_lock_length(args
->fl
));
1345 static void encode_release_lockowner(struct xdr_stream
*xdr
, const struct nfs_lowner
*lowner
, struct compound_hdr
*hdr
)
1347 encode_op_hdr(xdr
, OP_RELEASE_LOCKOWNER
, decode_release_lockowner_maxsz
, hdr
);
1348 encode_lockowner(xdr
, lowner
);
1351 static void encode_lookup(struct xdr_stream
*xdr
, const struct qstr
*name
, struct compound_hdr
*hdr
)
1353 encode_op_hdr(xdr
, OP_LOOKUP
, decode_lookup_maxsz
, hdr
);
1354 encode_string(xdr
, name
->len
, name
->name
);
1357 static void encode_share_access(struct xdr_stream
*xdr
, fmode_t fmode
)
1361 p
= reserve_space(xdr
, 8);
1362 switch (fmode
& (FMODE_READ
|FMODE_WRITE
)) {
1364 *p
++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ
);
1367 *p
++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE
);
1369 case FMODE_READ
|FMODE_WRITE
:
1370 *p
++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH
);
1373 *p
++ = cpu_to_be32(0);
1375 *p
= cpu_to_be32(0); /* for linux, share_deny = 0 always */
1378 static inline void encode_openhdr(struct xdr_stream
*xdr
, const struct nfs_openargs
*arg
)
1382 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1385 encode_nfs4_seqid(xdr
, arg
->seqid
);
1386 encode_share_access(xdr
, arg
->fmode
);
1387 p
= reserve_space(xdr
, 36);
1388 p
= xdr_encode_hyper(p
, arg
->clientid
);
1389 *p
++ = cpu_to_be32(24);
1390 p
= xdr_encode_opaque_fixed(p
, "open id:", 8);
1391 *p
++ = cpu_to_be32(arg
->server
->s_dev
);
1392 *p
++ = cpu_to_be32(arg
->id
.uniquifier
);
1393 xdr_encode_hyper(p
, arg
->id
.create_time
);
1396 static inline void encode_createmode(struct xdr_stream
*xdr
, const struct nfs_openargs
*arg
)
1401 p
= reserve_space(xdr
, 4);
1402 switch(arg
->createmode
) {
1403 case NFS4_CREATE_UNCHECKED
:
1404 *p
= cpu_to_be32(NFS4_CREATE_UNCHECKED
);
1405 encode_attrs(xdr
, arg
->u
.attrs
, arg
->label
, arg
->server
);
1407 case NFS4_CREATE_GUARDED
:
1408 *p
= cpu_to_be32(NFS4_CREATE_GUARDED
);
1409 encode_attrs(xdr
, arg
->u
.attrs
, arg
->label
, arg
->server
);
1411 case NFS4_CREATE_EXCLUSIVE
:
1412 *p
= cpu_to_be32(NFS4_CREATE_EXCLUSIVE
);
1413 encode_nfs4_verifier(xdr
, &arg
->u
.verifier
);
1415 case NFS4_CREATE_EXCLUSIVE4_1
:
1416 *p
= cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1
);
1417 encode_nfs4_verifier(xdr
, &arg
->u
.verifier
);
1419 encode_attrs(xdr
, &dummy
, arg
->label
, arg
->server
);
1423 static void encode_opentype(struct xdr_stream
*xdr
, const struct nfs_openargs
*arg
)
1427 p
= reserve_space(xdr
, 4);
1428 switch (arg
->open_flags
& O_CREAT
) {
1430 *p
= cpu_to_be32(NFS4_OPEN_NOCREATE
);
1433 *p
= cpu_to_be32(NFS4_OPEN_CREATE
);
1434 encode_createmode(xdr
, arg
);
1438 static inline void encode_delegation_type(struct xdr_stream
*xdr
, fmode_t delegation_type
)
1442 p
= reserve_space(xdr
, 4);
1443 switch (delegation_type
) {
1445 *p
= cpu_to_be32(NFS4_OPEN_DELEGATE_NONE
);
1448 *p
= cpu_to_be32(NFS4_OPEN_DELEGATE_READ
);
1450 case FMODE_WRITE
|FMODE_READ
:
1451 *p
= cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE
);
1458 static inline void encode_claim_null(struct xdr_stream
*xdr
, const struct qstr
*name
)
1462 p
= reserve_space(xdr
, 4);
1463 *p
= cpu_to_be32(NFS4_OPEN_CLAIM_NULL
);
1464 encode_string(xdr
, name
->len
, name
->name
);
1467 static inline void encode_claim_previous(struct xdr_stream
*xdr
, fmode_t type
)
1471 p
= reserve_space(xdr
, 4);
1472 *p
= cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS
);
1473 encode_delegation_type(xdr
, type
);
1476 static inline void encode_claim_delegate_cur(struct xdr_stream
*xdr
, const struct qstr
*name
, const nfs4_stateid
*stateid
)
1480 p
= reserve_space(xdr
, 4);
1481 *p
= cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR
);
1482 encode_nfs4_stateid(xdr
, stateid
);
1483 encode_string(xdr
, name
->len
, name
->name
);
1486 static inline void encode_claim_fh(struct xdr_stream
*xdr
)
1490 p
= reserve_space(xdr
, 4);
1491 *p
= cpu_to_be32(NFS4_OPEN_CLAIM_FH
);
1494 static inline void encode_claim_delegate_cur_fh(struct xdr_stream
*xdr
, const nfs4_stateid
*stateid
)
1498 p
= reserve_space(xdr
, 4);
1499 *p
= cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH
);
1500 encode_nfs4_stateid(xdr
, stateid
);
1503 static void encode_open(struct xdr_stream
*xdr
, const struct nfs_openargs
*arg
, struct compound_hdr
*hdr
)
1505 encode_op_hdr(xdr
, OP_OPEN
, decode_open_maxsz
, hdr
);
1506 encode_openhdr(xdr
, arg
);
1507 encode_opentype(xdr
, arg
);
1508 switch (arg
->claim
) {
1509 case NFS4_OPEN_CLAIM_NULL
:
1510 encode_claim_null(xdr
, arg
->name
);
1512 case NFS4_OPEN_CLAIM_PREVIOUS
:
1513 encode_claim_previous(xdr
, arg
->u
.delegation_type
);
1515 case NFS4_OPEN_CLAIM_DELEGATE_CUR
:
1516 encode_claim_delegate_cur(xdr
, arg
->name
, &arg
->u
.delegation
);
1518 case NFS4_OPEN_CLAIM_FH
:
1519 encode_claim_fh(xdr
);
1521 case NFS4_OPEN_CLAIM_DELEG_CUR_FH
:
1522 encode_claim_delegate_cur_fh(xdr
, &arg
->u
.delegation
);
1529 static void encode_open_confirm(struct xdr_stream
*xdr
, const struct nfs_open_confirmargs
*arg
, struct compound_hdr
*hdr
)
1531 encode_op_hdr(xdr
, OP_OPEN_CONFIRM
, decode_open_confirm_maxsz
, hdr
);
1532 encode_nfs4_stateid(xdr
, arg
->stateid
);
1533 encode_nfs4_seqid(xdr
, arg
->seqid
);
1536 static void encode_open_downgrade(struct xdr_stream
*xdr
, const struct nfs_closeargs
*arg
, struct compound_hdr
*hdr
)
1538 encode_op_hdr(xdr
, OP_OPEN_DOWNGRADE
, decode_open_downgrade_maxsz
, hdr
);
1539 encode_nfs4_stateid(xdr
, arg
->stateid
);
1540 encode_nfs4_seqid(xdr
, arg
->seqid
);
1541 encode_share_access(xdr
, arg
->fmode
);
1545 encode_putfh(struct xdr_stream
*xdr
, const struct nfs_fh
*fh
, struct compound_hdr
*hdr
)
1547 encode_op_hdr(xdr
, OP_PUTFH
, decode_putfh_maxsz
, hdr
);
1548 encode_string(xdr
, fh
->size
, fh
->data
);
1551 static void encode_putrootfh(struct xdr_stream
*xdr
, struct compound_hdr
*hdr
)
1553 encode_op_hdr(xdr
, OP_PUTROOTFH
, decode_putrootfh_maxsz
, hdr
);
1556 static void encode_read(struct xdr_stream
*xdr
, const struct nfs_readargs
*args
, struct compound_hdr
*hdr
)
1560 encode_op_hdr(xdr
, OP_READ
, decode_read_maxsz
, hdr
);
1561 encode_nfs4_stateid(xdr
, &args
->stateid
);
1563 p
= reserve_space(xdr
, 12);
1564 p
= xdr_encode_hyper(p
, args
->offset
);
1565 *p
= cpu_to_be32(args
->count
);
1568 static void encode_readdir(struct xdr_stream
*xdr
, const struct nfs4_readdir_arg
*readdir
, struct rpc_rqst
*req
, struct compound_hdr
*hdr
)
1570 uint32_t attrs
[3] = {
1571 FATTR4_WORD0_RDATTR_ERROR
,
1572 FATTR4_WORD1_MOUNTED_ON_FILEID
,
1574 uint32_t dircount
= readdir
->count
>> 1;
1577 if (readdir
->plus
) {
1578 attrs
[0] |= FATTR4_WORD0_TYPE
|FATTR4_WORD0_CHANGE
|FATTR4_WORD0_SIZE
|
1579 FATTR4_WORD0_FSID
|FATTR4_WORD0_FILEHANDLE
|FATTR4_WORD0_FILEID
;
1580 attrs
[1] |= FATTR4_WORD1_MODE
|FATTR4_WORD1_NUMLINKS
|FATTR4_WORD1_OWNER
|
1581 FATTR4_WORD1_OWNER_GROUP
|FATTR4_WORD1_RAWDEV
|
1582 FATTR4_WORD1_SPACE_USED
|FATTR4_WORD1_TIME_ACCESS
|
1583 FATTR4_WORD1_TIME_METADATA
|FATTR4_WORD1_TIME_MODIFY
;
1586 /* Use mounted_on_fileid only if the server supports it */
1587 if (!(readdir
->bitmask
[1] & FATTR4_WORD1_MOUNTED_ON_FILEID
))
1588 attrs
[0] |= FATTR4_WORD0_FILEID
;
1590 encode_op_hdr(xdr
, OP_READDIR
, decode_readdir_maxsz
, hdr
);
1591 encode_uint64(xdr
, readdir
->cookie
);
1592 encode_nfs4_verifier(xdr
, &readdir
->verifier
);
1593 p
= reserve_space(xdr
, encode_readdir_space
);
1594 *p
++ = cpu_to_be32(dircount
);
1595 *p
++ = cpu_to_be32(readdir
->count
);
1596 *p
++ = cpu_to_be32(encode_readdir_bitmask_sz
);
1597 *p
++ = cpu_to_be32(attrs
[0] & readdir
->bitmask
[0]);
1598 *p
= cpu_to_be32(attrs
[1] & readdir
->bitmask
[1]);
1599 if (encode_readdir_bitmask_sz
> 2) {
1600 if (hdr
->minorversion
> 1)
1601 attrs
[2] |= FATTR4_WORD2_SECURITY_LABEL
;
1602 p
++, *p
++ = cpu_to_be32(attrs
[2] & readdir
->bitmask
[2]);
1604 memcpy(verf
, readdir
->verifier
.data
, sizeof(verf
));
1606 dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n",
1608 (unsigned long long)readdir
->cookie
,
1610 attrs
[0] & readdir
->bitmask
[0],
1611 attrs
[1] & readdir
->bitmask
[1],
1612 attrs
[2] & readdir
->bitmask
[2]);
1615 static void encode_readlink(struct xdr_stream
*xdr
, const struct nfs4_readlink
*readlink
, struct rpc_rqst
*req
, struct compound_hdr
*hdr
)
1617 encode_op_hdr(xdr
, OP_READLINK
, decode_readlink_maxsz
, hdr
);
1620 static void encode_remove(struct xdr_stream
*xdr
, const struct qstr
*name
, struct compound_hdr
*hdr
)
1622 encode_op_hdr(xdr
, OP_REMOVE
, decode_remove_maxsz
, hdr
);
1623 encode_string(xdr
, name
->len
, name
->name
);
1626 static void encode_rename(struct xdr_stream
*xdr
, const struct qstr
*oldname
, const struct qstr
*newname
, struct compound_hdr
*hdr
)
1628 encode_op_hdr(xdr
, OP_RENAME
, decode_rename_maxsz
, hdr
);
1629 encode_string(xdr
, oldname
->len
, oldname
->name
);
1630 encode_string(xdr
, newname
->len
, newname
->name
);
1633 static void encode_renew(struct xdr_stream
*xdr
, clientid4 clid
,
1634 struct compound_hdr
*hdr
)
1636 encode_op_hdr(xdr
, OP_RENEW
, decode_renew_maxsz
, hdr
);
1637 encode_uint64(xdr
, clid
);
1641 encode_restorefh(struct xdr_stream
*xdr
, struct compound_hdr
*hdr
)
1643 encode_op_hdr(xdr
, OP_RESTOREFH
, decode_restorefh_maxsz
, hdr
);
1647 encode_setacl(struct xdr_stream
*xdr
, struct nfs_setaclargs
*arg
, struct compound_hdr
*hdr
)
1651 encode_op_hdr(xdr
, OP_SETATTR
, decode_setacl_maxsz
, hdr
);
1652 encode_nfs4_stateid(xdr
, &zero_stateid
);
1653 p
= reserve_space(xdr
, 2*4);
1654 *p
++ = cpu_to_be32(1);
1655 *p
= cpu_to_be32(FATTR4_WORD0_ACL
);
1656 p
= reserve_space(xdr
, 4);
1657 *p
= cpu_to_be32(arg
->acl_len
);
1658 xdr_write_pages(xdr
, arg
->acl_pages
, arg
->acl_pgbase
, arg
->acl_len
);
1662 encode_savefh(struct xdr_stream
*xdr
, struct compound_hdr
*hdr
)
1664 encode_op_hdr(xdr
, OP_SAVEFH
, decode_savefh_maxsz
, hdr
);
1667 static void encode_setattr(struct xdr_stream
*xdr
, const struct nfs_setattrargs
*arg
, const struct nfs_server
*server
, struct compound_hdr
*hdr
)
1669 encode_op_hdr(xdr
, OP_SETATTR
, decode_setattr_maxsz
, hdr
);
1670 encode_nfs4_stateid(xdr
, &arg
->stateid
);
1671 encode_attrs(xdr
, arg
->iap
, arg
->label
, server
);
1674 static void encode_setclientid(struct xdr_stream
*xdr
, const struct nfs4_setclientid
*setclientid
, struct compound_hdr
*hdr
)
1678 encode_op_hdr(xdr
, OP_SETCLIENTID
, decode_setclientid_maxsz
, hdr
);
1679 encode_nfs4_verifier(xdr
, setclientid
->sc_verifier
);
1681 encode_string(xdr
, setclientid
->sc_name_len
, setclientid
->sc_name
);
1682 p
= reserve_space(xdr
, 4);
1683 *p
= cpu_to_be32(setclientid
->sc_prog
);
1684 encode_string(xdr
, setclientid
->sc_netid_len
, setclientid
->sc_netid
);
1685 encode_string(xdr
, setclientid
->sc_uaddr_len
, setclientid
->sc_uaddr
);
1686 p
= reserve_space(xdr
, 4);
1687 *p
= cpu_to_be32(setclientid
->sc_cb_ident
);
1690 static void encode_setclientid_confirm(struct xdr_stream
*xdr
, const struct nfs4_setclientid_res
*arg
, struct compound_hdr
*hdr
)
1692 encode_op_hdr(xdr
, OP_SETCLIENTID_CONFIRM
,
1693 decode_setclientid_confirm_maxsz
, hdr
);
1694 encode_uint64(xdr
, arg
->clientid
);
1695 encode_nfs4_verifier(xdr
, &arg
->confirm
);
1698 static void encode_write(struct xdr_stream
*xdr
, const struct nfs_writeargs
*args
, struct compound_hdr
*hdr
)
1702 encode_op_hdr(xdr
, OP_WRITE
, decode_write_maxsz
, hdr
);
1703 encode_nfs4_stateid(xdr
, &args
->stateid
);
1705 p
= reserve_space(xdr
, 16);
1706 p
= xdr_encode_hyper(p
, args
->offset
);
1707 *p
++ = cpu_to_be32(args
->stable
);
1708 *p
= cpu_to_be32(args
->count
);
1710 xdr_write_pages(xdr
, args
->pages
, args
->pgbase
, args
->count
);
1713 static void encode_delegreturn(struct xdr_stream
*xdr
, const nfs4_stateid
*stateid
, struct compound_hdr
*hdr
)
1715 encode_op_hdr(xdr
, OP_DELEGRETURN
, decode_delegreturn_maxsz
, hdr
);
1716 encode_nfs4_stateid(xdr
, stateid
);
1719 static void encode_secinfo(struct xdr_stream
*xdr
, const struct qstr
*name
, struct compound_hdr
*hdr
)
1721 encode_op_hdr(xdr
, OP_SECINFO
, decode_secinfo_maxsz
, hdr
);
1722 encode_string(xdr
, name
->len
, name
->name
);
1725 #if defined(CONFIG_NFS_V4_1)
1726 /* NFSv4.1 operations */
1727 static void encode_bind_conn_to_session(struct xdr_stream
*xdr
,
1728 struct nfs4_session
*session
,
1729 struct compound_hdr
*hdr
)
1733 encode_op_hdr(xdr
, OP_BIND_CONN_TO_SESSION
,
1734 decode_bind_conn_to_session_maxsz
, hdr
);
1735 encode_opaque_fixed(xdr
, session
->sess_id
.data
, NFS4_MAX_SESSIONID_LEN
);
1736 p
= xdr_reserve_space(xdr
, 8);
1737 *p
++ = cpu_to_be32(NFS4_CDFC4_BACK_OR_BOTH
);
1738 *p
= 0; /* use_conn_in_rdma_mode = False */
1741 static void encode_exchange_id(struct xdr_stream
*xdr
,
1742 struct nfs41_exchange_id_args
*args
,
1743 struct compound_hdr
*hdr
)
1746 char impl_name
[IMPL_NAME_LIMIT
];
1749 encode_op_hdr(xdr
, OP_EXCHANGE_ID
, decode_exchange_id_maxsz
, hdr
);
1750 encode_nfs4_verifier(xdr
, args
->verifier
);
1752 encode_string(xdr
, args
->id_len
, args
->id
);
1754 p
= reserve_space(xdr
, 12);
1755 *p
++ = cpu_to_be32(args
->flags
);
1756 *p
++ = cpu_to_be32(0); /* zero length state_protect4_a */
1758 if (send_implementation_id
&&
1759 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
) > 1 &&
1760 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
)
1761 <= sizeof(impl_name
) + 1)
1762 len
= snprintf(impl_name
, sizeof(impl_name
), "%s %s %s %s",
1763 utsname()->sysname
, utsname()->release
,
1764 utsname()->version
, utsname()->machine
);
1767 *p
= cpu_to_be32(1); /* implementation id array length=1 */
1770 sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
) - 1,
1771 CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
);
1772 encode_string(xdr
, len
, impl_name
);
1773 /* just send zeros for nii_date - the date is in nii_name */
1774 p
= reserve_space(xdr
, 12);
1775 p
= xdr_encode_hyper(p
, 0);
1776 *p
= cpu_to_be32(0);
1778 *p
= cpu_to_be32(0); /* implementation id array length=0 */
1781 static void encode_create_session(struct xdr_stream
*xdr
,
1782 struct nfs41_create_session_args
*args
,
1783 struct compound_hdr
*hdr
)
1786 char machine_name
[NFS4_MAX_MACHINE_NAME_LEN
];
1788 struct nfs_client
*clp
= args
->client
;
1789 struct nfs_net
*nn
= net_generic(clp
->cl_net
, nfs_net_id
);
1790 u32 max_resp_sz_cached
;
1793 * Assumes OPEN is the biggest non-idempotent compound.
1794 * 2 is the verifier.
1796 max_resp_sz_cached
= (NFS4_dec_open_sz
+ RPC_REPHDRSIZE
+
1797 RPC_MAX_AUTH_SIZE
+ 2) * XDR_UNIT
;
1799 len
= scnprintf(machine_name
, sizeof(machine_name
), "%s",
1802 encode_op_hdr(xdr
, OP_CREATE_SESSION
, decode_create_session_maxsz
, hdr
);
1803 p
= reserve_space(xdr
, 16 + 2*28 + 20 + len
+ 12);
1804 p
= xdr_encode_hyper(p
, clp
->cl_clientid
);
1805 *p
++ = cpu_to_be32(clp
->cl_seqid
); /*Sequence id */
1806 *p
++ = cpu_to_be32(args
->flags
); /*flags */
1809 *p
++ = cpu_to_be32(0); /* header padding size */
1810 *p
++ = cpu_to_be32(args
->fc_attrs
.max_rqst_sz
); /* max req size */
1811 *p
++ = cpu_to_be32(args
->fc_attrs
.max_resp_sz
); /* max resp size */
1812 *p
++ = cpu_to_be32(max_resp_sz_cached
); /* Max resp sz cached */
1813 *p
++ = cpu_to_be32(args
->fc_attrs
.max_ops
); /* max operations */
1814 *p
++ = cpu_to_be32(args
->fc_attrs
.max_reqs
); /* max requests */
1815 *p
++ = cpu_to_be32(0); /* rdmachannel_attrs */
1818 *p
++ = cpu_to_be32(0); /* header padding size */
1819 *p
++ = cpu_to_be32(args
->bc_attrs
.max_rqst_sz
); /* max req size */
1820 *p
++ = cpu_to_be32(args
->bc_attrs
.max_resp_sz
); /* max resp size */
1821 *p
++ = cpu_to_be32(args
->bc_attrs
.max_resp_sz_cached
); /* Max resp sz cached */
1822 *p
++ = cpu_to_be32(args
->bc_attrs
.max_ops
); /* max operations */
1823 *p
++ = cpu_to_be32(args
->bc_attrs
.max_reqs
); /* max requests */
1824 *p
++ = cpu_to_be32(0); /* rdmachannel_attrs */
1826 *p
++ = cpu_to_be32(args
->cb_program
); /* cb_program */
1827 *p
++ = cpu_to_be32(1);
1828 *p
++ = cpu_to_be32(RPC_AUTH_UNIX
); /* auth_sys */
1830 /* authsys_parms rfc1831 */
1831 *p
++ = (__be32
)nn
->boot_time
.tv_nsec
; /* stamp */
1832 p
= xdr_encode_opaque(p
, machine_name
, len
);
1833 *p
++ = cpu_to_be32(0); /* UID */
1834 *p
++ = cpu_to_be32(0); /* GID */
1835 *p
= cpu_to_be32(0); /* No more gids */
1838 static void encode_destroy_session(struct xdr_stream
*xdr
,
1839 struct nfs4_session
*session
,
1840 struct compound_hdr
*hdr
)
1842 encode_op_hdr(xdr
, OP_DESTROY_SESSION
, decode_destroy_session_maxsz
, hdr
);
1843 encode_opaque_fixed(xdr
, session
->sess_id
.data
, NFS4_MAX_SESSIONID_LEN
);
1846 static void encode_destroy_clientid(struct xdr_stream
*xdr
,
1848 struct compound_hdr
*hdr
)
1850 encode_op_hdr(xdr
, OP_DESTROY_CLIENTID
, decode_destroy_clientid_maxsz
, hdr
);
1851 encode_uint64(xdr
, clientid
);
1854 static void encode_reclaim_complete(struct xdr_stream
*xdr
,
1855 struct nfs41_reclaim_complete_args
*args
,
1856 struct compound_hdr
*hdr
)
1858 encode_op_hdr(xdr
, OP_RECLAIM_COMPLETE
, decode_reclaim_complete_maxsz
, hdr
);
1859 encode_uint32(xdr
, args
->one_fs
);
1861 #endif /* CONFIG_NFS_V4_1 */
1863 static void encode_sequence(struct xdr_stream
*xdr
,
1864 const struct nfs4_sequence_args
*args
,
1865 struct compound_hdr
*hdr
)
1867 #if defined(CONFIG_NFS_V4_1)
1868 struct nfs4_session
*session
;
1869 struct nfs4_slot_table
*tp
;
1870 struct nfs4_slot
*slot
= args
->sa_slot
;
1877 session
= tp
->session
;
1879 encode_op_hdr(xdr
, OP_SEQUENCE
, decode_sequence_maxsz
, hdr
);
1882 * Sessionid + seqid + slotid + max slotid + cache_this
1884 dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
1885 "max_slotid=%d cache_this=%d\n",
1887 ((u32
*)session
->sess_id
.data
)[0],
1888 ((u32
*)session
->sess_id
.data
)[1],
1889 ((u32
*)session
->sess_id
.data
)[2],
1890 ((u32
*)session
->sess_id
.data
)[3],
1891 slot
->seq_nr
, slot
->slot_nr
,
1892 tp
->highest_used_slotid
, args
->sa_cache_this
);
1893 p
= reserve_space(xdr
, NFS4_MAX_SESSIONID_LEN
+ 16);
1894 p
= xdr_encode_opaque_fixed(p
, session
->sess_id
.data
, NFS4_MAX_SESSIONID_LEN
);
1895 *p
++ = cpu_to_be32(slot
->seq_nr
);
1896 *p
++ = cpu_to_be32(slot
->slot_nr
);
1897 *p
++ = cpu_to_be32(tp
->highest_used_slotid
);
1898 *p
= cpu_to_be32(args
->sa_cache_this
);
1899 #endif /* CONFIG_NFS_V4_1 */
1902 #ifdef CONFIG_NFS_V4_1
1904 encode_getdevicelist(struct xdr_stream
*xdr
,
1905 const struct nfs4_getdevicelist_args
*args
,
1906 struct compound_hdr
*hdr
)
1909 nfs4_verifier dummy
= {
1913 encode_op_hdr(xdr
, OP_GETDEVICELIST
, decode_getdevicelist_maxsz
, hdr
);
1914 p
= reserve_space(xdr
, 16);
1915 *p
++ = cpu_to_be32(args
->layoutclass
);
1916 *p
++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM
);
1917 xdr_encode_hyper(p
, 0ULL); /* cookie */
1918 encode_nfs4_verifier(xdr
, &dummy
);
1922 encode_getdeviceinfo(struct xdr_stream
*xdr
,
1923 const struct nfs4_getdeviceinfo_args
*args
,
1924 struct compound_hdr
*hdr
)
1928 encode_op_hdr(xdr
, OP_GETDEVICEINFO
, decode_getdeviceinfo_maxsz
, hdr
);
1929 p
= reserve_space(xdr
, 12 + NFS4_DEVICEID4_SIZE
);
1930 p
= xdr_encode_opaque_fixed(p
, args
->pdev
->dev_id
.data
,
1931 NFS4_DEVICEID4_SIZE
);
1932 *p
++ = cpu_to_be32(args
->pdev
->layout_type
);
1933 *p
++ = cpu_to_be32(args
->pdev
->maxcount
); /* gdia_maxcount */
1934 *p
++ = cpu_to_be32(0); /* bitmap length 0 */
1938 encode_layoutget(struct xdr_stream
*xdr
,
1939 const struct nfs4_layoutget_args
*args
,
1940 struct compound_hdr
*hdr
)
1944 encode_op_hdr(xdr
, OP_LAYOUTGET
, decode_layoutget_maxsz
, hdr
);
1945 p
= reserve_space(xdr
, 36);
1946 *p
++ = cpu_to_be32(0); /* Signal layout available */
1947 *p
++ = cpu_to_be32(args
->type
);
1948 *p
++ = cpu_to_be32(args
->range
.iomode
);
1949 p
= xdr_encode_hyper(p
, args
->range
.offset
);
1950 p
= xdr_encode_hyper(p
, args
->range
.length
);
1951 p
= xdr_encode_hyper(p
, args
->minlength
);
1952 encode_nfs4_stateid(xdr
, &args
->stateid
);
1953 encode_uint32(xdr
, args
->maxcount
);
1955 dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n",
1959 (unsigned long)args
->range
.offset
,
1960 (unsigned long)args
->range
.length
,
1965 encode_layoutcommit(struct xdr_stream
*xdr
,
1966 struct inode
*inode
,
1967 const struct nfs4_layoutcommit_args
*args
,
1968 struct compound_hdr
*hdr
)
1972 dprintk("%s: lbw: %llu type: %d\n", __func__
, args
->lastbytewritten
,
1973 NFS_SERVER(args
->inode
)->pnfs_curr_ld
->id
);
1975 encode_op_hdr(xdr
, OP_LAYOUTCOMMIT
, decode_layoutcommit_maxsz
, hdr
);
1976 p
= reserve_space(xdr
, 20);
1977 /* Only whole file layouts */
1978 p
= xdr_encode_hyper(p
, 0); /* offset */
1979 p
= xdr_encode_hyper(p
, args
->lastbytewritten
+ 1); /* length */
1980 *p
= cpu_to_be32(0); /* reclaim */
1981 encode_nfs4_stateid(xdr
, &args
->stateid
);
1982 p
= reserve_space(xdr
, 20);
1983 *p
++ = cpu_to_be32(1); /* newoffset = TRUE */
1984 p
= xdr_encode_hyper(p
, args
->lastbytewritten
);
1985 *p
++ = cpu_to_be32(0); /* Never send time_modify_changed */
1986 *p
++ = cpu_to_be32(NFS_SERVER(args
->inode
)->pnfs_curr_ld
->id
);/* type */
1988 if (NFS_SERVER(inode
)->pnfs_curr_ld
->encode_layoutcommit
)
1989 NFS_SERVER(inode
)->pnfs_curr_ld
->encode_layoutcommit(
1990 NFS_I(inode
)->layout
, xdr
, args
);
1992 encode_uint32(xdr
, 0); /* no layout-type payload */
1998 encode_layoutreturn(struct xdr_stream
*xdr
,
1999 const struct nfs4_layoutreturn_args
*args
,
2000 struct compound_hdr
*hdr
)
2004 encode_op_hdr(xdr
, OP_LAYOUTRETURN
, decode_layoutreturn_maxsz
, hdr
);
2005 p
= reserve_space(xdr
, 16);
2006 *p
++ = cpu_to_be32(0); /* reclaim. always 0 for now */
2007 *p
++ = cpu_to_be32(args
->layout_type
);
2008 *p
++ = cpu_to_be32(IOMODE_ANY
);
2009 *p
= cpu_to_be32(RETURN_FILE
);
2010 p
= reserve_space(xdr
, 16);
2011 p
= xdr_encode_hyper(p
, 0);
2012 p
= xdr_encode_hyper(p
, NFS4_MAX_UINT64
);
2013 spin_lock(&args
->inode
->i_lock
);
2014 encode_nfs4_stateid(xdr
, &args
->stateid
);
2015 spin_unlock(&args
->inode
->i_lock
);
2016 if (NFS_SERVER(args
->inode
)->pnfs_curr_ld
->encode_layoutreturn
) {
2017 NFS_SERVER(args
->inode
)->pnfs_curr_ld
->encode_layoutreturn(
2018 NFS_I(args
->inode
)->layout
, xdr
, args
);
2020 encode_uint32(xdr
, 0);
2024 encode_secinfo_no_name(struct xdr_stream
*xdr
,
2025 const struct nfs41_secinfo_no_name_args
*args
,
2026 struct compound_hdr
*hdr
)
2028 encode_op_hdr(xdr
, OP_SECINFO_NO_NAME
, decode_secinfo_no_name_maxsz
, hdr
);
2029 encode_uint32(xdr
, args
->style
);
2033 static void encode_test_stateid(struct xdr_stream
*xdr
,
2034 struct nfs41_test_stateid_args
*args
,
2035 struct compound_hdr
*hdr
)
2037 encode_op_hdr(xdr
, OP_TEST_STATEID
, decode_test_stateid_maxsz
, hdr
);
2038 encode_uint32(xdr
, 1);
2039 encode_nfs4_stateid(xdr
, args
->stateid
);
2042 static void encode_free_stateid(struct xdr_stream
*xdr
,
2043 struct nfs41_free_stateid_args
*args
,
2044 struct compound_hdr
*hdr
)
2046 encode_op_hdr(xdr
, OP_FREE_STATEID
, decode_free_stateid_maxsz
, hdr
);
2047 encode_nfs4_stateid(xdr
, &args
->stateid
);
2049 #endif /* CONFIG_NFS_V4_1 */
2052 * END OF "GENERIC" ENCODE ROUTINES.
2055 static u32
nfs4_xdr_minorversion(const struct nfs4_sequence_args
*args
)
2057 #if defined(CONFIG_NFS_V4_1)
2060 return args
->sa_slot
->table
->session
->clp
->cl_mvops
->minor_version
;
2061 #endif /* CONFIG_NFS_V4_1 */
2066 * Encode an ACCESS request
2068 static void nfs4_xdr_enc_access(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2069 const struct nfs4_accessargs
*args
)
2071 struct compound_hdr hdr
= {
2072 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2075 encode_compound_hdr(xdr
, req
, &hdr
);
2076 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2077 encode_putfh(xdr
, args
->fh
, &hdr
);
2078 encode_access(xdr
, args
->access
, &hdr
);
2079 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2084 * Encode LOOKUP request
2086 static void nfs4_xdr_enc_lookup(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2087 const struct nfs4_lookup_arg
*args
)
2089 struct compound_hdr hdr
= {
2090 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2093 encode_compound_hdr(xdr
, req
, &hdr
);
2094 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2095 encode_putfh(xdr
, args
->dir_fh
, &hdr
);
2096 encode_lookup(xdr
, args
->name
, &hdr
);
2097 encode_getfh(xdr
, &hdr
);
2098 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2103 * Encode LOOKUP_ROOT request
2105 static void nfs4_xdr_enc_lookup_root(struct rpc_rqst
*req
,
2106 struct xdr_stream
*xdr
,
2107 const struct nfs4_lookup_root_arg
*args
)
2109 struct compound_hdr hdr
= {
2110 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2113 encode_compound_hdr(xdr
, req
, &hdr
);
2114 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2115 encode_putrootfh(xdr
, &hdr
);
2116 encode_getfh(xdr
, &hdr
);
2117 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2122 * Encode REMOVE request
2124 static void nfs4_xdr_enc_remove(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2125 const struct nfs_removeargs
*args
)
2127 struct compound_hdr hdr
= {
2128 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2131 encode_compound_hdr(xdr
, req
, &hdr
);
2132 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2133 encode_putfh(xdr
, args
->fh
, &hdr
);
2134 encode_remove(xdr
, &args
->name
, &hdr
);
2139 * Encode RENAME request
2141 static void nfs4_xdr_enc_rename(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2142 const struct nfs_renameargs
*args
)
2144 struct compound_hdr hdr
= {
2145 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2148 encode_compound_hdr(xdr
, req
, &hdr
);
2149 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2150 encode_putfh(xdr
, args
->old_dir
, &hdr
);
2151 encode_savefh(xdr
, &hdr
);
2152 encode_putfh(xdr
, args
->new_dir
, &hdr
);
2153 encode_rename(xdr
, args
->old_name
, args
->new_name
, &hdr
);
2158 * Encode LINK request
2160 static void nfs4_xdr_enc_link(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2161 const struct nfs4_link_arg
*args
)
2163 struct compound_hdr hdr
= {
2164 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2167 encode_compound_hdr(xdr
, req
, &hdr
);
2168 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2169 encode_putfh(xdr
, args
->fh
, &hdr
);
2170 encode_savefh(xdr
, &hdr
);
2171 encode_putfh(xdr
, args
->dir_fh
, &hdr
);
2172 encode_link(xdr
, args
->name
, &hdr
);
2173 encode_restorefh(xdr
, &hdr
);
2174 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2179 * Encode CREATE request
2181 static void nfs4_xdr_enc_create(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2182 const struct nfs4_create_arg
*args
)
2184 struct compound_hdr hdr
= {
2185 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2188 encode_compound_hdr(xdr
, req
, &hdr
);
2189 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2190 encode_putfh(xdr
, args
->dir_fh
, &hdr
);
2191 encode_create(xdr
, args
, &hdr
);
2192 encode_getfh(xdr
, &hdr
);
2193 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2198 * Encode SYMLINK request
2200 static void nfs4_xdr_enc_symlink(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2201 const struct nfs4_create_arg
*args
)
2203 nfs4_xdr_enc_create(req
, xdr
, args
);
2207 * Encode GETATTR request
2209 static void nfs4_xdr_enc_getattr(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2210 const struct nfs4_getattr_arg
*args
)
2212 struct compound_hdr hdr
= {
2213 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2216 encode_compound_hdr(xdr
, req
, &hdr
);
2217 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2218 encode_putfh(xdr
, args
->fh
, &hdr
);
2219 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2224 * Encode a CLOSE request
2226 static void nfs4_xdr_enc_close(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2227 struct nfs_closeargs
*args
)
2229 struct compound_hdr hdr
= {
2230 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2233 encode_compound_hdr(xdr
, req
, &hdr
);
2234 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2235 encode_putfh(xdr
, args
->fh
, &hdr
);
2236 encode_close(xdr
, args
, &hdr
);
2237 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2242 * Encode an OPEN request
2244 static void nfs4_xdr_enc_open(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2245 struct nfs_openargs
*args
)
2247 struct compound_hdr hdr
= {
2248 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2251 encode_compound_hdr(xdr
, req
, &hdr
);
2252 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2253 encode_putfh(xdr
, args
->fh
, &hdr
);
2254 encode_open(xdr
, args
, &hdr
);
2255 encode_getfh(xdr
, &hdr
);
2257 encode_access(xdr
, args
->access
, &hdr
);
2258 encode_getfattr_open(xdr
, args
->bitmask
, args
->open_bitmap
, &hdr
);
2263 * Encode an OPEN_CONFIRM request
2265 static void nfs4_xdr_enc_open_confirm(struct rpc_rqst
*req
,
2266 struct xdr_stream
*xdr
,
2267 struct nfs_open_confirmargs
*args
)
2269 struct compound_hdr hdr
= {
2273 encode_compound_hdr(xdr
, req
, &hdr
);
2274 encode_putfh(xdr
, args
->fh
, &hdr
);
2275 encode_open_confirm(xdr
, args
, &hdr
);
2280 * Encode an OPEN request with no attributes.
2282 static void nfs4_xdr_enc_open_noattr(struct rpc_rqst
*req
,
2283 struct xdr_stream
*xdr
,
2284 struct nfs_openargs
*args
)
2286 struct compound_hdr hdr
= {
2287 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2290 encode_compound_hdr(xdr
, req
, &hdr
);
2291 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2292 encode_putfh(xdr
, args
->fh
, &hdr
);
2293 encode_open(xdr
, args
, &hdr
);
2295 encode_access(xdr
, args
->access
, &hdr
);
2296 encode_getfattr_open(xdr
, args
->bitmask
, args
->open_bitmap
, &hdr
);
2301 * Encode an OPEN_DOWNGRADE request
2303 static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst
*req
,
2304 struct xdr_stream
*xdr
,
2305 struct nfs_closeargs
*args
)
2307 struct compound_hdr hdr
= {
2308 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2311 encode_compound_hdr(xdr
, req
, &hdr
);
2312 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2313 encode_putfh(xdr
, args
->fh
, &hdr
);
2314 encode_open_downgrade(xdr
, args
, &hdr
);
2315 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2320 * Encode a LOCK request
2322 static void nfs4_xdr_enc_lock(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2323 struct nfs_lock_args
*args
)
2325 struct compound_hdr hdr
= {
2326 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2329 encode_compound_hdr(xdr
, req
, &hdr
);
2330 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2331 encode_putfh(xdr
, args
->fh
, &hdr
);
2332 encode_lock(xdr
, args
, &hdr
);
2337 * Encode a LOCKT request
2339 static void nfs4_xdr_enc_lockt(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2340 struct nfs_lockt_args
*args
)
2342 struct compound_hdr hdr
= {
2343 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2346 encode_compound_hdr(xdr
, req
, &hdr
);
2347 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2348 encode_putfh(xdr
, args
->fh
, &hdr
);
2349 encode_lockt(xdr
, args
, &hdr
);
2354 * Encode a LOCKU request
2356 static void nfs4_xdr_enc_locku(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2357 struct nfs_locku_args
*args
)
2359 struct compound_hdr hdr
= {
2360 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2363 encode_compound_hdr(xdr
, req
, &hdr
);
2364 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2365 encode_putfh(xdr
, args
->fh
, &hdr
);
2366 encode_locku(xdr
, args
, &hdr
);
2370 static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst
*req
,
2371 struct xdr_stream
*xdr
,
2372 struct nfs_release_lockowner_args
*args
)
2374 struct compound_hdr hdr
= {
2378 encode_compound_hdr(xdr
, req
, &hdr
);
2379 encode_release_lockowner(xdr
, &args
->lock_owner
, &hdr
);
2384 * Encode a READLINK request
2386 static void nfs4_xdr_enc_readlink(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2387 const struct nfs4_readlink
*args
)
2389 struct compound_hdr hdr
= {
2390 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2393 encode_compound_hdr(xdr
, req
, &hdr
);
2394 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2395 encode_putfh(xdr
, args
->fh
, &hdr
);
2396 encode_readlink(xdr
, args
, req
, &hdr
);
2398 xdr_inline_pages(&req
->rq_rcv_buf
, hdr
.replen
<< 2, args
->pages
,
2399 args
->pgbase
, args
->pglen
);
2404 * Encode a READDIR request
2406 static void nfs4_xdr_enc_readdir(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2407 const struct nfs4_readdir_arg
*args
)
2409 struct compound_hdr hdr
= {
2410 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2413 encode_compound_hdr(xdr
, req
, &hdr
);
2414 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2415 encode_putfh(xdr
, args
->fh
, &hdr
);
2416 encode_readdir(xdr
, args
, req
, &hdr
);
2418 xdr_inline_pages(&req
->rq_rcv_buf
, hdr
.replen
<< 2, args
->pages
,
2419 args
->pgbase
, args
->count
);
2420 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
2421 __func__
, hdr
.replen
<< 2, args
->pages
,
2422 args
->pgbase
, args
->count
);
2427 * Encode a READ request
2429 static void nfs4_xdr_enc_read(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2430 struct nfs_readargs
*args
)
2432 struct compound_hdr hdr
= {
2433 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2436 encode_compound_hdr(xdr
, req
, &hdr
);
2437 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2438 encode_putfh(xdr
, args
->fh
, &hdr
);
2439 encode_read(xdr
, args
, &hdr
);
2441 xdr_inline_pages(&req
->rq_rcv_buf
, hdr
.replen
<< 2,
2442 args
->pages
, args
->pgbase
, args
->count
);
2443 req
->rq_rcv_buf
.flags
|= XDRBUF_READ
;
2448 * Encode an SETATTR request
2450 static void nfs4_xdr_enc_setattr(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2451 struct nfs_setattrargs
*args
)
2453 struct compound_hdr hdr
= {
2454 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2457 encode_compound_hdr(xdr
, req
, &hdr
);
2458 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2459 encode_putfh(xdr
, args
->fh
, &hdr
);
2460 encode_setattr(xdr
, args
, args
->server
, &hdr
);
2461 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2466 * Encode a GETACL request
2468 static void nfs4_xdr_enc_getacl(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2469 struct nfs_getaclargs
*args
)
2471 struct compound_hdr hdr
= {
2472 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2476 encode_compound_hdr(xdr
, req
, &hdr
);
2477 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2478 encode_putfh(xdr
, args
->fh
, &hdr
);
2479 replen
= hdr
.replen
+ op_decode_hdr_maxsz
+ 1;
2480 encode_getattr_two(xdr
, FATTR4_WORD0_ACL
, 0, &hdr
);
2482 xdr_inline_pages(&req
->rq_rcv_buf
, replen
<< 2,
2483 args
->acl_pages
, args
->acl_pgbase
, args
->acl_len
);
2489 * Encode a WRITE request
2491 static void nfs4_xdr_enc_write(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2492 struct nfs_writeargs
*args
)
2494 struct compound_hdr hdr
= {
2495 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2498 encode_compound_hdr(xdr
, req
, &hdr
);
2499 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2500 encode_putfh(xdr
, args
->fh
, &hdr
);
2501 encode_write(xdr
, args
, &hdr
);
2502 req
->rq_snd_buf
.flags
|= XDRBUF_WRITE
;
2504 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2511 static void nfs4_xdr_enc_commit(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2512 struct nfs_commitargs
*args
)
2514 struct compound_hdr hdr
= {
2515 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2518 encode_compound_hdr(xdr
, req
, &hdr
);
2519 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2520 encode_putfh(xdr
, args
->fh
, &hdr
);
2521 encode_commit(xdr
, args
, &hdr
);
2528 static void nfs4_xdr_enc_fsinfo(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2529 struct nfs4_fsinfo_arg
*args
)
2531 struct compound_hdr hdr
= {
2532 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2535 encode_compound_hdr(xdr
, req
, &hdr
);
2536 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2537 encode_putfh(xdr
, args
->fh
, &hdr
);
2538 encode_fsinfo(xdr
, args
->bitmask
, &hdr
);
2543 * a PATHCONF request
2545 static void nfs4_xdr_enc_pathconf(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2546 const struct nfs4_pathconf_arg
*args
)
2548 struct compound_hdr hdr
= {
2549 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2552 encode_compound_hdr(xdr
, req
, &hdr
);
2553 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2554 encode_putfh(xdr
, args
->fh
, &hdr
);
2555 encode_getattr_one(xdr
, args
->bitmask
[0] & nfs4_pathconf_bitmap
[0],
2563 static void nfs4_xdr_enc_statfs(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2564 const struct nfs4_statfs_arg
*args
)
2566 struct compound_hdr hdr
= {
2567 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2570 encode_compound_hdr(xdr
, req
, &hdr
);
2571 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2572 encode_putfh(xdr
, args
->fh
, &hdr
);
2573 encode_getattr_two(xdr
, args
->bitmask
[0] & nfs4_statfs_bitmap
[0],
2574 args
->bitmask
[1] & nfs4_statfs_bitmap
[1], &hdr
);
2579 * GETATTR_BITMAP request
2581 static void nfs4_xdr_enc_server_caps(struct rpc_rqst
*req
,
2582 struct xdr_stream
*xdr
,
2583 struct nfs4_server_caps_arg
*args
)
2585 struct compound_hdr hdr
= {
2586 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2589 encode_compound_hdr(xdr
, req
, &hdr
);
2590 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2591 encode_putfh(xdr
, args
->fhandle
, &hdr
);
2592 encode_getattr_one(xdr
, FATTR4_WORD0_SUPPORTED_ATTRS
|
2593 FATTR4_WORD0_FH_EXPIRE_TYPE
|
2594 FATTR4_WORD0_LINK_SUPPORT
|
2595 FATTR4_WORD0_SYMLINK_SUPPORT
|
2596 FATTR4_WORD0_ACLSUPPORT
, &hdr
);
2603 static void nfs4_xdr_enc_renew(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2604 struct nfs_client
*clp
)
2606 struct compound_hdr hdr
= {
2610 encode_compound_hdr(xdr
, req
, &hdr
);
2611 encode_renew(xdr
, clp
->cl_clientid
, &hdr
);
2616 * a SETCLIENTID request
2618 static void nfs4_xdr_enc_setclientid(struct rpc_rqst
*req
,
2619 struct xdr_stream
*xdr
,
2620 struct nfs4_setclientid
*sc
)
2622 struct compound_hdr hdr
= {
2626 encode_compound_hdr(xdr
, req
, &hdr
);
2627 encode_setclientid(xdr
, sc
, &hdr
);
2632 * a SETCLIENTID_CONFIRM request
2634 static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst
*req
,
2635 struct xdr_stream
*xdr
,
2636 struct nfs4_setclientid_res
*arg
)
2638 struct compound_hdr hdr
= {
2642 encode_compound_hdr(xdr
, req
, &hdr
);
2643 encode_setclientid_confirm(xdr
, arg
, &hdr
);
2648 * DELEGRETURN request
2650 static void nfs4_xdr_enc_delegreturn(struct rpc_rqst
*req
,
2651 struct xdr_stream
*xdr
,
2652 const struct nfs4_delegreturnargs
*args
)
2654 struct compound_hdr hdr
= {
2655 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2658 encode_compound_hdr(xdr
, req
, &hdr
);
2659 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2660 encode_putfh(xdr
, args
->fhandle
, &hdr
);
2661 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2662 encode_delegreturn(xdr
, args
->stateid
, &hdr
);
2667 * Encode FS_LOCATIONS request
2669 static void nfs4_xdr_enc_fs_locations(struct rpc_rqst
*req
,
2670 struct xdr_stream
*xdr
,
2671 struct nfs4_fs_locations_arg
*args
)
2673 struct compound_hdr hdr
= {
2674 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2678 encode_compound_hdr(xdr
, req
, &hdr
);
2679 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2680 encode_putfh(xdr
, args
->dir_fh
, &hdr
);
2681 encode_lookup(xdr
, args
->name
, &hdr
);
2682 replen
= hdr
.replen
; /* get the attribute into args->page */
2683 encode_fs_locations(xdr
, args
->bitmask
, &hdr
);
2685 xdr_inline_pages(&req
->rq_rcv_buf
, replen
<< 2, &args
->page
,
2691 * Encode SECINFO request
2693 static void nfs4_xdr_enc_secinfo(struct rpc_rqst
*req
,
2694 struct xdr_stream
*xdr
,
2695 struct nfs4_secinfo_arg
*args
)
2697 struct compound_hdr hdr
= {
2698 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2701 encode_compound_hdr(xdr
, req
, &hdr
);
2702 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2703 encode_putfh(xdr
, args
->dir_fh
, &hdr
);
2704 encode_secinfo(xdr
, args
->name
, &hdr
);
2708 #if defined(CONFIG_NFS_V4_1)
2710 * BIND_CONN_TO_SESSION request
2712 static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst
*req
,
2713 struct xdr_stream
*xdr
,
2714 struct nfs_client
*clp
)
2716 struct compound_hdr hdr
= {
2717 .minorversion
= clp
->cl_mvops
->minor_version
,
2720 encode_compound_hdr(xdr
, req
, &hdr
);
2721 encode_bind_conn_to_session(xdr
, clp
->cl_session
, &hdr
);
2726 * EXCHANGE_ID request
2728 static void nfs4_xdr_enc_exchange_id(struct rpc_rqst
*req
,
2729 struct xdr_stream
*xdr
,
2730 struct nfs41_exchange_id_args
*args
)
2732 struct compound_hdr hdr
= {
2733 .minorversion
= args
->client
->cl_mvops
->minor_version
,
2736 encode_compound_hdr(xdr
, req
, &hdr
);
2737 encode_exchange_id(xdr
, args
, &hdr
);
2742 * a CREATE_SESSION request
2744 static void nfs4_xdr_enc_create_session(struct rpc_rqst
*req
,
2745 struct xdr_stream
*xdr
,
2746 struct nfs41_create_session_args
*args
)
2748 struct compound_hdr hdr
= {
2749 .minorversion
= args
->client
->cl_mvops
->minor_version
,
2752 encode_compound_hdr(xdr
, req
, &hdr
);
2753 encode_create_session(xdr
, args
, &hdr
);
2758 * a DESTROY_SESSION request
2760 static void nfs4_xdr_enc_destroy_session(struct rpc_rqst
*req
,
2761 struct xdr_stream
*xdr
,
2762 struct nfs4_session
*session
)
2764 struct compound_hdr hdr
= {
2765 .minorversion
= session
->clp
->cl_mvops
->minor_version
,
2768 encode_compound_hdr(xdr
, req
, &hdr
);
2769 encode_destroy_session(xdr
, session
, &hdr
);
2774 * a DESTROY_CLIENTID request
2776 static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst
*req
,
2777 struct xdr_stream
*xdr
,
2778 struct nfs_client
*clp
)
2780 struct compound_hdr hdr
= {
2781 .minorversion
= clp
->cl_mvops
->minor_version
,
2784 encode_compound_hdr(xdr
, req
, &hdr
);
2785 encode_destroy_clientid(xdr
, clp
->cl_clientid
, &hdr
);
2790 * a SEQUENCE request
2792 static void nfs4_xdr_enc_sequence(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
2793 struct nfs4_sequence_args
*args
)
2795 struct compound_hdr hdr
= {
2796 .minorversion
= nfs4_xdr_minorversion(args
),
2799 encode_compound_hdr(xdr
, req
, &hdr
);
2800 encode_sequence(xdr
, args
, &hdr
);
2805 * a GET_LEASE_TIME request
2807 static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst
*req
,
2808 struct xdr_stream
*xdr
,
2809 struct nfs4_get_lease_time_args
*args
)
2811 struct compound_hdr hdr
= {
2812 .minorversion
= nfs4_xdr_minorversion(&args
->la_seq_args
),
2814 const u32 lease_bitmap
[3] = { FATTR4_WORD0_LEASE_TIME
};
2816 encode_compound_hdr(xdr
, req
, &hdr
);
2817 encode_sequence(xdr
, &args
->la_seq_args
, &hdr
);
2818 encode_putrootfh(xdr
, &hdr
);
2819 encode_fsinfo(xdr
, lease_bitmap
, &hdr
);
2824 * a RECLAIM_COMPLETE request
2826 static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst
*req
,
2827 struct xdr_stream
*xdr
,
2828 struct nfs41_reclaim_complete_args
*args
)
2830 struct compound_hdr hdr
= {
2831 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
)
2834 encode_compound_hdr(xdr
, req
, &hdr
);
2835 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2836 encode_reclaim_complete(xdr
, args
, &hdr
);
2841 * Encode GETDEVICELIST request
2843 static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst
*req
,
2844 struct xdr_stream
*xdr
,
2845 struct nfs4_getdevicelist_args
*args
)
2847 struct compound_hdr hdr
= {
2848 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2851 encode_compound_hdr(xdr
, req
, &hdr
);
2852 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2853 encode_putfh(xdr
, args
->fh
, &hdr
);
2854 encode_getdevicelist(xdr
, args
, &hdr
);
2859 * Encode GETDEVICEINFO request
2861 static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst
*req
,
2862 struct xdr_stream
*xdr
,
2863 struct nfs4_getdeviceinfo_args
*args
)
2865 struct compound_hdr hdr
= {
2866 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2869 encode_compound_hdr(xdr
, req
, &hdr
);
2870 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2871 encode_getdeviceinfo(xdr
, args
, &hdr
);
2873 /* set up reply kvec. Subtract notification bitmap max size (2)
2874 * so that notification bitmap is put in xdr_buf tail */
2875 xdr_inline_pages(&req
->rq_rcv_buf
, (hdr
.replen
- 2) << 2,
2876 args
->pdev
->pages
, args
->pdev
->pgbase
,
2883 * Encode LAYOUTGET request
2885 static void nfs4_xdr_enc_layoutget(struct rpc_rqst
*req
,
2886 struct xdr_stream
*xdr
,
2887 struct nfs4_layoutget_args
*args
)
2889 struct compound_hdr hdr
= {
2890 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2893 encode_compound_hdr(xdr
, req
, &hdr
);
2894 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2895 encode_putfh(xdr
, NFS_FH(args
->inode
), &hdr
);
2896 encode_layoutget(xdr
, args
, &hdr
);
2898 xdr_inline_pages(&req
->rq_rcv_buf
, hdr
.replen
<< 2,
2899 args
->layout
.pages
, 0, args
->layout
.pglen
);
2905 * Encode LAYOUTCOMMIT request
2907 static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst
*req
,
2908 struct xdr_stream
*xdr
,
2909 struct nfs4_layoutcommit_args
*args
)
2911 struct nfs4_layoutcommit_data
*data
=
2912 container_of(args
, struct nfs4_layoutcommit_data
, args
);
2913 struct compound_hdr hdr
= {
2914 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2917 encode_compound_hdr(xdr
, req
, &hdr
);
2918 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2919 encode_putfh(xdr
, NFS_FH(args
->inode
), &hdr
);
2920 encode_layoutcommit(xdr
, data
->args
.inode
, args
, &hdr
);
2921 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
2926 * Encode LAYOUTRETURN request
2928 static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst
*req
,
2929 struct xdr_stream
*xdr
,
2930 struct nfs4_layoutreturn_args
*args
)
2932 struct compound_hdr hdr
= {
2933 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2936 encode_compound_hdr(xdr
, req
, &hdr
);
2937 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2938 encode_putfh(xdr
, NFS_FH(args
->inode
), &hdr
);
2939 encode_layoutreturn(xdr
, args
, &hdr
);
2944 * Encode SECINFO_NO_NAME request
2946 static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst
*req
,
2947 struct xdr_stream
*xdr
,
2948 struct nfs41_secinfo_no_name_args
*args
)
2950 struct compound_hdr hdr
= {
2951 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2954 encode_compound_hdr(xdr
, req
, &hdr
);
2955 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2956 encode_putrootfh(xdr
, &hdr
);
2957 encode_secinfo_no_name(xdr
, args
, &hdr
);
2963 * Encode TEST_STATEID request
2965 static void nfs4_xdr_enc_test_stateid(struct rpc_rqst
*req
,
2966 struct xdr_stream
*xdr
,
2967 struct nfs41_test_stateid_args
*args
)
2969 struct compound_hdr hdr
= {
2970 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2973 encode_compound_hdr(xdr
, req
, &hdr
);
2974 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2975 encode_test_stateid(xdr
, args
, &hdr
);
2980 * Encode FREE_STATEID request
2982 static void nfs4_xdr_enc_free_stateid(struct rpc_rqst
*req
,
2983 struct xdr_stream
*xdr
,
2984 struct nfs41_free_stateid_args
*args
)
2986 struct compound_hdr hdr
= {
2987 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
2990 encode_compound_hdr(xdr
, req
, &hdr
);
2991 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
2992 encode_free_stateid(xdr
, args
, &hdr
);
2995 #endif /* CONFIG_NFS_V4_1 */
2997 static void print_overflow_msg(const char *func
, const struct xdr_stream
*xdr
)
2999 dprintk("nfs: %s: prematurely hit end of receive buffer. "
3000 "Remaining buffer length is %tu words.\n",
3001 func
, xdr
->end
- xdr
->p
);
3004 static int decode_opaque_inline(struct xdr_stream
*xdr
, unsigned int *len
, char **string
)
3008 p
= xdr_inline_decode(xdr
, 4);
3011 *len
= be32_to_cpup(p
);
3012 p
= xdr_inline_decode(xdr
, *len
);
3015 *string
= (char *)p
;
3018 print_overflow_msg(__func__
, xdr
);
3022 static int decode_compound_hdr(struct xdr_stream
*xdr
, struct compound_hdr
*hdr
)
3026 p
= xdr_inline_decode(xdr
, 8);
3029 hdr
->status
= be32_to_cpup(p
++);
3030 hdr
->taglen
= be32_to_cpup(p
);
3032 p
= xdr_inline_decode(xdr
, hdr
->taglen
+ 4);
3035 hdr
->tag
= (char *)p
;
3036 p
+= XDR_QUADLEN(hdr
->taglen
);
3037 hdr
->nops
= be32_to_cpup(p
);
3038 if (unlikely(hdr
->nops
< 1))
3039 return nfs4_stat_to_errno(hdr
->status
);
3042 print_overflow_msg(__func__
, xdr
);
3046 static int decode_op_hdr(struct xdr_stream
*xdr
, enum nfs_opnum4 expected
)
3052 p
= xdr_inline_decode(xdr
, 8);
3055 opnum
= be32_to_cpup(p
++);
3056 if (opnum
!= expected
) {
3057 dprintk("nfs: Server returned operation"
3058 " %d but we issued a request for %d\n",
3062 nfserr
= be32_to_cpup(p
);
3063 if (nfserr
!= NFS_OK
)
3064 return nfs4_stat_to_errno(nfserr
);
3067 print_overflow_msg(__func__
, xdr
);
3072 static int decode_ace(struct xdr_stream
*xdr
, void *ace
, struct nfs_client
*clp
)
3075 unsigned int strlen
;
3078 p
= xdr_inline_decode(xdr
, 12);
3080 return decode_opaque_inline(xdr
, &strlen
, &str
);
3081 print_overflow_msg(__func__
, xdr
);
3085 static int decode_attr_bitmap(struct xdr_stream
*xdr
, uint32_t *bitmap
)
3090 p
= xdr_inline_decode(xdr
, 4);
3093 bmlen
= be32_to_cpup(p
);
3095 bitmap
[0] = bitmap
[1] = bitmap
[2] = 0;
3096 p
= xdr_inline_decode(xdr
, (bmlen
<< 2));
3100 bitmap
[0] = be32_to_cpup(p
++);
3102 bitmap
[1] = be32_to_cpup(p
++);
3104 bitmap
[2] = be32_to_cpup(p
);
3109 print_overflow_msg(__func__
, xdr
);
3113 static int decode_attr_length(struct xdr_stream
*xdr
, uint32_t *attrlen
, unsigned int *savep
)
3117 p
= xdr_inline_decode(xdr
, 4);
3120 *attrlen
= be32_to_cpup(p
);
3121 *savep
= xdr_stream_pos(xdr
);
3124 print_overflow_msg(__func__
, xdr
);
3128 static int decode_attr_supported(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *bitmask
)
3130 if (likely(bitmap
[0] & FATTR4_WORD0_SUPPORTED_ATTRS
)) {
3132 ret
= decode_attr_bitmap(xdr
, bitmask
);
3133 if (unlikely(ret
< 0))
3135 bitmap
[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS
;
3137 bitmask
[0] = bitmask
[1] = bitmask
[2] = 0;
3138 dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__
,
3139 bitmask
[0], bitmask
[1], bitmask
[2]);
3143 static int decode_attr_type(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *type
)
3149 if (unlikely(bitmap
[0] & (FATTR4_WORD0_TYPE
- 1U)))
3151 if (likely(bitmap
[0] & FATTR4_WORD0_TYPE
)) {
3152 p
= xdr_inline_decode(xdr
, 4);
3155 *type
= be32_to_cpup(p
);
3156 if (*type
< NF4REG
|| *type
> NF4NAMEDATTR
) {
3157 dprintk("%s: bad type %d\n", __func__
, *type
);
3160 bitmap
[0] &= ~FATTR4_WORD0_TYPE
;
3161 ret
= NFS_ATTR_FATTR_TYPE
;
3163 dprintk("%s: type=0%o\n", __func__
, nfs_type2fmt
[*type
]);
3166 print_overflow_msg(__func__
, xdr
);
3170 static int decode_attr_fh_expire_type(struct xdr_stream
*xdr
,
3171 uint32_t *bitmap
, uint32_t *type
)
3176 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE
- 1U)))
3178 if (likely(bitmap
[0] & FATTR4_WORD0_FH_EXPIRE_TYPE
)) {
3179 p
= xdr_inline_decode(xdr
, 4);
3182 *type
= be32_to_cpup(p
);
3183 bitmap
[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE
;
3185 dprintk("%s: expire type=0x%x\n", __func__
, *type
);
3188 print_overflow_msg(__func__
, xdr
);
3192 static int decode_attr_change(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *change
)
3198 if (unlikely(bitmap
[0] & (FATTR4_WORD0_CHANGE
- 1U)))
3200 if (likely(bitmap
[0] & FATTR4_WORD0_CHANGE
)) {
3201 p
= xdr_inline_decode(xdr
, 8);
3204 xdr_decode_hyper(p
, change
);
3205 bitmap
[0] &= ~FATTR4_WORD0_CHANGE
;
3206 ret
= NFS_ATTR_FATTR_CHANGE
;
3208 dprintk("%s: change attribute=%Lu\n", __func__
,
3209 (unsigned long long)*change
);
3212 print_overflow_msg(__func__
, xdr
);
3216 static int decode_attr_size(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *size
)
3222 if (unlikely(bitmap
[0] & (FATTR4_WORD0_SIZE
- 1U)))
3224 if (likely(bitmap
[0] & FATTR4_WORD0_SIZE
)) {
3225 p
= xdr_inline_decode(xdr
, 8);
3228 xdr_decode_hyper(p
, size
);
3229 bitmap
[0] &= ~FATTR4_WORD0_SIZE
;
3230 ret
= NFS_ATTR_FATTR_SIZE
;
3232 dprintk("%s: file size=%Lu\n", __func__
, (unsigned long long)*size
);
3235 print_overflow_msg(__func__
, xdr
);
3239 static int decode_attr_link_support(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3244 if (unlikely(bitmap
[0] & (FATTR4_WORD0_LINK_SUPPORT
- 1U)))
3246 if (likely(bitmap
[0] & FATTR4_WORD0_LINK_SUPPORT
)) {
3247 p
= xdr_inline_decode(xdr
, 4);
3250 *res
= be32_to_cpup(p
);
3251 bitmap
[0] &= ~FATTR4_WORD0_LINK_SUPPORT
;
3253 dprintk("%s: link support=%s\n", __func__
, *res
== 0 ? "false" : "true");
3256 print_overflow_msg(__func__
, xdr
);
3260 static int decode_attr_symlink_support(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3265 if (unlikely(bitmap
[0] & (FATTR4_WORD0_SYMLINK_SUPPORT
- 1U)))
3267 if (likely(bitmap
[0] & FATTR4_WORD0_SYMLINK_SUPPORT
)) {
3268 p
= xdr_inline_decode(xdr
, 4);
3271 *res
= be32_to_cpup(p
);
3272 bitmap
[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT
;
3274 dprintk("%s: symlink support=%s\n", __func__
, *res
== 0 ? "false" : "true");
3277 print_overflow_msg(__func__
, xdr
);
3281 static int decode_attr_fsid(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct nfs_fsid
*fsid
)
3288 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FSID
- 1U)))
3290 if (likely(bitmap
[0] & FATTR4_WORD0_FSID
)) {
3291 p
= xdr_inline_decode(xdr
, 16);
3294 p
= xdr_decode_hyper(p
, &fsid
->major
);
3295 xdr_decode_hyper(p
, &fsid
->minor
);
3296 bitmap
[0] &= ~FATTR4_WORD0_FSID
;
3297 ret
= NFS_ATTR_FATTR_FSID
;
3299 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__
,
3300 (unsigned long long)fsid
->major
,
3301 (unsigned long long)fsid
->minor
);
3304 print_overflow_msg(__func__
, xdr
);
3308 static int decode_attr_lease_time(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3313 if (unlikely(bitmap
[0] & (FATTR4_WORD0_LEASE_TIME
- 1U)))
3315 if (likely(bitmap
[0] & FATTR4_WORD0_LEASE_TIME
)) {
3316 p
= xdr_inline_decode(xdr
, 4);
3319 *res
= be32_to_cpup(p
);
3320 bitmap
[0] &= ~FATTR4_WORD0_LEASE_TIME
;
3322 dprintk("%s: file size=%u\n", __func__
, (unsigned int)*res
);
3325 print_overflow_msg(__func__
, xdr
);
3329 static int decode_attr_error(struct xdr_stream
*xdr
, uint32_t *bitmap
, int32_t *res
)
3333 if (unlikely(bitmap
[0] & (FATTR4_WORD0_RDATTR_ERROR
- 1U)))
3335 if (likely(bitmap
[0] & FATTR4_WORD0_RDATTR_ERROR
)) {
3336 p
= xdr_inline_decode(xdr
, 4);
3339 bitmap
[0] &= ~FATTR4_WORD0_RDATTR_ERROR
;
3340 *res
= -be32_to_cpup(p
);
3344 print_overflow_msg(__func__
, xdr
);
3348 static int decode_attr_filehandle(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct nfs_fh
*fh
)
3354 memset(fh
, 0, sizeof(*fh
));
3356 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FILEHANDLE
- 1U)))
3358 if (likely(bitmap
[0] & FATTR4_WORD0_FILEHANDLE
)) {
3359 p
= xdr_inline_decode(xdr
, 4);
3362 len
= be32_to_cpup(p
);
3363 if (len
> NFS4_FHSIZE
)
3365 p
= xdr_inline_decode(xdr
, len
);
3369 memcpy(fh
->data
, p
, len
);
3372 bitmap
[0] &= ~FATTR4_WORD0_FILEHANDLE
;
3376 print_overflow_msg(__func__
, xdr
);
3380 static int decode_attr_aclsupport(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3384 *res
= ACL4_SUPPORT_ALLOW_ACL
|ACL4_SUPPORT_DENY_ACL
;
3385 if (unlikely(bitmap
[0] & (FATTR4_WORD0_ACLSUPPORT
- 1U)))
3387 if (likely(bitmap
[0] & FATTR4_WORD0_ACLSUPPORT
)) {
3388 p
= xdr_inline_decode(xdr
, 4);
3391 *res
= be32_to_cpup(p
);
3392 bitmap
[0] &= ~FATTR4_WORD0_ACLSUPPORT
;
3394 dprintk("%s: ACLs supported=%u\n", __func__
, (unsigned int)*res
);
3397 print_overflow_msg(__func__
, xdr
);
3401 static int decode_attr_fileid(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *fileid
)
3407 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FILEID
- 1U)))
3409 if (likely(bitmap
[0] & FATTR4_WORD0_FILEID
)) {
3410 p
= xdr_inline_decode(xdr
, 8);
3413 xdr_decode_hyper(p
, fileid
);
3414 bitmap
[0] &= ~FATTR4_WORD0_FILEID
;
3415 ret
= NFS_ATTR_FATTR_FILEID
;
3417 dprintk("%s: fileid=%Lu\n", __func__
, (unsigned long long)*fileid
);
3420 print_overflow_msg(__func__
, xdr
);
3424 static int decode_attr_mounted_on_fileid(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *fileid
)
3430 if (unlikely(bitmap
[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID
- 1U)))
3432 if (likely(bitmap
[1] & FATTR4_WORD1_MOUNTED_ON_FILEID
)) {
3433 p
= xdr_inline_decode(xdr
, 8);
3436 xdr_decode_hyper(p
, fileid
);
3437 bitmap
[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID
;
3438 ret
= NFS_ATTR_FATTR_MOUNTED_ON_FILEID
;
3440 dprintk("%s: fileid=%Lu\n", __func__
, (unsigned long long)*fileid
);
3443 print_overflow_msg(__func__
, xdr
);
3447 static int decode_attr_files_avail(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3453 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FILES_AVAIL
- 1U)))
3455 if (likely(bitmap
[0] & FATTR4_WORD0_FILES_AVAIL
)) {
3456 p
= xdr_inline_decode(xdr
, 8);
3459 xdr_decode_hyper(p
, res
);
3460 bitmap
[0] &= ~FATTR4_WORD0_FILES_AVAIL
;
3462 dprintk("%s: files avail=%Lu\n", __func__
, (unsigned long long)*res
);
3465 print_overflow_msg(__func__
, xdr
);
3469 static int decode_attr_files_free(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3475 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FILES_FREE
- 1U)))
3477 if (likely(bitmap
[0] & FATTR4_WORD0_FILES_FREE
)) {
3478 p
= xdr_inline_decode(xdr
, 8);
3481 xdr_decode_hyper(p
, res
);
3482 bitmap
[0] &= ~FATTR4_WORD0_FILES_FREE
;
3484 dprintk("%s: files free=%Lu\n", __func__
, (unsigned long long)*res
);
3487 print_overflow_msg(__func__
, xdr
);
3491 static int decode_attr_files_total(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3497 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FILES_TOTAL
- 1U)))
3499 if (likely(bitmap
[0] & FATTR4_WORD0_FILES_TOTAL
)) {
3500 p
= xdr_inline_decode(xdr
, 8);
3503 xdr_decode_hyper(p
, res
);
3504 bitmap
[0] &= ~FATTR4_WORD0_FILES_TOTAL
;
3506 dprintk("%s: files total=%Lu\n", __func__
, (unsigned long long)*res
);
3509 print_overflow_msg(__func__
, xdr
);
3513 static int decode_pathname(struct xdr_stream
*xdr
, struct nfs4_pathname
*path
)
3519 p
= xdr_inline_decode(xdr
, 4);
3522 n
= be32_to_cpup(p
);
3525 dprintk("pathname4: ");
3526 if (n
> NFS4_PATHNAME_MAXCOMPONENTS
) {
3527 dprintk("cannot parse %d components in path\n", n
);
3530 for (path
->ncomponents
= 0; path
->ncomponents
< n
; path
->ncomponents
++) {
3531 struct nfs4_string
*component
= &path
->components
[path
->ncomponents
];
3532 status
= decode_opaque_inline(xdr
, &component
->len
, &component
->data
);
3533 if (unlikely(status
!= 0))
3537 (path
->ncomponents
!= n
? "/ " : ""),
3538 component
->len
, component
->data
);
3543 /* a root pathname is sent as a zero component4 */
3544 path
->ncomponents
= 1;
3545 path
->components
[0].len
=0;
3546 path
->components
[0].data
=NULL
;
3547 dprintk("pathname4: /\n");
3550 dprintk(" status %d", status
);
3554 print_overflow_msg(__func__
, xdr
);
3558 static int decode_attr_fs_locations(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct nfs4_fs_locations
*res
)
3564 if (unlikely(bitmap
[0] & (FATTR4_WORD0_FS_LOCATIONS
-1U)))
3567 if (unlikely(!(bitmap
[0] & FATTR4_WORD0_FS_LOCATIONS
)))
3570 /* Ignore borken servers that return unrequested attrs */
3571 if (unlikely(res
== NULL
))
3573 dprintk("%s: fsroot:\n", __func__
);
3574 status
= decode_pathname(xdr
, &res
->fs_path
);
3575 if (unlikely(status
!= 0))
3577 p
= xdr_inline_decode(xdr
, 4);
3580 n
= be32_to_cpup(p
);
3583 for (res
->nlocations
= 0; res
->nlocations
< n
; res
->nlocations
++) {
3585 struct nfs4_fs_location
*loc
;
3587 if (res
->nlocations
== NFS4_FS_LOCATIONS_MAXENTRIES
)
3589 loc
= &res
->locations
[res
->nlocations
];
3590 p
= xdr_inline_decode(xdr
, 4);
3593 m
= be32_to_cpup(p
);
3595 dprintk("%s: servers:\n", __func__
);
3596 for (loc
->nservers
= 0; loc
->nservers
< m
; loc
->nservers
++) {
3597 struct nfs4_string
*server
;
3599 if (loc
->nservers
== NFS4_FS_LOCATION_MAXSERVERS
) {
3601 dprintk("%s: using first %u of %u servers "
3602 "returned for location %u\n",
3604 NFS4_FS_LOCATION_MAXSERVERS
,
3605 m
, res
->nlocations
);
3606 for (i
= loc
->nservers
; i
< m
; i
++) {
3609 status
= decode_opaque_inline(xdr
, &len
, &data
);
3610 if (unlikely(status
!= 0))
3615 server
= &loc
->servers
[loc
->nservers
];
3616 status
= decode_opaque_inline(xdr
, &server
->len
, &server
->data
);
3617 if (unlikely(status
!= 0))
3619 dprintk("%s ", server
->data
);
3621 status
= decode_pathname(xdr
, &loc
->rootpath
);
3622 if (unlikely(status
!= 0))
3625 if (res
->nlocations
!= 0)
3626 status
= NFS_ATTR_FATTR_V4_LOCATIONS
;
3628 dprintk("%s: fs_locations done, error = %d\n", __func__
, status
);
3631 print_overflow_msg(__func__
, xdr
);
3637 static int decode_attr_maxfilesize(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3643 if (unlikely(bitmap
[0] & (FATTR4_WORD0_MAXFILESIZE
- 1U)))
3645 if (likely(bitmap
[0] & FATTR4_WORD0_MAXFILESIZE
)) {
3646 p
= xdr_inline_decode(xdr
, 8);
3649 xdr_decode_hyper(p
, res
);
3650 bitmap
[0] &= ~FATTR4_WORD0_MAXFILESIZE
;
3652 dprintk("%s: maxfilesize=%Lu\n", __func__
, (unsigned long long)*res
);
3655 print_overflow_msg(__func__
, xdr
);
3659 static int decode_attr_maxlink(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *maxlink
)
3665 if (unlikely(bitmap
[0] & (FATTR4_WORD0_MAXLINK
- 1U)))
3667 if (likely(bitmap
[0] & FATTR4_WORD0_MAXLINK
)) {
3668 p
= xdr_inline_decode(xdr
, 4);
3671 *maxlink
= be32_to_cpup(p
);
3672 bitmap
[0] &= ~FATTR4_WORD0_MAXLINK
;
3674 dprintk("%s: maxlink=%u\n", __func__
, *maxlink
);
3677 print_overflow_msg(__func__
, xdr
);
3681 static int decode_attr_maxname(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *maxname
)
3687 if (unlikely(bitmap
[0] & (FATTR4_WORD0_MAXNAME
- 1U)))
3689 if (likely(bitmap
[0] & FATTR4_WORD0_MAXNAME
)) {
3690 p
= xdr_inline_decode(xdr
, 4);
3693 *maxname
= be32_to_cpup(p
);
3694 bitmap
[0] &= ~FATTR4_WORD0_MAXNAME
;
3696 dprintk("%s: maxname=%u\n", __func__
, *maxname
);
3699 print_overflow_msg(__func__
, xdr
);
3703 static int decode_attr_maxread(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3709 if (unlikely(bitmap
[0] & (FATTR4_WORD0_MAXREAD
- 1U)))
3711 if (likely(bitmap
[0] & FATTR4_WORD0_MAXREAD
)) {
3713 p
= xdr_inline_decode(xdr
, 8);
3716 xdr_decode_hyper(p
, &maxread
);
3717 if (maxread
> 0x7FFFFFFF)
3718 maxread
= 0x7FFFFFFF;
3719 *res
= (uint32_t)maxread
;
3720 bitmap
[0] &= ~FATTR4_WORD0_MAXREAD
;
3722 dprintk("%s: maxread=%lu\n", __func__
, (unsigned long)*res
);
3725 print_overflow_msg(__func__
, xdr
);
3729 static int decode_attr_maxwrite(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *res
)
3735 if (unlikely(bitmap
[0] & (FATTR4_WORD0_MAXWRITE
- 1U)))
3737 if (likely(bitmap
[0] & FATTR4_WORD0_MAXWRITE
)) {
3739 p
= xdr_inline_decode(xdr
, 8);
3742 xdr_decode_hyper(p
, &maxwrite
);
3743 if (maxwrite
> 0x7FFFFFFF)
3744 maxwrite
= 0x7FFFFFFF;
3745 *res
= (uint32_t)maxwrite
;
3746 bitmap
[0] &= ~FATTR4_WORD0_MAXWRITE
;
3748 dprintk("%s: maxwrite=%lu\n", __func__
, (unsigned long)*res
);
3751 print_overflow_msg(__func__
, xdr
);
3755 static int decode_attr_mode(struct xdr_stream
*xdr
, uint32_t *bitmap
, umode_t
*mode
)
3762 if (unlikely(bitmap
[1] & (FATTR4_WORD1_MODE
- 1U)))
3764 if (likely(bitmap
[1] & FATTR4_WORD1_MODE
)) {
3765 p
= xdr_inline_decode(xdr
, 4);
3768 tmp
= be32_to_cpup(p
);
3769 *mode
= tmp
& ~S_IFMT
;
3770 bitmap
[1] &= ~FATTR4_WORD1_MODE
;
3771 ret
= NFS_ATTR_FATTR_MODE
;
3773 dprintk("%s: file mode=0%o\n", __func__
, (unsigned int)*mode
);
3776 print_overflow_msg(__func__
, xdr
);
3780 static int decode_attr_nlink(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint32_t *nlink
)
3786 if (unlikely(bitmap
[1] & (FATTR4_WORD1_NUMLINKS
- 1U)))
3788 if (likely(bitmap
[1] & FATTR4_WORD1_NUMLINKS
)) {
3789 p
= xdr_inline_decode(xdr
, 4);
3792 *nlink
= be32_to_cpup(p
);
3793 bitmap
[1] &= ~FATTR4_WORD1_NUMLINKS
;
3794 ret
= NFS_ATTR_FATTR_NLINK
;
3796 dprintk("%s: nlink=%u\n", __func__
, (unsigned int)*nlink
);
3799 print_overflow_msg(__func__
, xdr
);
3803 static int decode_attr_owner(struct xdr_stream
*xdr
, uint32_t *bitmap
,
3804 const struct nfs_server
*server
, kuid_t
*uid
,
3805 struct nfs4_string
*owner_name
)
3811 *uid
= make_kuid(&init_user_ns
, -2);
3812 if (unlikely(bitmap
[1] & (FATTR4_WORD1_OWNER
- 1U)))
3814 if (likely(bitmap
[1] & FATTR4_WORD1_OWNER
)) {
3815 p
= xdr_inline_decode(xdr
, 4);
3818 len
= be32_to_cpup(p
);
3819 p
= xdr_inline_decode(xdr
, len
);
3822 if (owner_name
!= NULL
) {
3823 owner_name
->data
= kmemdup(p
, len
, GFP_NOWAIT
);
3824 if (owner_name
->data
!= NULL
) {
3825 owner_name
->len
= len
;
3826 ret
= NFS_ATTR_FATTR_OWNER_NAME
;
3828 } else if (len
< XDR_MAX_NETOBJ
) {
3829 if (nfs_map_name_to_uid(server
, (char *)p
, len
, uid
) == 0)
3830 ret
= NFS_ATTR_FATTR_OWNER
;
3832 dprintk("%s: nfs_map_name_to_uid failed!\n",
3835 dprintk("%s: name too long (%u)!\n",
3837 bitmap
[1] &= ~FATTR4_WORD1_OWNER
;
3839 dprintk("%s: uid=%d\n", __func__
, (int)from_kuid(&init_user_ns
, *uid
));
3842 print_overflow_msg(__func__
, xdr
);
3846 static int decode_attr_group(struct xdr_stream
*xdr
, uint32_t *bitmap
,
3847 const struct nfs_server
*server
, kgid_t
*gid
,
3848 struct nfs4_string
*group_name
)
3854 *gid
= make_kgid(&init_user_ns
, -2);
3855 if (unlikely(bitmap
[1] & (FATTR4_WORD1_OWNER_GROUP
- 1U)))
3857 if (likely(bitmap
[1] & FATTR4_WORD1_OWNER_GROUP
)) {
3858 p
= xdr_inline_decode(xdr
, 4);
3861 len
= be32_to_cpup(p
);
3862 p
= xdr_inline_decode(xdr
, len
);
3865 if (group_name
!= NULL
) {
3866 group_name
->data
= kmemdup(p
, len
, GFP_NOWAIT
);
3867 if (group_name
->data
!= NULL
) {
3868 group_name
->len
= len
;
3869 ret
= NFS_ATTR_FATTR_GROUP_NAME
;
3871 } else if (len
< XDR_MAX_NETOBJ
) {
3872 if (nfs_map_group_to_gid(server
, (char *)p
, len
, gid
) == 0)
3873 ret
= NFS_ATTR_FATTR_GROUP
;
3875 dprintk("%s: nfs_map_group_to_gid failed!\n",
3878 dprintk("%s: name too long (%u)!\n",
3880 bitmap
[1] &= ~FATTR4_WORD1_OWNER_GROUP
;
3882 dprintk("%s: gid=%d\n", __func__
, (int)from_kgid(&init_user_ns
, *gid
));
3885 print_overflow_msg(__func__
, xdr
);
3889 static int decode_attr_rdev(struct xdr_stream
*xdr
, uint32_t *bitmap
, dev_t
*rdev
)
3891 uint32_t major
= 0, minor
= 0;
3896 if (unlikely(bitmap
[1] & (FATTR4_WORD1_RAWDEV
- 1U)))
3898 if (likely(bitmap
[1] & FATTR4_WORD1_RAWDEV
)) {
3901 p
= xdr_inline_decode(xdr
, 8);
3904 major
= be32_to_cpup(p
++);
3905 minor
= be32_to_cpup(p
);
3906 tmp
= MKDEV(major
, minor
);
3907 if (MAJOR(tmp
) == major
&& MINOR(tmp
) == minor
)
3909 bitmap
[1] &= ~ FATTR4_WORD1_RAWDEV
;
3910 ret
= NFS_ATTR_FATTR_RDEV
;
3912 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__
, major
, minor
);
3915 print_overflow_msg(__func__
, xdr
);
3919 static int decode_attr_space_avail(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3925 if (unlikely(bitmap
[1] & (FATTR4_WORD1_SPACE_AVAIL
- 1U)))
3927 if (likely(bitmap
[1] & FATTR4_WORD1_SPACE_AVAIL
)) {
3928 p
= xdr_inline_decode(xdr
, 8);
3931 xdr_decode_hyper(p
, res
);
3932 bitmap
[1] &= ~FATTR4_WORD1_SPACE_AVAIL
;
3934 dprintk("%s: space avail=%Lu\n", __func__
, (unsigned long long)*res
);
3937 print_overflow_msg(__func__
, xdr
);
3941 static int decode_attr_space_free(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3947 if (unlikely(bitmap
[1] & (FATTR4_WORD1_SPACE_FREE
- 1U)))
3949 if (likely(bitmap
[1] & FATTR4_WORD1_SPACE_FREE
)) {
3950 p
= xdr_inline_decode(xdr
, 8);
3953 xdr_decode_hyper(p
, res
);
3954 bitmap
[1] &= ~FATTR4_WORD1_SPACE_FREE
;
3956 dprintk("%s: space free=%Lu\n", __func__
, (unsigned long long)*res
);
3959 print_overflow_msg(__func__
, xdr
);
3963 static int decode_attr_space_total(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *res
)
3969 if (unlikely(bitmap
[1] & (FATTR4_WORD1_SPACE_TOTAL
- 1U)))
3971 if (likely(bitmap
[1] & FATTR4_WORD1_SPACE_TOTAL
)) {
3972 p
= xdr_inline_decode(xdr
, 8);
3975 xdr_decode_hyper(p
, res
);
3976 bitmap
[1] &= ~FATTR4_WORD1_SPACE_TOTAL
;
3978 dprintk("%s: space total=%Lu\n", __func__
, (unsigned long long)*res
);
3981 print_overflow_msg(__func__
, xdr
);
3985 static int decode_attr_space_used(struct xdr_stream
*xdr
, uint32_t *bitmap
, uint64_t *used
)
3991 if (unlikely(bitmap
[1] & (FATTR4_WORD1_SPACE_USED
- 1U)))
3993 if (likely(bitmap
[1] & FATTR4_WORD1_SPACE_USED
)) {
3994 p
= xdr_inline_decode(xdr
, 8);
3997 xdr_decode_hyper(p
, used
);
3998 bitmap
[1] &= ~FATTR4_WORD1_SPACE_USED
;
3999 ret
= NFS_ATTR_FATTR_SPACE_USED
;
4001 dprintk("%s: space used=%Lu\n", __func__
,
4002 (unsigned long long)*used
);
4005 print_overflow_msg(__func__
, xdr
);
4009 static int decode_attr_time(struct xdr_stream
*xdr
, struct timespec
*time
)
4015 p
= xdr_inline_decode(xdr
, 12);
4018 p
= xdr_decode_hyper(p
, &sec
);
4019 nsec
= be32_to_cpup(p
);
4020 time
->tv_sec
= (time_t)sec
;
4021 time
->tv_nsec
= (long)nsec
;
4024 print_overflow_msg(__func__
, xdr
);
4028 static int decode_attr_time_access(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct timespec
*time
)
4034 if (unlikely(bitmap
[1] & (FATTR4_WORD1_TIME_ACCESS
- 1U)))
4036 if (likely(bitmap
[1] & FATTR4_WORD1_TIME_ACCESS
)) {
4037 status
= decode_attr_time(xdr
, time
);
4039 status
= NFS_ATTR_FATTR_ATIME
;
4040 bitmap
[1] &= ~FATTR4_WORD1_TIME_ACCESS
;
4042 dprintk("%s: atime=%ld\n", __func__
, (long)time
->tv_sec
);
4046 static int decode_attr_time_metadata(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct timespec
*time
)
4052 if (unlikely(bitmap
[1] & (FATTR4_WORD1_TIME_METADATA
- 1U)))
4054 if (likely(bitmap
[1] & FATTR4_WORD1_TIME_METADATA
)) {
4055 status
= decode_attr_time(xdr
, time
);
4057 status
= NFS_ATTR_FATTR_CTIME
;
4058 bitmap
[1] &= ~FATTR4_WORD1_TIME_METADATA
;
4060 dprintk("%s: ctime=%ld\n", __func__
, (long)time
->tv_sec
);
4064 static int decode_attr_time_delta(struct xdr_stream
*xdr
, uint32_t *bitmap
,
4065 struct timespec
*time
)
4071 if (unlikely(bitmap
[1] & (FATTR4_WORD1_TIME_DELTA
- 1U)))
4073 if (likely(bitmap
[1] & FATTR4_WORD1_TIME_DELTA
)) {
4074 status
= decode_attr_time(xdr
, time
);
4075 bitmap
[1] &= ~FATTR4_WORD1_TIME_DELTA
;
4077 dprintk("%s: time_delta=%ld %ld\n", __func__
, (long)time
->tv_sec
,
4078 (long)time
->tv_nsec
);
4082 static int decode_attr_security_label(struct xdr_stream
*xdr
, uint32_t *bitmap
,
4083 struct nfs4_label
*label
)
4091 if (unlikely(bitmap
[2] & (FATTR4_WORD2_SECURITY_LABEL
- 1U)))
4093 if (likely(bitmap
[2] & FATTR4_WORD2_SECURITY_LABEL
)) {
4094 p
= xdr_inline_decode(xdr
, 4);
4097 lfs
= be32_to_cpup(p
++);
4098 p
= xdr_inline_decode(xdr
, 4);
4101 pi
= be32_to_cpup(p
++);
4102 p
= xdr_inline_decode(xdr
, 4);
4105 len
= be32_to_cpup(p
++);
4106 p
= xdr_inline_decode(xdr
, len
);
4109 if (len
< NFS4_MAXLABELLEN
) {
4111 memcpy(label
->label
, p
, len
);
4115 status
= NFS_ATTR_FATTR_V4_SECURITY_LABEL
;
4117 bitmap
[2] &= ~FATTR4_WORD2_SECURITY_LABEL
;
4119 printk(KERN_WARNING
"%s: label too long (%u)!\n",
4122 if (label
&& label
->label
)
4123 dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__
,
4124 (char *)label
->label
, label
->len
, label
->pi
, label
->lfs
);
4128 print_overflow_msg(__func__
, xdr
);
4132 static int decode_attr_time_modify(struct xdr_stream
*xdr
, uint32_t *bitmap
, struct timespec
*time
)
4138 if (unlikely(bitmap
[1] & (FATTR4_WORD1_TIME_MODIFY
- 1U)))
4140 if (likely(bitmap
[1] & FATTR4_WORD1_TIME_MODIFY
)) {
4141 status
= decode_attr_time(xdr
, time
);
4143 status
= NFS_ATTR_FATTR_MTIME
;
4144 bitmap
[1] &= ~FATTR4_WORD1_TIME_MODIFY
;
4146 dprintk("%s: mtime=%ld\n", __func__
, (long)time
->tv_sec
);
4150 static int verify_attr_len(struct xdr_stream
*xdr
, unsigned int savep
, uint32_t attrlen
)
4152 unsigned int attrwords
= XDR_QUADLEN(attrlen
);
4153 unsigned int nwords
= (xdr_stream_pos(xdr
) - savep
) >> 2;
4155 if (unlikely(attrwords
!= nwords
)) {
4156 dprintk("%s: server returned incorrect attribute length: "
4160 (attrwords
< nwords
) ? '<' : '>',
4167 static int decode_change_info(struct xdr_stream
*xdr
, struct nfs4_change_info
*cinfo
)
4171 p
= xdr_inline_decode(xdr
, 20);
4174 cinfo
->atomic
= be32_to_cpup(p
++);
4175 p
= xdr_decode_hyper(p
, &cinfo
->before
);
4176 xdr_decode_hyper(p
, &cinfo
->after
);
4179 print_overflow_msg(__func__
, xdr
);
4183 static int decode_access(struct xdr_stream
*xdr
, u32
*supported
, u32
*access
)
4189 status
= decode_op_hdr(xdr
, OP_ACCESS
);
4192 p
= xdr_inline_decode(xdr
, 8);
4195 supp
= be32_to_cpup(p
++);
4196 acc
= be32_to_cpup(p
);
4201 print_overflow_msg(__func__
, xdr
);
4205 static int decode_opaque_fixed(struct xdr_stream
*xdr
, void *buf
, size_t len
)
4209 p
= xdr_inline_decode(xdr
, len
);
4211 memcpy(buf
, p
, len
);
4214 print_overflow_msg(__func__
, xdr
);
4218 static int decode_stateid(struct xdr_stream
*xdr
, nfs4_stateid
*stateid
)
4220 return decode_opaque_fixed(xdr
, stateid
, NFS4_STATEID_SIZE
);
4223 static int decode_close(struct xdr_stream
*xdr
, struct nfs_closeres
*res
)
4227 status
= decode_op_hdr(xdr
, OP_CLOSE
);
4229 nfs_increment_open_seqid(status
, res
->seqid
);
4231 status
= decode_stateid(xdr
, &res
->stateid
);
4235 static int decode_verifier(struct xdr_stream
*xdr
, void *verifier
)
4237 return decode_opaque_fixed(xdr
, verifier
, NFS4_VERIFIER_SIZE
);
4240 static int decode_write_verifier(struct xdr_stream
*xdr
, struct nfs_write_verifier
*verifier
)
4242 return decode_opaque_fixed(xdr
, verifier
->data
, NFS4_VERIFIER_SIZE
);
4245 static int decode_commit(struct xdr_stream
*xdr
, struct nfs_commitres
*res
)
4249 status
= decode_op_hdr(xdr
, OP_COMMIT
);
4251 status
= decode_write_verifier(xdr
, &res
->verf
->verifier
);
4255 static int decode_create(struct xdr_stream
*xdr
, struct nfs4_change_info
*cinfo
)
4261 status
= decode_op_hdr(xdr
, OP_CREATE
);
4264 if ((status
= decode_change_info(xdr
, cinfo
)))
4266 p
= xdr_inline_decode(xdr
, 4);
4269 bmlen
= be32_to_cpup(p
);
4270 p
= xdr_inline_decode(xdr
, bmlen
<< 2);
4274 print_overflow_msg(__func__
, xdr
);
4278 static int decode_server_caps(struct xdr_stream
*xdr
, struct nfs4_server_caps_res
*res
)
4281 uint32_t attrlen
, bitmap
[3] = {0};
4284 if ((status
= decode_op_hdr(xdr
, OP_GETATTR
)) != 0)
4286 if ((status
= decode_attr_bitmap(xdr
, bitmap
)) != 0)
4288 if ((status
= decode_attr_length(xdr
, &attrlen
, &savep
)) != 0)
4290 if ((status
= decode_attr_supported(xdr
, bitmap
, res
->attr_bitmask
)) != 0)
4292 if ((status
= decode_attr_fh_expire_type(xdr
, bitmap
,
4293 &res
->fh_expire_type
)) != 0)
4295 if ((status
= decode_attr_link_support(xdr
, bitmap
, &res
->has_links
)) != 0)
4297 if ((status
= decode_attr_symlink_support(xdr
, bitmap
, &res
->has_symlinks
)) != 0)
4299 if ((status
= decode_attr_aclsupport(xdr
, bitmap
, &res
->acl_bitmask
)) != 0)
4301 status
= verify_attr_len(xdr
, savep
, attrlen
);
4303 dprintk("%s: xdr returned %d!\n", __func__
, -status
);
4307 static int decode_statfs(struct xdr_stream
*xdr
, struct nfs_fsstat
*fsstat
)
4310 uint32_t attrlen
, bitmap
[3] = {0};
4313 if ((status
= decode_op_hdr(xdr
, OP_GETATTR
)) != 0)
4315 if ((status
= decode_attr_bitmap(xdr
, bitmap
)) != 0)
4317 if ((status
= decode_attr_length(xdr
, &attrlen
, &savep
)) != 0)
4320 if ((status
= decode_attr_files_avail(xdr
, bitmap
, &fsstat
->afiles
)) != 0)
4322 if ((status
= decode_attr_files_free(xdr
, bitmap
, &fsstat
->ffiles
)) != 0)
4324 if ((status
= decode_attr_files_total(xdr
, bitmap
, &fsstat
->tfiles
)) != 0)
4326 if ((status
= decode_attr_space_avail(xdr
, bitmap
, &fsstat
->abytes
)) != 0)
4328 if ((status
= decode_attr_space_free(xdr
, bitmap
, &fsstat
->fbytes
)) != 0)
4330 if ((status
= decode_attr_space_total(xdr
, bitmap
, &fsstat
->tbytes
)) != 0)
4333 status
= verify_attr_len(xdr
, savep
, attrlen
);
4335 dprintk("%s: xdr returned %d!\n", __func__
, -status
);
4339 static int decode_pathconf(struct xdr_stream
*xdr
, struct nfs_pathconf
*pathconf
)
4342 uint32_t attrlen
, bitmap
[3] = {0};
4345 if ((status
= decode_op_hdr(xdr
, OP_GETATTR
)) != 0)
4347 if ((status
= decode_attr_bitmap(xdr
, bitmap
)) != 0)
4349 if ((status
= decode_attr_length(xdr
, &attrlen
, &savep
)) != 0)
4352 if ((status
= decode_attr_maxlink(xdr
, bitmap
, &pathconf
->max_link
)) != 0)
4354 if ((status
= decode_attr_maxname(xdr
, bitmap
, &pathconf
->max_namelen
)) != 0)
4357 status
= verify_attr_len(xdr
, savep
, attrlen
);
4359 dprintk("%s: xdr returned %d!\n", __func__
, -status
);
4363 static int decode_threshold_hint(struct xdr_stream
*xdr
,
4371 if (likely(bitmap
[0] & hint_bit
)) {
4372 p
= xdr_inline_decode(xdr
, 8);
4375 xdr_decode_hyper(p
, res
);
4379 print_overflow_msg(__func__
, xdr
);
4383 static int decode_first_threshold_item4(struct xdr_stream
*xdr
,
4384 struct nfs4_threshold
*res
)
4388 uint32_t bitmap
[3] = {0,}, attrlen
;
4392 p
= xdr_inline_decode(xdr
, 4);
4394 print_overflow_msg(__func__
, xdr
);
4397 res
->l_type
= be32_to_cpup(p
);
4399 /* thi_hintset bitmap */
4400 status
= decode_attr_bitmap(xdr
, bitmap
);
4404 /* thi_hintlist length */
4405 status
= decode_attr_length(xdr
, &attrlen
, &savep
);
4409 status
= decode_threshold_hint(xdr
, bitmap
, &res
->rd_sz
, THRESHOLD_RD
);
4412 status
= decode_threshold_hint(xdr
, bitmap
, &res
->wr_sz
, THRESHOLD_WR
);
4415 status
= decode_threshold_hint(xdr
, bitmap
, &res
->rd_io_sz
,
4419 status
= decode_threshold_hint(xdr
, bitmap
, &res
->wr_io_sz
,
4424 status
= verify_attr_len(xdr
, savep
, attrlen
);
4425 res
->bm
= bitmap
[0];
4427 dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n",
4428 __func__
, res
->bm
, res
->rd_sz
, res
->wr_sz
, res
->rd_io_sz
,
4431 dprintk("%s ret=%d!\n", __func__
, status
);
4436 * Thresholds on pNFS direct I/O vrs MDS I/O
4438 static int decode_attr_mdsthreshold(struct xdr_stream
*xdr
,
4440 struct nfs4_threshold
*res
)
4446 if (unlikely(bitmap
[2] & (FATTR4_WORD2_MDSTHRESHOLD
- 1U)))
4448 if (bitmap
[2] & FATTR4_WORD2_MDSTHRESHOLD
) {
4449 /* Did the server return an unrequested attribute? */
4450 if (unlikely(res
== NULL
))
4452 p
= xdr_inline_decode(xdr
, 4);
4455 num
= be32_to_cpup(p
);
4459 printk(KERN_INFO
"%s: Warning: Multiple pNFS layout "
4460 "drivers per filesystem not supported\n",
4463 status
= decode_first_threshold_item4(xdr
, res
);
4464 bitmap
[2] &= ~FATTR4_WORD2_MDSTHRESHOLD
;
4468 print_overflow_msg(__func__
, xdr
);
4472 static int decode_getfattr_attrs(struct xdr_stream
*xdr
, uint32_t *bitmap
,
4473 struct nfs_fattr
*fattr
, struct nfs_fh
*fh
,
4474 struct nfs4_fs_locations
*fs_loc
, struct nfs4_label
*label
,
4475 const struct nfs_server
*server
)
4482 status
= decode_attr_type(xdr
, bitmap
, &type
);
4487 fattr
->mode
|= nfs_type2fmt
[type
];
4488 fattr
->valid
|= status
;
4491 status
= decode_attr_change(xdr
, bitmap
, &fattr
->change_attr
);
4494 fattr
->valid
|= status
;
4496 status
= decode_attr_size(xdr
, bitmap
, &fattr
->size
);
4499 fattr
->valid
|= status
;
4501 status
= decode_attr_fsid(xdr
, bitmap
, &fattr
->fsid
);
4504 fattr
->valid
|= status
;
4507 status
= decode_attr_error(xdr
, bitmap
, &err
);
4511 status
= decode_attr_filehandle(xdr
, bitmap
, fh
);
4515 status
= decode_attr_fileid(xdr
, bitmap
, &fattr
->fileid
);
4518 fattr
->valid
|= status
;
4520 status
= decode_attr_fs_locations(xdr
, bitmap
, fs_loc
);
4523 fattr
->valid
|= status
;
4525 status
= decode_attr_mode(xdr
, bitmap
, &fmode
);
4529 fattr
->mode
|= fmode
;
4530 fattr
->valid
|= status
;
4533 status
= decode_attr_nlink(xdr
, bitmap
, &fattr
->nlink
);
4536 fattr
->valid
|= status
;
4538 status
= decode_attr_owner(xdr
, bitmap
, server
, &fattr
->uid
, fattr
->owner_name
);
4541 fattr
->valid
|= status
;
4543 status
= decode_attr_group(xdr
, bitmap
, server
, &fattr
->gid
, fattr
->group_name
);
4546 fattr
->valid
|= status
;
4548 status
= decode_attr_rdev(xdr
, bitmap
, &fattr
->rdev
);
4551 fattr
->valid
|= status
;
4553 status
= decode_attr_space_used(xdr
, bitmap
, &fattr
->du
.nfs3
.used
);
4556 fattr
->valid
|= status
;
4558 status
= decode_attr_time_access(xdr
, bitmap
, &fattr
->atime
);
4561 fattr
->valid
|= status
;
4563 status
= decode_attr_time_metadata(xdr
, bitmap
, &fattr
->ctime
);
4566 fattr
->valid
|= status
;
4568 status
= decode_attr_time_modify(xdr
, bitmap
, &fattr
->mtime
);
4571 fattr
->valid
|= status
;
4573 status
= decode_attr_mounted_on_fileid(xdr
, bitmap
, &fattr
->mounted_on_fileid
);
4576 fattr
->valid
|= status
;
4578 status
= decode_attr_mdsthreshold(xdr
, bitmap
, fattr
->mdsthreshold
);
4583 status
= decode_attr_security_label(xdr
, bitmap
, label
);
4586 fattr
->valid
|= status
;
4590 dprintk("%s: xdr returned %d\n", __func__
, -status
);
4594 static int decode_getfattr_generic(struct xdr_stream
*xdr
, struct nfs_fattr
*fattr
,
4595 struct nfs_fh
*fh
, struct nfs4_fs_locations
*fs_loc
,
4596 struct nfs4_label
*label
, const struct nfs_server
*server
)
4603 status
= decode_op_hdr(xdr
, OP_GETATTR
);
4607 status
= decode_attr_bitmap(xdr
, bitmap
);
4611 status
= decode_attr_length(xdr
, &attrlen
, &savep
);
4615 status
= decode_getfattr_attrs(xdr
, bitmap
, fattr
, fh
, fs_loc
,
4620 status
= verify_attr_len(xdr
, savep
, attrlen
);
4622 dprintk("%s: xdr returned %d\n", __func__
, -status
);
4626 static int decode_getfattr_label(struct xdr_stream
*xdr
, struct nfs_fattr
*fattr
,
4627 struct nfs4_label
*label
, const struct nfs_server
*server
)
4629 return decode_getfattr_generic(xdr
, fattr
, NULL
, NULL
, label
, server
);
4632 static int decode_getfattr(struct xdr_stream
*xdr
, struct nfs_fattr
*fattr
,
4633 const struct nfs_server
*server
)
4635 return decode_getfattr_generic(xdr
, fattr
, NULL
, NULL
, NULL
, server
);
4639 * Decode potentially multiple layout types. Currently we only support
4640 * one layout driver per file system.
4642 static int decode_first_pnfs_layout_type(struct xdr_stream
*xdr
,
4643 uint32_t *layouttype
)
4648 p
= xdr_inline_decode(xdr
, 4);
4651 num
= be32_to_cpup(p
);
4653 /* pNFS is not supported by the underlying file system */
4659 printk(KERN_INFO
"NFS: %s: Warning: Multiple pNFS layout "
4660 "drivers per filesystem not supported\n", __func__
);
4662 /* Decode and set first layout type, move xdr->p past unused types */
4663 p
= xdr_inline_decode(xdr
, num
* 4);
4666 *layouttype
= be32_to_cpup(p
);
4669 print_overflow_msg(__func__
, xdr
);
4674 * The type of file system exported.
4675 * Note we must ensure that layouttype is set in any non-error case.
4677 static int decode_attr_pnfstype(struct xdr_stream
*xdr
, uint32_t *bitmap
,
4678 uint32_t *layouttype
)
4682 dprintk("%s: bitmap is %x\n", __func__
, bitmap
[1]);
4683 if (unlikely(bitmap
[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES
- 1U)))
4685 if (bitmap
[1] & FATTR4_WORD1_FS_LAYOUT_TYPES
) {
4686 status
= decode_first_pnfs_layout_type(xdr
, layouttype
);
4687 bitmap
[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES
;
4694 * The prefered block size for layout directed io
4696 static int decode_attr_layout_blksize(struct xdr_stream
*xdr
, uint32_t *bitmap
,
4701 dprintk("%s: bitmap is %x\n", __func__
, bitmap
[2]);
4703 if (bitmap
[2] & FATTR4_WORD2_LAYOUT_BLKSIZE
) {
4704 p
= xdr_inline_decode(xdr
, 4);
4706 print_overflow_msg(__func__
, xdr
);
4709 *res
= be32_to_cpup(p
);
4710 bitmap
[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE
;
4715 static int decode_fsinfo(struct xdr_stream
*xdr
, struct nfs_fsinfo
*fsinfo
)
4718 uint32_t attrlen
, bitmap
[3];
4721 if ((status
= decode_op_hdr(xdr
, OP_GETATTR
)) != 0)
4723 if ((status
= decode_attr_bitmap(xdr
, bitmap
)) != 0)
4725 if ((status
= decode_attr_length(xdr
, &attrlen
, &savep
)) != 0)
4728 fsinfo
->rtmult
= fsinfo
->wtmult
= 512; /* ??? */
4730 if ((status
= decode_attr_lease_time(xdr
, bitmap
, &fsinfo
->lease_time
)) != 0)
4732 if ((status
= decode_attr_maxfilesize(xdr
, bitmap
, &fsinfo
->maxfilesize
)) != 0)
4734 if ((status
= decode_attr_maxread(xdr
, bitmap
, &fsinfo
->rtmax
)) != 0)
4736 fsinfo
->rtpref
= fsinfo
->dtpref
= fsinfo
->rtmax
;
4737 if ((status
= decode_attr_maxwrite(xdr
, bitmap
, &fsinfo
->wtmax
)) != 0)
4739 fsinfo
->wtpref
= fsinfo
->wtmax
;
4740 status
= decode_attr_time_delta(xdr
, bitmap
, &fsinfo
->time_delta
);
4743 status
= decode_attr_pnfstype(xdr
, bitmap
, &fsinfo
->layouttype
);
4746 status
= decode_attr_layout_blksize(xdr
, bitmap
, &fsinfo
->blksize
);
4750 status
= verify_attr_len(xdr
, savep
, attrlen
);
4752 dprintk("%s: xdr returned %d!\n", __func__
, -status
);
4756 static int decode_getfh(struct xdr_stream
*xdr
, struct nfs_fh
*fh
)
4762 /* Zero handle first to allow comparisons */
4763 memset(fh
, 0, sizeof(*fh
));
4765 status
= decode_op_hdr(xdr
, OP_GETFH
);
4769 p
= xdr_inline_decode(xdr
, 4);
4772 len
= be32_to_cpup(p
);
4773 if (len
> NFS4_FHSIZE
)
4776 p
= xdr_inline_decode(xdr
, len
);
4779 memcpy(fh
->data
, p
, len
);
4782 print_overflow_msg(__func__
, xdr
);
4786 static int decode_link(struct xdr_stream
*xdr
, struct nfs4_change_info
*cinfo
)
4790 status
= decode_op_hdr(xdr
, OP_LINK
);
4793 return decode_change_info(xdr
, cinfo
);
4797 * We create the owner, so we know a proper owner.id length is 4.
4799 static int decode_lock_denied (struct xdr_stream
*xdr
, struct file_lock
*fl
)
4801 uint64_t offset
, length
, clientid
;
4803 uint32_t namelen
, type
;
4805 p
= xdr_inline_decode(xdr
, 32); /* read 32 bytes */
4808 p
= xdr_decode_hyper(p
, &offset
); /* read 2 8-byte long words */
4809 p
= xdr_decode_hyper(p
, &length
);
4810 type
= be32_to_cpup(p
++); /* 4 byte read */
4811 if (fl
!= NULL
) { /* manipulate file lock */
4812 fl
->fl_start
= (loff_t
)offset
;
4813 fl
->fl_end
= fl
->fl_start
+ (loff_t
)length
- 1;
4814 if (length
== ~(uint64_t)0)
4815 fl
->fl_end
= OFFSET_MAX
;
4816 fl
->fl_type
= F_WRLCK
;
4818 fl
->fl_type
= F_RDLCK
;
4821 p
= xdr_decode_hyper(p
, &clientid
); /* read 8 bytes */
4822 namelen
= be32_to_cpup(p
); /* read 4 bytes */ /* have read all 32 bytes now */
4823 p
= xdr_inline_decode(xdr
, namelen
); /* variable size field */
4825 return -NFS4ERR_DENIED
;
4827 print_overflow_msg(__func__
, xdr
);
4831 static int decode_lock(struct xdr_stream
*xdr
, struct nfs_lock_res
*res
)
4835 status
= decode_op_hdr(xdr
, OP_LOCK
);
4839 status
= decode_stateid(xdr
, &res
->stateid
);
4840 if (unlikely(status
))
4842 } else if (status
== -NFS4ERR_DENIED
)
4843 status
= decode_lock_denied(xdr
, NULL
);
4844 if (res
->open_seqid
!= NULL
)
4845 nfs_increment_open_seqid(status
, res
->open_seqid
);
4846 nfs_increment_lock_seqid(status
, res
->lock_seqid
);
4851 static int decode_lockt(struct xdr_stream
*xdr
, struct nfs_lockt_res
*res
)
4854 status
= decode_op_hdr(xdr
, OP_LOCKT
);
4855 if (status
== -NFS4ERR_DENIED
)
4856 return decode_lock_denied(xdr
, res
->denied
);
4860 static int decode_locku(struct xdr_stream
*xdr
, struct nfs_locku_res
*res
)
4864 status
= decode_op_hdr(xdr
, OP_LOCKU
);
4866 nfs_increment_lock_seqid(status
, res
->seqid
);
4868 status
= decode_stateid(xdr
, &res
->stateid
);
4872 static int decode_release_lockowner(struct xdr_stream
*xdr
)
4874 return decode_op_hdr(xdr
, OP_RELEASE_LOCKOWNER
);
4877 static int decode_lookup(struct xdr_stream
*xdr
)
4879 return decode_op_hdr(xdr
, OP_LOOKUP
);
4882 /* This is too sick! */
4883 static int decode_space_limit(struct xdr_stream
*xdr
, u64
*maxsize
)
4886 uint32_t limit_type
, nblocks
, blocksize
;
4888 p
= xdr_inline_decode(xdr
, 12);
4891 limit_type
= be32_to_cpup(p
++);
4892 switch (limit_type
) {
4894 xdr_decode_hyper(p
, maxsize
);
4897 nblocks
= be32_to_cpup(p
++);
4898 blocksize
= be32_to_cpup(p
);
4899 *maxsize
= (uint64_t)nblocks
* (uint64_t)blocksize
;
4903 print_overflow_msg(__func__
, xdr
);
4907 static int decode_delegation(struct xdr_stream
*xdr
, struct nfs_openres
*res
)
4910 uint32_t delegation_type
;
4913 p
= xdr_inline_decode(xdr
, 4);
4916 delegation_type
= be32_to_cpup(p
);
4917 if (delegation_type
== NFS4_OPEN_DELEGATE_NONE
) {
4918 res
->delegation_type
= 0;
4921 status
= decode_stateid(xdr
, &res
->delegation
);
4922 if (unlikely(status
))
4924 p
= xdr_inline_decode(xdr
, 4);
4927 res
->do_recall
= be32_to_cpup(p
);
4929 switch (delegation_type
) {
4930 case NFS4_OPEN_DELEGATE_READ
:
4931 res
->delegation_type
= FMODE_READ
;
4933 case NFS4_OPEN_DELEGATE_WRITE
:
4934 res
->delegation_type
= FMODE_WRITE
|FMODE_READ
;
4935 if (decode_space_limit(xdr
, &res
->maxsize
) < 0)
4938 return decode_ace(xdr
, NULL
, res
->server
->nfs_client
);
4940 print_overflow_msg(__func__
, xdr
);
4944 static int decode_open(struct xdr_stream
*xdr
, struct nfs_openres
*res
)
4947 uint32_t savewords
, bmlen
, i
;
4950 status
= decode_op_hdr(xdr
, OP_OPEN
);
4952 nfs_increment_open_seqid(status
, res
->seqid
);
4954 status
= decode_stateid(xdr
, &res
->stateid
);
4955 if (unlikely(status
))
4958 decode_change_info(xdr
, &res
->cinfo
);
4960 p
= xdr_inline_decode(xdr
, 8);
4963 res
->rflags
= be32_to_cpup(p
++);
4964 bmlen
= be32_to_cpup(p
);
4968 p
= xdr_inline_decode(xdr
, bmlen
<< 2);
4971 savewords
= min_t(uint32_t, bmlen
, NFS4_BITMAP_SIZE
);
4972 for (i
= 0; i
< savewords
; ++i
)
4973 res
->attrset
[i
] = be32_to_cpup(p
++);
4974 for (; i
< NFS4_BITMAP_SIZE
; i
++)
4975 res
->attrset
[i
] = 0;
4977 return decode_delegation(xdr
, res
);
4979 dprintk("%s: Bitmap too large! Length = %u\n", __func__
, bmlen
);
4982 print_overflow_msg(__func__
, xdr
);
4986 static int decode_open_confirm(struct xdr_stream
*xdr
, struct nfs_open_confirmres
*res
)
4990 status
= decode_op_hdr(xdr
, OP_OPEN_CONFIRM
);
4992 nfs_increment_open_seqid(status
, res
->seqid
);
4994 status
= decode_stateid(xdr
, &res
->stateid
);
4998 static int decode_open_downgrade(struct xdr_stream
*xdr
, struct nfs_closeres
*res
)
5002 status
= decode_op_hdr(xdr
, OP_OPEN_DOWNGRADE
);
5004 nfs_increment_open_seqid(status
, res
->seqid
);
5006 status
= decode_stateid(xdr
, &res
->stateid
);
5010 static int decode_putfh(struct xdr_stream
*xdr
)
5012 return decode_op_hdr(xdr
, OP_PUTFH
);
5015 static int decode_putrootfh(struct xdr_stream
*xdr
)
5017 return decode_op_hdr(xdr
, OP_PUTROOTFH
);
5020 static int decode_read(struct xdr_stream
*xdr
, struct rpc_rqst
*req
, struct nfs_readres
*res
)
5023 uint32_t count
, eof
, recvd
;
5026 status
= decode_op_hdr(xdr
, OP_READ
);
5029 p
= xdr_inline_decode(xdr
, 8);
5032 eof
= be32_to_cpup(p
++);
5033 count
= be32_to_cpup(p
);
5034 recvd
= xdr_read_pages(xdr
, count
);
5035 if (count
> recvd
) {
5036 dprintk("NFS: server cheating in read reply: "
5037 "count %u > recvd %u\n", count
, recvd
);
5045 print_overflow_msg(__func__
, xdr
);
5049 static int decode_readdir(struct xdr_stream
*xdr
, struct rpc_rqst
*req
, struct nfs4_readdir_res
*readdir
)
5054 status
= decode_op_hdr(xdr
, OP_READDIR
);
5056 status
= decode_verifier(xdr
, readdir
->verifier
.data
);
5057 if (unlikely(status
))
5059 memcpy(verf
, readdir
->verifier
.data
, sizeof(verf
));
5060 dprintk("%s: verifier = %08x:%08x\n",
5061 __func__
, verf
[0], verf
[1]);
5062 return xdr_read_pages(xdr
, xdr
->buf
->page_len
);
5065 static int decode_readlink(struct xdr_stream
*xdr
, struct rpc_rqst
*req
)
5067 struct xdr_buf
*rcvbuf
= &req
->rq_rcv_buf
;
5072 status
= decode_op_hdr(xdr
, OP_READLINK
);
5076 /* Convert length of symlink */
5077 p
= xdr_inline_decode(xdr
, 4);
5080 len
= be32_to_cpup(p
);
5081 if (len
>= rcvbuf
->page_len
|| len
<= 0) {
5082 dprintk("nfs: server returned giant symlink!\n");
5083 return -ENAMETOOLONG
;
5085 recvd
= xdr_read_pages(xdr
, len
);
5087 dprintk("NFS: server cheating in readlink reply: "
5088 "count %u > recvd %u\n", len
, recvd
);
5092 * The XDR encode routine has set things up so that
5093 * the link text will be copied directly into the
5094 * buffer. We just have to do overflow-checking,
5095 * and and null-terminate the text (the VFS expects
5096 * null-termination).
5098 xdr_terminate_string(rcvbuf
, len
);
5101 print_overflow_msg(__func__
, xdr
);
5105 static int decode_remove(struct xdr_stream
*xdr
, struct nfs4_change_info
*cinfo
)
5109 status
= decode_op_hdr(xdr
, OP_REMOVE
);
5112 status
= decode_change_info(xdr
, cinfo
);
5117 static int decode_rename(struct xdr_stream
*xdr
, struct nfs4_change_info
*old_cinfo
,
5118 struct nfs4_change_info
*new_cinfo
)
5122 status
= decode_op_hdr(xdr
, OP_RENAME
);
5125 if ((status
= decode_change_info(xdr
, old_cinfo
)))
5127 status
= decode_change_info(xdr
, new_cinfo
);
5132 static int decode_renew(struct xdr_stream
*xdr
)
5134 return decode_op_hdr(xdr
, OP_RENEW
);
5138 decode_restorefh(struct xdr_stream
*xdr
)
5140 return decode_op_hdr(xdr
, OP_RESTOREFH
);
5143 static int decode_getacl(struct xdr_stream
*xdr
, struct rpc_rqst
*req
,
5144 struct nfs_getaclres
*res
)
5150 unsigned int pg_offset
;
5153 if ((status
= decode_op_hdr(xdr
, OP_GETATTR
)) != 0)
5156 xdr_enter_page(xdr
, xdr
->buf
->page_len
);
5158 /* Calculate the offset of the page data */
5159 pg_offset
= xdr
->buf
->head
[0].iov_len
;
5161 if ((status
= decode_attr_bitmap(xdr
, bitmap
)) != 0)
5163 if ((status
= decode_attr_length(xdr
, &attrlen
, &savep
)) != 0)
5166 if (unlikely(bitmap
[0] & (FATTR4_WORD0_ACL
- 1U)))
5168 if (likely(bitmap
[0] & FATTR4_WORD0_ACL
)) {
5170 /* The bitmap (xdr len + bitmaps) and the attr xdr len words
5171 * are stored with the acl data to handle the problem of
5172 * variable length bitmaps.*/
5173 res
->acl_data_offset
= xdr_stream_pos(xdr
) - pg_offset
;
5174 res
->acl_len
= attrlen
;
5176 /* Check for receive buffer overflow */
5177 if (res
->acl_len
> (xdr
->nwords
<< 2) ||
5178 res
->acl_len
+ res
->acl_data_offset
> xdr
->buf
->page_len
) {
5179 res
->acl_flags
|= NFS4_ACL_TRUNC
;
5180 dprintk("NFS: acl reply: attrlen %u > page_len %u\n",
5181 attrlen
, xdr
->nwords
<< 2);
5184 status
= -EOPNOTSUPP
;
5191 decode_savefh(struct xdr_stream
*xdr
)
5193 return decode_op_hdr(xdr
, OP_SAVEFH
);
5196 static int decode_setattr(struct xdr_stream
*xdr
)
5202 status
= decode_op_hdr(xdr
, OP_SETATTR
);
5205 p
= xdr_inline_decode(xdr
, 4);
5208 bmlen
= be32_to_cpup(p
);
5209 p
= xdr_inline_decode(xdr
, bmlen
<< 2);
5213 print_overflow_msg(__func__
, xdr
);
5217 static int decode_setclientid(struct xdr_stream
*xdr
, struct nfs4_setclientid_res
*res
)
5223 p
= xdr_inline_decode(xdr
, 8);
5226 opnum
= be32_to_cpup(p
++);
5227 if (opnum
!= OP_SETCLIENTID
) {
5228 dprintk("nfs: decode_setclientid: Server returned operation"
5232 nfserr
= be32_to_cpup(p
);
5233 if (nfserr
== NFS_OK
) {
5234 p
= xdr_inline_decode(xdr
, 8 + NFS4_VERIFIER_SIZE
);
5237 p
= xdr_decode_hyper(p
, &res
->clientid
);
5238 memcpy(res
->confirm
.data
, p
, NFS4_VERIFIER_SIZE
);
5239 } else if (nfserr
== NFSERR_CLID_INUSE
) {
5242 /* skip netid string */
5243 p
= xdr_inline_decode(xdr
, 4);
5246 len
= be32_to_cpup(p
);
5247 p
= xdr_inline_decode(xdr
, len
);
5251 /* skip uaddr string */
5252 p
= xdr_inline_decode(xdr
, 4);
5255 len
= be32_to_cpup(p
);
5256 p
= xdr_inline_decode(xdr
, len
);
5259 return -NFSERR_CLID_INUSE
;
5261 return nfs4_stat_to_errno(nfserr
);
5265 print_overflow_msg(__func__
, xdr
);
5269 static int decode_setclientid_confirm(struct xdr_stream
*xdr
)
5271 return decode_op_hdr(xdr
, OP_SETCLIENTID_CONFIRM
);
5274 static int decode_write(struct xdr_stream
*xdr
, struct nfs_writeres
*res
)
5279 status
= decode_op_hdr(xdr
, OP_WRITE
);
5283 p
= xdr_inline_decode(xdr
, 8);
5286 res
->count
= be32_to_cpup(p
++);
5287 res
->verf
->committed
= be32_to_cpup(p
++);
5288 return decode_write_verifier(xdr
, &res
->verf
->verifier
);
5290 print_overflow_msg(__func__
, xdr
);
5294 static int decode_delegreturn(struct xdr_stream
*xdr
)
5296 return decode_op_hdr(xdr
, OP_DELEGRETURN
);
5299 static int decode_secinfo_gss(struct xdr_stream
*xdr
,
5300 struct nfs4_secinfo4
*flavor
)
5305 p
= xdr_inline_decode(xdr
, 4);
5308 oid_len
= be32_to_cpup(p
);
5309 if (oid_len
> GSS_OID_MAX_LEN
)
5312 p
= xdr_inline_decode(xdr
, oid_len
);
5315 memcpy(flavor
->flavor_info
.oid
.data
, p
, oid_len
);
5316 flavor
->flavor_info
.oid
.len
= oid_len
;
5318 p
= xdr_inline_decode(xdr
, 8);
5321 flavor
->flavor_info
.qop
= be32_to_cpup(p
++);
5322 flavor
->flavor_info
.service
= be32_to_cpup(p
);
5327 print_overflow_msg(__func__
, xdr
);
5333 static int decode_secinfo_common(struct xdr_stream
*xdr
, struct nfs4_secinfo_res
*res
)
5335 struct nfs4_secinfo4
*sec_flavor
;
5336 unsigned int i
, num_flavors
;
5340 p
= xdr_inline_decode(xdr
, 4);
5344 res
->flavors
->num_flavors
= 0;
5345 num_flavors
= be32_to_cpup(p
);
5347 for (i
= 0; i
< num_flavors
; i
++) {
5348 sec_flavor
= &res
->flavors
->flavors
[i
];
5349 if ((char *)&sec_flavor
[1] - (char *)res
->flavors
> PAGE_SIZE
)
5352 p
= xdr_inline_decode(xdr
, 4);
5355 sec_flavor
->flavor
= be32_to_cpup(p
);
5357 if (sec_flavor
->flavor
== RPC_AUTH_GSS
) {
5358 status
= decode_secinfo_gss(xdr
, sec_flavor
);
5362 res
->flavors
->num_flavors
++;
5369 print_overflow_msg(__func__
, xdr
);
5373 static int decode_secinfo(struct xdr_stream
*xdr
, struct nfs4_secinfo_res
*res
)
5375 int status
= decode_op_hdr(xdr
, OP_SECINFO
);
5378 return decode_secinfo_common(xdr
, res
);
5381 #if defined(CONFIG_NFS_V4_1)
5382 static int decode_secinfo_no_name(struct xdr_stream
*xdr
, struct nfs4_secinfo_res
*res
)
5384 int status
= decode_op_hdr(xdr
, OP_SECINFO_NO_NAME
);
5387 return decode_secinfo_common(xdr
, res
);
5390 static int decode_exchange_id(struct xdr_stream
*xdr
,
5391 struct nfs41_exchange_id_res
*res
)
5397 uint32_t impl_id_count
;
5399 status
= decode_op_hdr(xdr
, OP_EXCHANGE_ID
);
5403 p
= xdr_inline_decode(xdr
, 8);
5406 xdr_decode_hyper(p
, &res
->clientid
);
5407 p
= xdr_inline_decode(xdr
, 12);
5410 res
->seqid
= be32_to_cpup(p
++);
5411 res
->flags
= be32_to_cpup(p
++);
5413 /* We ask for SP4_NONE */
5414 dummy
= be32_to_cpup(p
);
5415 if (dummy
!= SP4_NONE
)
5418 /* server_owner4.so_minor_id */
5419 p
= xdr_inline_decode(xdr
, 8);
5422 p
= xdr_decode_hyper(p
, &res
->server_owner
->minor_id
);
5424 /* server_owner4.so_major_id */
5425 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
5426 if (unlikely(status
))
5428 if (unlikely(dummy
> NFS4_OPAQUE_LIMIT
))
5430 memcpy(res
->server_owner
->major_id
, dummy_str
, dummy
);
5431 res
->server_owner
->major_id_sz
= dummy
;
5434 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
5435 if (unlikely(status
))
5437 if (unlikely(dummy
> NFS4_OPAQUE_LIMIT
))
5439 memcpy(res
->server_scope
->server_scope
, dummy_str
, dummy
);
5440 res
->server_scope
->server_scope_sz
= dummy
;
5442 /* Implementation Id */
5443 p
= xdr_inline_decode(xdr
, 4);
5446 impl_id_count
= be32_to_cpup(p
++);
5448 if (impl_id_count
) {
5450 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
5451 if (unlikely(status
))
5453 if (unlikely(dummy
> NFS4_OPAQUE_LIMIT
))
5455 memcpy(res
->impl_id
->domain
, dummy_str
, dummy
);
5458 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
5459 if (unlikely(status
))
5461 if (unlikely(dummy
> NFS4_OPAQUE_LIMIT
))
5463 memcpy(res
->impl_id
->name
, dummy_str
, dummy
);
5466 p
= xdr_inline_decode(xdr
, 12);
5469 p
= xdr_decode_hyper(p
, &res
->impl_id
->date
.seconds
);
5470 res
->impl_id
->date
.nseconds
= be32_to_cpup(p
);
5472 /* if there's more than one entry, ignore the rest */
5476 print_overflow_msg(__func__
, xdr
);
5480 static int decode_chan_attrs(struct xdr_stream
*xdr
,
5481 struct nfs4_channel_attrs
*attrs
)
5486 p
= xdr_inline_decode(xdr
, 28);
5489 val
= be32_to_cpup(p
++); /* headerpadsz */
5491 return -EINVAL
; /* no support for header padding yet */
5492 attrs
->max_rqst_sz
= be32_to_cpup(p
++);
5493 attrs
->max_resp_sz
= be32_to_cpup(p
++);
5494 attrs
->max_resp_sz_cached
= be32_to_cpup(p
++);
5495 attrs
->max_ops
= be32_to_cpup(p
++);
5496 attrs
->max_reqs
= be32_to_cpup(p
++);
5497 nr_attrs
= be32_to_cpup(p
);
5498 if (unlikely(nr_attrs
> 1)) {
5499 printk(KERN_WARNING
"NFS: %s: Invalid rdma channel attrs "
5500 "count %u\n", __func__
, nr_attrs
);
5503 if (nr_attrs
== 1) {
5504 p
= xdr_inline_decode(xdr
, 4); /* skip rdma_attrs */
5510 print_overflow_msg(__func__
, xdr
);
5514 static int decode_sessionid(struct xdr_stream
*xdr
, struct nfs4_sessionid
*sid
)
5516 return decode_opaque_fixed(xdr
, sid
->data
, NFS4_MAX_SESSIONID_LEN
);
5519 static int decode_bind_conn_to_session(struct xdr_stream
*xdr
,
5520 struct nfs41_bind_conn_to_session_res
*res
)
5525 status
= decode_op_hdr(xdr
, OP_BIND_CONN_TO_SESSION
);
5527 status
= decode_sessionid(xdr
, &res
->session
->sess_id
);
5528 if (unlikely(status
))
5531 /* dir flags, rdma mode bool */
5532 p
= xdr_inline_decode(xdr
, 8);
5536 res
->dir
= be32_to_cpup(p
++);
5537 if (res
->dir
== 0 || res
->dir
> NFS4_CDFS4_BOTH
)
5539 if (be32_to_cpup(p
) == 0)
5540 res
->use_conn_in_rdma_mode
= false;
5542 res
->use_conn_in_rdma_mode
= true;
5546 print_overflow_msg(__func__
, xdr
);
5550 static int decode_create_session(struct xdr_stream
*xdr
,
5551 struct nfs41_create_session_res
*res
)
5555 struct nfs_client
*clp
= res
->client
;
5556 struct nfs4_session
*session
= clp
->cl_session
;
5558 status
= decode_op_hdr(xdr
, OP_CREATE_SESSION
);
5560 status
= decode_sessionid(xdr
, &session
->sess_id
);
5561 if (unlikely(status
))
5565 p
= xdr_inline_decode(xdr
, 8);
5568 clp
->cl_seqid
= be32_to_cpup(p
++);
5569 session
->flags
= be32_to_cpup(p
);
5571 /* Channel attributes */
5572 status
= decode_chan_attrs(xdr
, &session
->fc_attrs
);
5574 status
= decode_chan_attrs(xdr
, &session
->bc_attrs
);
5577 print_overflow_msg(__func__
, xdr
);
5581 static int decode_destroy_session(struct xdr_stream
*xdr
, void *dummy
)
5583 return decode_op_hdr(xdr
, OP_DESTROY_SESSION
);
5586 static int decode_destroy_clientid(struct xdr_stream
*xdr
, void *dummy
)
5588 return decode_op_hdr(xdr
, OP_DESTROY_CLIENTID
);
5591 static int decode_reclaim_complete(struct xdr_stream
*xdr
, void *dummy
)
5593 return decode_op_hdr(xdr
, OP_RECLAIM_COMPLETE
);
5595 #endif /* CONFIG_NFS_V4_1 */
5597 static int decode_sequence(struct xdr_stream
*xdr
,
5598 struct nfs4_sequence_res
*res
,
5599 struct rpc_rqst
*rqstp
)
5601 #if defined(CONFIG_NFS_V4_1)
5602 struct nfs4_session
*session
;
5603 struct nfs4_sessionid id
;
5608 if (res
->sr_slot
== NULL
)
5611 status
= decode_op_hdr(xdr
, OP_SEQUENCE
);
5613 status
= decode_sessionid(xdr
, &id
);
5614 if (unlikely(status
))
5618 * If the server returns different values for sessionID, slotID or
5619 * sequence number, the server is looney tunes.
5621 status
= -EREMOTEIO
;
5622 session
= res
->sr_slot
->table
->session
;
5624 if (memcmp(id
.data
, session
->sess_id
.data
,
5625 NFS4_MAX_SESSIONID_LEN
)) {
5626 dprintk("%s Invalid session id\n", __func__
);
5630 p
= xdr_inline_decode(xdr
, 20);
5635 dummy
= be32_to_cpup(p
++);
5636 if (dummy
!= res
->sr_slot
->seq_nr
) {
5637 dprintk("%s Invalid sequence number\n", __func__
);
5641 dummy
= be32_to_cpup(p
++);
5642 if (dummy
!= res
->sr_slot
->slot_nr
) {
5643 dprintk("%s Invalid slot id\n", __func__
);
5646 /* highest slot id */
5647 res
->sr_highest_slotid
= be32_to_cpup(p
++);
5648 /* target highest slot id */
5649 res
->sr_target_highest_slotid
= be32_to_cpup(p
++);
5651 res
->sr_status_flags
= be32_to_cpup(p
);
5654 res
->sr_status
= status
;
5657 print_overflow_msg(__func__
, xdr
);
5660 #else /* CONFIG_NFS_V4_1 */
5662 #endif /* CONFIG_NFS_V4_1 */
5665 #if defined(CONFIG_NFS_V4_1)
5667 * TODO: Need to handle case when EOF != true;
5669 static int decode_getdevicelist(struct xdr_stream
*xdr
,
5670 struct pnfs_devicelist
*res
)
5674 nfs4_verifier verftemp
;
5676 status
= decode_op_hdr(xdr
, OP_GETDEVICELIST
);
5680 p
= xdr_inline_decode(xdr
, 8 + 8 + 4);
5684 /* TODO: Skip cookie for now */
5688 p
= xdr_decode_opaque_fixed(p
, verftemp
.data
, NFS4_VERIFIER_SIZE
);
5690 res
->num_devs
= be32_to_cpup(p
);
5692 dprintk("%s: num_dev %d\n", __func__
, res
->num_devs
);
5694 if (res
->num_devs
> NFS4_PNFS_GETDEVLIST_MAXNUM
) {
5695 printk(KERN_ERR
"NFS: %s too many result dev_num %u\n",
5696 __func__
, res
->num_devs
);
5700 p
= xdr_inline_decode(xdr
,
5701 res
->num_devs
* NFS4_DEVICEID4_SIZE
+ 4);
5704 for (i
= 0; i
< res
->num_devs
; i
++)
5705 p
= xdr_decode_opaque_fixed(p
, res
->dev_id
[i
].data
,
5706 NFS4_DEVICEID4_SIZE
);
5707 res
->eof
= be32_to_cpup(p
);
5710 print_overflow_msg(__func__
, xdr
);
5714 static int decode_getdeviceinfo(struct xdr_stream
*xdr
,
5715 struct pnfs_device
*pdev
)
5721 status
= decode_op_hdr(xdr
, OP_GETDEVICEINFO
);
5723 if (status
== -ETOOSMALL
) {
5724 p
= xdr_inline_decode(xdr
, 4);
5727 pdev
->mincount
= be32_to_cpup(p
);
5728 dprintk("%s: Min count too small. mincnt = %u\n",
5729 __func__
, pdev
->mincount
);
5734 p
= xdr_inline_decode(xdr
, 8);
5737 type
= be32_to_cpup(p
++);
5738 if (type
!= pdev
->layout_type
) {
5739 dprintk("%s: layout mismatch req: %u pdev: %u\n",
5740 __func__
, pdev
->layout_type
, type
);
5744 * Get the length of the opaque device_addr4. xdr_read_pages places
5745 * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages)
5746 * and places the remaining xdr data in xdr_buf->tail
5748 pdev
->mincount
= be32_to_cpup(p
);
5749 if (xdr_read_pages(xdr
, pdev
->mincount
) != pdev
->mincount
)
5752 /* Parse notification bitmap, verifying that it is zero. */
5753 p
= xdr_inline_decode(xdr
, 4);
5756 len
= be32_to_cpup(p
);
5760 p
= xdr_inline_decode(xdr
, 4 * len
);
5763 for (i
= 0; i
< len
; i
++, p
++) {
5764 if (be32_to_cpup(p
)) {
5765 dprintk("%s: notifications not supported\n",
5773 print_overflow_msg(__func__
, xdr
);
5777 static int decode_layoutget(struct xdr_stream
*xdr
, struct rpc_rqst
*req
,
5778 struct nfs4_layoutget_res
*res
)
5785 status
= decode_op_hdr(xdr
, OP_LAYOUTGET
);
5788 p
= xdr_inline_decode(xdr
, 4);
5791 res
->return_on_close
= be32_to_cpup(p
);
5792 decode_stateid(xdr
, &res
->stateid
);
5793 p
= xdr_inline_decode(xdr
, 4);
5796 layout_count
= be32_to_cpup(p
);
5797 if (!layout_count
) {
5798 dprintk("%s: server responded with empty layout array\n",
5803 p
= xdr_inline_decode(xdr
, 28);
5806 p
= xdr_decode_hyper(p
, &res
->range
.offset
);
5807 p
= xdr_decode_hyper(p
, &res
->range
.length
);
5808 res
->range
.iomode
= be32_to_cpup(p
++);
5809 res
->type
= be32_to_cpup(p
++);
5810 res
->layoutp
->len
= be32_to_cpup(p
);
5812 dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n",
5814 (unsigned long)res
->range
.offset
,
5815 (unsigned long)res
->range
.length
,
5820 recvd
= xdr_read_pages(xdr
, res
->layoutp
->len
);
5821 if (res
->layoutp
->len
> recvd
) {
5822 dprintk("NFS: server cheating in layoutget reply: "
5823 "layout len %u > recvd %u\n",
5824 res
->layoutp
->len
, recvd
);
5828 if (layout_count
> 1) {
5829 /* We only handle a length one array at the moment. Any
5830 * further entries are just ignored. Note that this means
5831 * the client may see a response that is less than the
5832 * minimum it requested.
5834 dprintk("%s: server responded with %d layouts, dropping tail\n",
5835 __func__
, layout_count
);
5840 print_overflow_msg(__func__
, xdr
);
5844 static int decode_layoutreturn(struct xdr_stream
*xdr
,
5845 struct nfs4_layoutreturn_res
*res
)
5850 status
= decode_op_hdr(xdr
, OP_LAYOUTRETURN
);
5853 p
= xdr_inline_decode(xdr
, 4);
5856 res
->lrs_present
= be32_to_cpup(p
);
5857 if (res
->lrs_present
)
5858 status
= decode_stateid(xdr
, &res
->stateid
);
5861 print_overflow_msg(__func__
, xdr
);
5865 static int decode_layoutcommit(struct xdr_stream
*xdr
,
5866 struct rpc_rqst
*req
,
5867 struct nfs4_layoutcommit_res
*res
)
5873 status
= decode_op_hdr(xdr
, OP_LAYOUTCOMMIT
);
5874 res
->status
= status
;
5878 p
= xdr_inline_decode(xdr
, 4);
5881 sizechanged
= be32_to_cpup(p
);
5884 /* throw away new size */
5885 p
= xdr_inline_decode(xdr
, 8);
5891 print_overflow_msg(__func__
, xdr
);
5895 static int decode_test_stateid(struct xdr_stream
*xdr
,
5896 struct nfs41_test_stateid_res
*res
)
5902 status
= decode_op_hdr(xdr
, OP_TEST_STATEID
);
5906 p
= xdr_inline_decode(xdr
, 4);
5909 num_res
= be32_to_cpup(p
++);
5913 p
= xdr_inline_decode(xdr
, 4);
5916 res
->status
= be32_to_cpup(p
++);
5920 print_overflow_msg(__func__
, xdr
);
5925 static int decode_free_stateid(struct xdr_stream
*xdr
,
5926 struct nfs41_free_stateid_res
*res
)
5931 status
= decode_op_hdr(xdr
, OP_FREE_STATEID
);
5935 p
= xdr_inline_decode(xdr
, 4);
5938 res
->status
= be32_to_cpup(p
++);
5941 print_overflow_msg(__func__
, xdr
);
5944 #endif /* CONFIG_NFS_V4_1 */
5947 * END OF "GENERIC" DECODE ROUTINES.
5951 * Decode OPEN_DOWNGRADE response
5953 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst
*rqstp
,
5954 struct xdr_stream
*xdr
,
5955 struct nfs_closeres
*res
)
5957 struct compound_hdr hdr
;
5960 status
= decode_compound_hdr(xdr
, &hdr
);
5963 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
5966 status
= decode_putfh(xdr
);
5969 status
= decode_open_downgrade(xdr
, res
);
5972 decode_getfattr(xdr
, res
->fattr
, res
->server
);
5978 * Decode ACCESS response
5980 static int nfs4_xdr_dec_access(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
5981 struct nfs4_accessres
*res
)
5983 struct compound_hdr hdr
;
5986 status
= decode_compound_hdr(xdr
, &hdr
);
5989 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
5992 status
= decode_putfh(xdr
);
5995 status
= decode_access(xdr
, &res
->supported
, &res
->access
);
5998 decode_getfattr(xdr
, res
->fattr
, res
->server
);
6004 * Decode LOOKUP response
6006 static int nfs4_xdr_dec_lookup(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6007 struct nfs4_lookup_res
*res
)
6009 struct compound_hdr hdr
;
6012 status
= decode_compound_hdr(xdr
, &hdr
);
6015 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6018 status
= decode_putfh(xdr
);
6021 status
= decode_lookup(xdr
);
6024 status
= decode_getfh(xdr
, res
->fh
);
6027 status
= decode_getfattr_label(xdr
, res
->fattr
, res
->label
, res
->server
);
6033 * Decode LOOKUP_ROOT response
6035 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst
*rqstp
,
6036 struct xdr_stream
*xdr
,
6037 struct nfs4_lookup_res
*res
)
6039 struct compound_hdr hdr
;
6042 status
= decode_compound_hdr(xdr
, &hdr
);
6045 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6048 status
= decode_putrootfh(xdr
);
6051 status
= decode_getfh(xdr
, res
->fh
);
6053 status
= decode_getfattr_label(xdr
, res
->fattr
,
6054 res
->label
, res
->server
);
6060 * Decode REMOVE response
6062 static int nfs4_xdr_dec_remove(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6063 struct nfs_removeres
*res
)
6065 struct compound_hdr hdr
;
6068 status
= decode_compound_hdr(xdr
, &hdr
);
6071 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6074 status
= decode_putfh(xdr
);
6077 status
= decode_remove(xdr
, &res
->cinfo
);
6083 * Decode RENAME response
6085 static int nfs4_xdr_dec_rename(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6086 struct nfs_renameres
*res
)
6088 struct compound_hdr hdr
;
6091 status
= decode_compound_hdr(xdr
, &hdr
);
6094 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6097 status
= decode_putfh(xdr
);
6100 status
= decode_savefh(xdr
);
6103 status
= decode_putfh(xdr
);
6106 status
= decode_rename(xdr
, &res
->old_cinfo
, &res
->new_cinfo
);
6112 * Decode LINK response
6114 static int nfs4_xdr_dec_link(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6115 struct nfs4_link_res
*res
)
6117 struct compound_hdr hdr
;
6120 status
= decode_compound_hdr(xdr
, &hdr
);
6123 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6126 status
= decode_putfh(xdr
);
6129 status
= decode_savefh(xdr
);
6132 status
= decode_putfh(xdr
);
6135 status
= decode_link(xdr
, &res
->cinfo
);
6139 * Note order: OP_LINK leaves the directory as the current
6142 status
= decode_restorefh(xdr
);
6145 decode_getfattr_label(xdr
, res
->fattr
, res
->label
, res
->server
);
6151 * Decode CREATE response
6153 static int nfs4_xdr_dec_create(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6154 struct nfs4_create_res
*res
)
6156 struct compound_hdr hdr
;
6159 status
= decode_compound_hdr(xdr
, &hdr
);
6162 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6165 status
= decode_putfh(xdr
);
6168 status
= decode_create(xdr
, &res
->dir_cinfo
);
6171 status
= decode_getfh(xdr
, res
->fh
);
6174 decode_getfattr_label(xdr
, res
->fattr
, res
->label
, res
->server
);
6180 * Decode SYMLINK response
6182 static int nfs4_xdr_dec_symlink(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6183 struct nfs4_create_res
*res
)
6185 return nfs4_xdr_dec_create(rqstp
, xdr
, res
);
6189 * Decode GETATTR response
6191 static int nfs4_xdr_dec_getattr(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6192 struct nfs4_getattr_res
*res
)
6194 struct compound_hdr hdr
;
6197 status
= decode_compound_hdr(xdr
, &hdr
);
6200 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6203 status
= decode_putfh(xdr
);
6206 status
= decode_getfattr_label(xdr
, res
->fattr
, res
->label
, res
->server
);
6212 * Encode an SETACL request
6214 static void nfs4_xdr_enc_setacl(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
6215 struct nfs_setaclargs
*args
)
6217 struct compound_hdr hdr
= {
6218 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
6221 encode_compound_hdr(xdr
, req
, &hdr
);
6222 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
6223 encode_putfh(xdr
, args
->fh
, &hdr
);
6224 encode_setacl(xdr
, args
, &hdr
);
6229 * Decode SETACL response
6232 nfs4_xdr_dec_setacl(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6233 struct nfs_setaclres
*res
)
6235 struct compound_hdr hdr
;
6238 status
= decode_compound_hdr(xdr
, &hdr
);
6241 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6244 status
= decode_putfh(xdr
);
6247 status
= decode_setattr(xdr
);
6253 * Decode GETACL response
6256 nfs4_xdr_dec_getacl(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6257 struct nfs_getaclres
*res
)
6259 struct compound_hdr hdr
;
6262 if (res
->acl_scratch
!= NULL
) {
6263 void *p
= page_address(res
->acl_scratch
);
6264 xdr_set_scratch_buffer(xdr
, p
, PAGE_SIZE
);
6266 status
= decode_compound_hdr(xdr
, &hdr
);
6269 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6272 status
= decode_putfh(xdr
);
6275 status
= decode_getacl(xdr
, rqstp
, res
);
6282 * Decode CLOSE response
6284 static int nfs4_xdr_dec_close(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6285 struct nfs_closeres
*res
)
6287 struct compound_hdr hdr
;
6290 status
= decode_compound_hdr(xdr
, &hdr
);
6293 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6296 status
= decode_putfh(xdr
);
6299 status
= decode_close(xdr
, res
);
6303 * Note: Server may do delete on close for this file
6304 * in which case the getattr call will fail with
6305 * an ESTALE error. Shouldn't be a problem,
6306 * though, since fattr->valid will remain unset.
6308 decode_getfattr(xdr
, res
->fattr
, res
->server
);
6314 * Decode OPEN response
6316 static int nfs4_xdr_dec_open(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6317 struct nfs_openres
*res
)
6319 struct compound_hdr hdr
;
6322 status
= decode_compound_hdr(xdr
, &hdr
);
6325 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6328 status
= decode_putfh(xdr
);
6331 status
= decode_open(xdr
, res
);
6334 status
= decode_getfh(xdr
, &res
->fh
);
6337 if (res
->access_request
)
6338 decode_access(xdr
, &res
->access_supported
, &res
->access_result
);
6339 decode_getfattr_label(xdr
, res
->f_attr
, res
->f_label
, res
->server
);
6345 * Decode OPEN_CONFIRM response
6347 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst
*rqstp
,
6348 struct xdr_stream
*xdr
,
6349 struct nfs_open_confirmres
*res
)
6351 struct compound_hdr hdr
;
6354 status
= decode_compound_hdr(xdr
, &hdr
);
6357 status
= decode_putfh(xdr
);
6360 status
= decode_open_confirm(xdr
, res
);
6366 * Decode OPEN response
6368 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst
*rqstp
,
6369 struct xdr_stream
*xdr
,
6370 struct nfs_openres
*res
)
6372 struct compound_hdr hdr
;
6375 status
= decode_compound_hdr(xdr
, &hdr
);
6378 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6381 status
= decode_putfh(xdr
);
6384 status
= decode_open(xdr
, res
);
6387 if (res
->access_request
)
6388 decode_access(xdr
, &res
->access_supported
, &res
->access_result
);
6389 decode_getfattr(xdr
, res
->f_attr
, res
->server
);
6395 * Decode SETATTR response
6397 static int nfs4_xdr_dec_setattr(struct rpc_rqst
*rqstp
,
6398 struct xdr_stream
*xdr
,
6399 struct nfs_setattrres
*res
)
6401 struct compound_hdr hdr
;
6404 status
= decode_compound_hdr(xdr
, &hdr
);
6407 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6410 status
= decode_putfh(xdr
);
6413 status
= decode_setattr(xdr
);
6416 decode_getfattr_label(xdr
, res
->fattr
, res
->label
, res
->server
);
6422 * Decode LOCK response
6424 static int nfs4_xdr_dec_lock(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6425 struct nfs_lock_res
*res
)
6427 struct compound_hdr hdr
;
6430 status
= decode_compound_hdr(xdr
, &hdr
);
6433 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6436 status
= decode_putfh(xdr
);
6439 status
= decode_lock(xdr
, res
);
6445 * Decode LOCKT response
6447 static int nfs4_xdr_dec_lockt(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6448 struct nfs_lockt_res
*res
)
6450 struct compound_hdr hdr
;
6453 status
= decode_compound_hdr(xdr
, &hdr
);
6456 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6459 status
= decode_putfh(xdr
);
6462 status
= decode_lockt(xdr
, res
);
6468 * Decode LOCKU response
6470 static int nfs4_xdr_dec_locku(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6471 struct nfs_locku_res
*res
)
6473 struct compound_hdr hdr
;
6476 status
= decode_compound_hdr(xdr
, &hdr
);
6479 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6482 status
= decode_putfh(xdr
);
6485 status
= decode_locku(xdr
, res
);
6490 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst
*rqstp
,
6491 struct xdr_stream
*xdr
, void *dummy
)
6493 struct compound_hdr hdr
;
6496 status
= decode_compound_hdr(xdr
, &hdr
);
6498 status
= decode_release_lockowner(xdr
);
6503 * Decode READLINK response
6505 static int nfs4_xdr_dec_readlink(struct rpc_rqst
*rqstp
,
6506 struct xdr_stream
*xdr
,
6507 struct nfs4_readlink_res
*res
)
6509 struct compound_hdr hdr
;
6512 status
= decode_compound_hdr(xdr
, &hdr
);
6515 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6518 status
= decode_putfh(xdr
);
6521 status
= decode_readlink(xdr
, rqstp
);
6527 * Decode READDIR response
6529 static int nfs4_xdr_dec_readdir(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6530 struct nfs4_readdir_res
*res
)
6532 struct compound_hdr hdr
;
6535 status
= decode_compound_hdr(xdr
, &hdr
);
6538 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6541 status
= decode_putfh(xdr
);
6544 status
= decode_readdir(xdr
, rqstp
, res
);
6550 * Decode Read response
6552 static int nfs4_xdr_dec_read(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6553 struct nfs_readres
*res
)
6555 struct compound_hdr hdr
;
6558 status
= decode_compound_hdr(xdr
, &hdr
);
6561 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6564 status
= decode_putfh(xdr
);
6567 status
= decode_read(xdr
, rqstp
, res
);
6569 status
= res
->count
;
6575 * Decode WRITE response
6577 static int nfs4_xdr_dec_write(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6578 struct nfs_writeres
*res
)
6580 struct compound_hdr hdr
;
6583 status
= decode_compound_hdr(xdr
, &hdr
);
6586 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6589 status
= decode_putfh(xdr
);
6592 status
= decode_write(xdr
, res
);
6596 decode_getfattr(xdr
, res
->fattr
, res
->server
);
6598 status
= res
->count
;
6604 * Decode COMMIT response
6606 static int nfs4_xdr_dec_commit(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6607 struct nfs_commitres
*res
)
6609 struct compound_hdr hdr
;
6612 status
= decode_compound_hdr(xdr
, &hdr
);
6615 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6618 status
= decode_putfh(xdr
);
6621 status
= decode_commit(xdr
, res
);
6627 * Decode FSINFO response
6629 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
6630 struct nfs4_fsinfo_res
*res
)
6632 struct compound_hdr hdr
;
6635 status
= decode_compound_hdr(xdr
, &hdr
);
6637 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
6639 status
= decode_putfh(xdr
);
6641 status
= decode_fsinfo(xdr
, res
->fsinfo
);
6646 * Decode PATHCONF response
6648 static int nfs4_xdr_dec_pathconf(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
6649 struct nfs4_pathconf_res
*res
)
6651 struct compound_hdr hdr
;
6654 status
= decode_compound_hdr(xdr
, &hdr
);
6656 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
6658 status
= decode_putfh(xdr
);
6660 status
= decode_pathconf(xdr
, res
->pathconf
);
6665 * Decode STATFS response
6667 static int nfs4_xdr_dec_statfs(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
6668 struct nfs4_statfs_res
*res
)
6670 struct compound_hdr hdr
;
6673 status
= decode_compound_hdr(xdr
, &hdr
);
6675 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
6677 status
= decode_putfh(xdr
);
6679 status
= decode_statfs(xdr
, res
->fsstat
);
6684 * Decode GETATTR_BITMAP response
6686 static int nfs4_xdr_dec_server_caps(struct rpc_rqst
*req
,
6687 struct xdr_stream
*xdr
,
6688 struct nfs4_server_caps_res
*res
)
6690 struct compound_hdr hdr
;
6693 status
= decode_compound_hdr(xdr
, &hdr
);
6696 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
6699 status
= decode_putfh(xdr
);
6702 status
= decode_server_caps(xdr
, res
);
6708 * Decode RENEW response
6710 static int nfs4_xdr_dec_renew(struct rpc_rqst
*rqstp
, struct xdr_stream
*xdr
,
6713 struct compound_hdr hdr
;
6716 status
= decode_compound_hdr(xdr
, &hdr
);
6718 status
= decode_renew(xdr
);
6723 * Decode SETCLIENTID response
6725 static int nfs4_xdr_dec_setclientid(struct rpc_rqst
*req
,
6726 struct xdr_stream
*xdr
,
6727 struct nfs4_setclientid_res
*res
)
6729 struct compound_hdr hdr
;
6732 status
= decode_compound_hdr(xdr
, &hdr
);
6734 status
= decode_setclientid(xdr
, res
);
6739 * Decode SETCLIENTID_CONFIRM response
6741 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst
*req
,
6742 struct xdr_stream
*xdr
)
6744 struct compound_hdr hdr
;
6747 status
= decode_compound_hdr(xdr
, &hdr
);
6749 status
= decode_setclientid_confirm(xdr
);
6754 * Decode DELEGRETURN response
6756 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst
*rqstp
,
6757 struct xdr_stream
*xdr
,
6758 struct nfs4_delegreturnres
*res
)
6760 struct compound_hdr hdr
;
6763 status
= decode_compound_hdr(xdr
, &hdr
);
6766 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6769 status
= decode_putfh(xdr
);
6772 status
= decode_getfattr(xdr
, res
->fattr
, res
->server
);
6775 status
= decode_delegreturn(xdr
);
6781 * Decode FS_LOCATIONS response
6783 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst
*req
,
6784 struct xdr_stream
*xdr
,
6785 struct nfs4_fs_locations_res
*res
)
6787 struct compound_hdr hdr
;
6790 status
= decode_compound_hdr(xdr
, &hdr
);
6793 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
6796 status
= decode_putfh(xdr
);
6799 status
= decode_lookup(xdr
);
6802 xdr_enter_page(xdr
, PAGE_SIZE
);
6803 status
= decode_getfattr_generic(xdr
, &res
->fs_locations
->fattr
,
6804 NULL
, res
->fs_locations
,
6805 NULL
, res
->fs_locations
->server
);
6811 * Decode SECINFO response
6813 static int nfs4_xdr_dec_secinfo(struct rpc_rqst
*rqstp
,
6814 struct xdr_stream
*xdr
,
6815 struct nfs4_secinfo_res
*res
)
6817 struct compound_hdr hdr
;
6820 status
= decode_compound_hdr(xdr
, &hdr
);
6823 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6826 status
= decode_putfh(xdr
);
6829 status
= decode_secinfo(xdr
, res
);
6834 #if defined(CONFIG_NFS_V4_1)
6836 * Decode BIND_CONN_TO_SESSION response
6838 static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst
*rqstp
,
6839 struct xdr_stream
*xdr
,
6842 struct compound_hdr hdr
;
6845 status
= decode_compound_hdr(xdr
, &hdr
);
6847 status
= decode_bind_conn_to_session(xdr
, res
);
6852 * Decode EXCHANGE_ID response
6854 static int nfs4_xdr_dec_exchange_id(struct rpc_rqst
*rqstp
,
6855 struct xdr_stream
*xdr
,
6858 struct compound_hdr hdr
;
6861 status
= decode_compound_hdr(xdr
, &hdr
);
6863 status
= decode_exchange_id(xdr
, res
);
6868 * Decode CREATE_SESSION response
6870 static int nfs4_xdr_dec_create_session(struct rpc_rqst
*rqstp
,
6871 struct xdr_stream
*xdr
,
6872 struct nfs41_create_session_res
*res
)
6874 struct compound_hdr hdr
;
6877 status
= decode_compound_hdr(xdr
, &hdr
);
6879 status
= decode_create_session(xdr
, res
);
6884 * Decode DESTROY_SESSION response
6886 static int nfs4_xdr_dec_destroy_session(struct rpc_rqst
*rqstp
,
6887 struct xdr_stream
*xdr
,
6890 struct compound_hdr hdr
;
6893 status
= decode_compound_hdr(xdr
, &hdr
);
6895 status
= decode_destroy_session(xdr
, res
);
6900 * Decode DESTROY_CLIENTID response
6902 static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst
*rqstp
,
6903 struct xdr_stream
*xdr
,
6906 struct compound_hdr hdr
;
6909 status
= decode_compound_hdr(xdr
, &hdr
);
6911 status
= decode_destroy_clientid(xdr
, res
);
6916 * Decode SEQUENCE response
6918 static int nfs4_xdr_dec_sequence(struct rpc_rqst
*rqstp
,
6919 struct xdr_stream
*xdr
,
6920 struct nfs4_sequence_res
*res
)
6922 struct compound_hdr hdr
;
6925 status
= decode_compound_hdr(xdr
, &hdr
);
6927 status
= decode_sequence(xdr
, res
, rqstp
);
6932 * Decode GET_LEASE_TIME response
6934 static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst
*rqstp
,
6935 struct xdr_stream
*xdr
,
6936 struct nfs4_get_lease_time_res
*res
)
6938 struct compound_hdr hdr
;
6941 status
= decode_compound_hdr(xdr
, &hdr
);
6943 status
= decode_sequence(xdr
, &res
->lr_seq_res
, rqstp
);
6945 status
= decode_putrootfh(xdr
);
6947 status
= decode_fsinfo(xdr
, res
->lr_fsinfo
);
6952 * Decode RECLAIM_COMPLETE response
6954 static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst
*rqstp
,
6955 struct xdr_stream
*xdr
,
6956 struct nfs41_reclaim_complete_res
*res
)
6958 struct compound_hdr hdr
;
6961 status
= decode_compound_hdr(xdr
, &hdr
);
6963 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6965 status
= decode_reclaim_complete(xdr
, (void *)NULL
);
6970 * Decode GETDEVICELIST response
6972 static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst
*rqstp
,
6973 struct xdr_stream
*xdr
,
6974 struct nfs4_getdevicelist_res
*res
)
6976 struct compound_hdr hdr
;
6979 dprintk("encoding getdevicelist!\n");
6981 status
= decode_compound_hdr(xdr
, &hdr
);
6984 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
6987 status
= decode_putfh(xdr
);
6990 status
= decode_getdevicelist(xdr
, res
->devlist
);
6996 * Decode GETDEVINFO response
6998 static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst
*rqstp
,
6999 struct xdr_stream
*xdr
,
7000 struct nfs4_getdeviceinfo_res
*res
)
7002 struct compound_hdr hdr
;
7005 status
= decode_compound_hdr(xdr
, &hdr
);
7008 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7011 status
= decode_getdeviceinfo(xdr
, res
->pdev
);
7017 * Decode LAYOUTGET response
7019 static int nfs4_xdr_dec_layoutget(struct rpc_rqst
*rqstp
,
7020 struct xdr_stream
*xdr
,
7021 struct nfs4_layoutget_res
*res
)
7023 struct compound_hdr hdr
;
7026 status
= decode_compound_hdr(xdr
, &hdr
);
7029 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7032 status
= decode_putfh(xdr
);
7035 status
= decode_layoutget(xdr
, rqstp
, res
);
7041 * Decode LAYOUTRETURN response
7043 static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst
*rqstp
,
7044 struct xdr_stream
*xdr
,
7045 struct nfs4_layoutreturn_res
*res
)
7047 struct compound_hdr hdr
;
7050 status
= decode_compound_hdr(xdr
, &hdr
);
7053 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7056 status
= decode_putfh(xdr
);
7059 status
= decode_layoutreturn(xdr
, res
);
7065 * Decode LAYOUTCOMMIT response
7067 static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst
*rqstp
,
7068 struct xdr_stream
*xdr
,
7069 struct nfs4_layoutcommit_res
*res
)
7071 struct compound_hdr hdr
;
7074 status
= decode_compound_hdr(xdr
, &hdr
);
7077 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7080 status
= decode_putfh(xdr
);
7083 status
= decode_layoutcommit(xdr
, rqstp
, res
);
7086 decode_getfattr(xdr
, res
->fattr
, res
->server
);
7092 * Decode SECINFO_NO_NAME response
7094 static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst
*rqstp
,
7095 struct xdr_stream
*xdr
,
7096 struct nfs4_secinfo_res
*res
)
7098 struct compound_hdr hdr
;
7101 status
= decode_compound_hdr(xdr
, &hdr
);
7104 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7107 status
= decode_putrootfh(xdr
);
7110 status
= decode_secinfo_no_name(xdr
, res
);
7116 * Decode TEST_STATEID response
7118 static int nfs4_xdr_dec_test_stateid(struct rpc_rqst
*rqstp
,
7119 struct xdr_stream
*xdr
,
7120 struct nfs41_test_stateid_res
*res
)
7122 struct compound_hdr hdr
;
7125 status
= decode_compound_hdr(xdr
, &hdr
);
7128 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7131 status
= decode_test_stateid(xdr
, res
);
7137 * Decode FREE_STATEID response
7139 static int nfs4_xdr_dec_free_stateid(struct rpc_rqst
*rqstp
,
7140 struct xdr_stream
*xdr
,
7141 struct nfs41_free_stateid_res
*res
)
7143 struct compound_hdr hdr
;
7146 status
= decode_compound_hdr(xdr
, &hdr
);
7149 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
7152 status
= decode_free_stateid(xdr
, res
);
7156 #endif /* CONFIG_NFS_V4_1 */
7159 * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in
7160 * the local page cache.
7161 * @xdr: XDR stream where entry resides
7162 * @entry: buffer to fill in with entry data
7163 * @plus: boolean indicating whether this should be a readdirplus entry
7165 * Returns zero if successful, otherwise a negative errno value is
7168 * This function is not invoked during READDIR reply decoding, but
7169 * rather whenever an application invokes the getdents(2) system call
7170 * on a directory already in our cache.
7172 int nfs4_decode_dirent(struct xdr_stream
*xdr
, struct nfs_entry
*entry
,
7176 uint32_t bitmap
[3] = {0};
7178 __be32
*p
= xdr_inline_decode(xdr
, 4);
7181 if (*p
== xdr_zero
) {
7182 p
= xdr_inline_decode(xdr
, 4);
7191 p
= xdr_inline_decode(xdr
, 12);
7194 entry
->prev_cookie
= entry
->cookie
;
7195 p
= xdr_decode_hyper(p
, &entry
->cookie
);
7196 entry
->len
= be32_to_cpup(p
);
7198 p
= xdr_inline_decode(xdr
, entry
->len
);
7201 entry
->name
= (const char *) p
;
7204 * In case the server doesn't return an inode number,
7205 * we fake one here. (We don't use inode number 0,
7206 * since glibc seems to choke on it...)
7209 entry
->fattr
->valid
= 0;
7211 if (decode_attr_bitmap(xdr
, bitmap
) < 0)
7214 if (decode_attr_length(xdr
, &len
, &savep
) < 0)
7217 if (decode_getfattr_attrs(xdr
, bitmap
, entry
->fattr
, entry
->fh
,
7218 NULL
, entry
->label
, entry
->server
) < 0)
7220 if (entry
->fattr
->valid
& NFS_ATTR_FATTR_MOUNTED_ON_FILEID
)
7221 entry
->ino
= entry
->fattr
->mounted_on_fileid
;
7222 else if (entry
->fattr
->valid
& NFS_ATTR_FATTR_FILEID
)
7223 entry
->ino
= entry
->fattr
->fileid
;
7225 entry
->d_type
= DT_UNKNOWN
;
7226 if (entry
->fattr
->valid
& NFS_ATTR_FATTR_TYPE
)
7227 entry
->d_type
= nfs_umode_to_dtype(entry
->fattr
->mode
);
7232 print_overflow_msg(__func__
, xdr
);
7237 * We need to translate between nfs status return values and
7238 * the local errno values which may not be the same.
7245 { NFS4ERR_PERM
, -EPERM
},
7246 { NFS4ERR_NOENT
, -ENOENT
},
7247 { NFS4ERR_IO
, -errno_NFSERR_IO
},
7248 { NFS4ERR_NXIO
, -ENXIO
},
7249 { NFS4ERR_ACCESS
, -EACCES
},
7250 { NFS4ERR_EXIST
, -EEXIST
},
7251 { NFS4ERR_XDEV
, -EXDEV
},
7252 { NFS4ERR_NOTDIR
, -ENOTDIR
},
7253 { NFS4ERR_ISDIR
, -EISDIR
},
7254 { NFS4ERR_INVAL
, -EINVAL
},
7255 { NFS4ERR_FBIG
, -EFBIG
},
7256 { NFS4ERR_NOSPC
, -ENOSPC
},
7257 { NFS4ERR_ROFS
, -EROFS
},
7258 { NFS4ERR_MLINK
, -EMLINK
},
7259 { NFS4ERR_NAMETOOLONG
, -ENAMETOOLONG
},
7260 { NFS4ERR_NOTEMPTY
, -ENOTEMPTY
},
7261 { NFS4ERR_DQUOT
, -EDQUOT
},
7262 { NFS4ERR_STALE
, -ESTALE
},
7263 { NFS4ERR_BADHANDLE
, -EBADHANDLE
},
7264 { NFS4ERR_BAD_COOKIE
, -EBADCOOKIE
},
7265 { NFS4ERR_NOTSUPP
, -ENOTSUPP
},
7266 { NFS4ERR_TOOSMALL
, -ETOOSMALL
},
7267 { NFS4ERR_SERVERFAULT
, -EREMOTEIO
},
7268 { NFS4ERR_BADTYPE
, -EBADTYPE
},
7269 { NFS4ERR_LOCKED
, -EAGAIN
},
7270 { NFS4ERR_SYMLINK
, -ELOOP
},
7271 { NFS4ERR_OP_ILLEGAL
, -EOPNOTSUPP
},
7272 { NFS4ERR_DEADLOCK
, -EDEADLK
},
7277 * Convert an NFS error code to a local one.
7278 * This one is used jointly by NFSv2 and NFSv3.
7281 nfs4_stat_to_errno(int stat
)
7284 for (i
= 0; nfs_errtbl
[i
].stat
!= -1; i
++) {
7285 if (nfs_errtbl
[i
].stat
== stat
)
7286 return nfs_errtbl
[i
].errno
;
7288 if (stat
<= 10000 || stat
> 10100) {
7289 /* The server is looney tunes. */
7292 /* If we cannot translate the error, the recovery routines should
7294 * Note: remaining NFSv4 error codes have values > 10000, so should
7295 * not conflict with native Linux error codes.
7300 #define PROC(proc, argtype, restype) \
7301 [NFSPROC4_CLNT_##proc] = { \
7302 .p_proc = NFSPROC4_COMPOUND, \
7303 .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \
7304 .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \
7305 .p_arglen = NFS4_##argtype##_sz, \
7306 .p_replen = NFS4_##restype##_sz, \
7307 .p_statidx = NFSPROC4_CLNT_##proc, \
7311 struct rpc_procinfo nfs4_procedures
[] = {
7312 PROC(READ
, enc_read
, dec_read
),
7313 PROC(WRITE
, enc_write
, dec_write
),
7314 PROC(COMMIT
, enc_commit
, dec_commit
),
7315 PROC(OPEN
, enc_open
, dec_open
),
7316 PROC(OPEN_CONFIRM
, enc_open_confirm
, dec_open_confirm
),
7317 PROC(OPEN_NOATTR
, enc_open_noattr
, dec_open_noattr
),
7318 PROC(OPEN_DOWNGRADE
, enc_open_downgrade
, dec_open_downgrade
),
7319 PROC(CLOSE
, enc_close
, dec_close
),
7320 PROC(SETATTR
, enc_setattr
, dec_setattr
),
7321 PROC(FSINFO
, enc_fsinfo
, dec_fsinfo
),
7322 PROC(RENEW
, enc_renew
, dec_renew
),
7323 PROC(SETCLIENTID
, enc_setclientid
, dec_setclientid
),
7324 PROC(SETCLIENTID_CONFIRM
, enc_setclientid_confirm
, dec_setclientid_confirm
),
7325 PROC(LOCK
, enc_lock
, dec_lock
),
7326 PROC(LOCKT
, enc_lockt
, dec_lockt
),
7327 PROC(LOCKU
, enc_locku
, dec_locku
),
7328 PROC(ACCESS
, enc_access
, dec_access
),
7329 PROC(GETATTR
, enc_getattr
, dec_getattr
),
7330 PROC(LOOKUP
, enc_lookup
, dec_lookup
),
7331 PROC(LOOKUP_ROOT
, enc_lookup_root
, dec_lookup_root
),
7332 PROC(REMOVE
, enc_remove
, dec_remove
),
7333 PROC(RENAME
, enc_rename
, dec_rename
),
7334 PROC(LINK
, enc_link
, dec_link
),
7335 PROC(SYMLINK
, enc_symlink
, dec_symlink
),
7336 PROC(CREATE
, enc_create
, dec_create
),
7337 PROC(PATHCONF
, enc_pathconf
, dec_pathconf
),
7338 PROC(STATFS
, enc_statfs
, dec_statfs
),
7339 PROC(READLINK
, enc_readlink
, dec_readlink
),
7340 PROC(READDIR
, enc_readdir
, dec_readdir
),
7341 PROC(SERVER_CAPS
, enc_server_caps
, dec_server_caps
),
7342 PROC(DELEGRETURN
, enc_delegreturn
, dec_delegreturn
),
7343 PROC(GETACL
, enc_getacl
, dec_getacl
),
7344 PROC(SETACL
, enc_setacl
, dec_setacl
),
7345 PROC(FS_LOCATIONS
, enc_fs_locations
, dec_fs_locations
),
7346 PROC(RELEASE_LOCKOWNER
, enc_release_lockowner
, dec_release_lockowner
),
7347 PROC(SECINFO
, enc_secinfo
, dec_secinfo
),
7348 #if defined(CONFIG_NFS_V4_1)
7349 PROC(EXCHANGE_ID
, enc_exchange_id
, dec_exchange_id
),
7350 PROC(CREATE_SESSION
, enc_create_session
, dec_create_session
),
7351 PROC(DESTROY_SESSION
, enc_destroy_session
, dec_destroy_session
),
7352 PROC(SEQUENCE
, enc_sequence
, dec_sequence
),
7353 PROC(GET_LEASE_TIME
, enc_get_lease_time
, dec_get_lease_time
),
7354 PROC(RECLAIM_COMPLETE
, enc_reclaim_complete
, dec_reclaim_complete
),
7355 PROC(GETDEVICEINFO
, enc_getdeviceinfo
, dec_getdeviceinfo
),
7356 PROC(LAYOUTGET
, enc_layoutget
, dec_layoutget
),
7357 PROC(LAYOUTCOMMIT
, enc_layoutcommit
, dec_layoutcommit
),
7358 PROC(LAYOUTRETURN
, enc_layoutreturn
, dec_layoutreturn
),
7359 PROC(SECINFO_NO_NAME
, enc_secinfo_no_name
, dec_secinfo_no_name
),
7360 PROC(TEST_STATEID
, enc_test_stateid
, dec_test_stateid
),
7361 PROC(FREE_STATEID
, enc_free_stateid
, dec_free_stateid
),
7362 PROC(GETDEVICELIST
, enc_getdevicelist
, dec_getdevicelist
),
7363 PROC(BIND_CONN_TO_SESSION
,
7364 enc_bind_conn_to_session
, dec_bind_conn_to_session
),
7365 PROC(DESTROY_CLIENTID
, enc_destroy_clientid
, dec_destroy_clientid
),
7366 #endif /* CONFIG_NFS_V4_1 */
7369 const struct rpc_version nfs_version4
= {
7371 .nrprocs
= ARRAY_SIZE(nfs4_procedures
),
7372 .procs
= nfs4_procedures