1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
5 #ifndef __LINUX_FS_NFS_NFS4_2XDR_H
6 #define __LINUX_FS_NFS_NFS4_2XDR_H
10 /* Not limited by NFS itself, limited by the generic xattr code */
11 #define nfs4_xattr_name_maxsz XDR_QUADLEN(XATTR_NAME_MAX)
13 #define encode_fallocate_maxsz (encode_stateid_maxsz + \
16 #define NFS42_WRITE_RES_SIZE (1 /* wr_callback_id size */ +\
17 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
19 1 /* wr_committed */ + \
20 XDR_QUADLEN(NFS4_VERIFIER_SIZE))
21 #define encode_allocate_maxsz (op_encode_hdr_maxsz + \
22 encode_fallocate_maxsz)
23 #define decode_allocate_maxsz (op_decode_hdr_maxsz)
24 #define encode_copy_maxsz (op_encode_hdr_maxsz + \
25 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
26 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
27 2 + 2 + 2 + 1 + 1 + 1 +\
28 1 + /* One cnr_source_server */\
30 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
31 #define decode_copy_maxsz (op_decode_hdr_maxsz + \
32 NFS42_WRITE_RES_SIZE + \
33 1 /* cr_consecutive */ + \
34 1 /* cr_synchronous */)
35 #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
36 XDR_QUADLEN(NFS4_STATEID_SIZE))
37 #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
38 #define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \
39 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
41 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
42 #define decode_copy_notify_maxsz (op_decode_hdr_maxsz + \
43 3 + /* cnr_lease_time */\
44 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
45 1 + /* Support 1 cnr_source_server */\
47 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
48 #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
49 encode_fallocate_maxsz)
50 #define decode_deallocate_maxsz (op_decode_hdr_maxsz)
51 #define encode_read_plus_maxsz (op_encode_hdr_maxsz + \
52 encode_stateid_maxsz + 3)
53 #define NFS42_READ_PLUS_DATA_SEGMENT_SIZE \
54 (1 /* data_content4 */ + \
55 2 /* data_info4.di_offset */ + \
56 1 /* data_info4.di_length */)
57 #define NFS42_READ_PLUS_HOLE_SEGMENT_SIZE \
58 (1 /* data_content4 */ + \
59 2 /* data_info4.di_offset */ + \
60 2 /* data_info4.di_length */)
61 #define READ_PLUS_SEGMENT_SIZE_DIFF (NFS42_READ_PLUS_HOLE_SEGMENT_SIZE - \
62 NFS42_READ_PLUS_DATA_SEGMENT_SIZE)
63 #define decode_read_plus_maxsz (op_decode_hdr_maxsz + \
65 1 /* rpr_contents count */ + \
66 NFS42_READ_PLUS_HOLE_SEGMENT_SIZE)
67 #define encode_seek_maxsz (op_encode_hdr_maxsz + \
68 encode_stateid_maxsz + \
71 #define decode_seek_maxsz (op_decode_hdr_maxsz + \
76 #define encode_io_info_maxsz 4
77 #define encode_layoutstats_maxsz (op_decode_hdr_maxsz + \
80 encode_stateid_maxsz + \
81 encode_io_info_maxsz + \
82 encode_io_info_maxsz + \
83 1 /* opaque devaddr4 length */ + \
84 XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
85 #define decode_layoutstats_maxsz (op_decode_hdr_maxsz)
86 #define encode_device_error_maxsz (XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
87 1 /* status */ + 1 /* opnum */)
88 #define encode_layouterror_maxsz (op_decode_hdr_maxsz + \
91 encode_stateid_maxsz + \
92 1 /* Array size */ + \
93 encode_device_error_maxsz)
94 #define decode_layouterror_maxsz (op_decode_hdr_maxsz)
95 #define encode_clone_maxsz (encode_stateid_maxsz + \
96 encode_stateid_maxsz + \
97 2 /* src offset */ + \
98 2 /* dst offset */ + \
100 #define decode_clone_maxsz (op_decode_hdr_maxsz)
101 #define encode_getxattr_maxsz (op_encode_hdr_maxsz + 1 + \
102 nfs4_xattr_name_maxsz)
103 #define decode_getxattr_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz)
104 #define encode_setxattr_maxsz (op_encode_hdr_maxsz + \
105 1 + nfs4_xattr_name_maxsz + 1)
106 #define decode_setxattr_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
107 #define encode_listxattrs_maxsz (op_encode_hdr_maxsz + 2 + 1)
108 #define decode_listxattrs_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + 1)
109 #define encode_removexattr_maxsz (op_encode_hdr_maxsz + 1 + \
110 nfs4_xattr_name_maxsz)
111 #define decode_removexattr_maxsz (op_decode_hdr_maxsz + \
112 decode_change_info_maxsz)
114 #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
115 encode_sequence_maxsz + \
116 encode_putfh_maxsz + \
117 encode_allocate_maxsz + \
118 encode_getattr_maxsz)
119 #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
120 decode_sequence_maxsz + \
121 decode_putfh_maxsz + \
122 decode_allocate_maxsz + \
123 decode_getattr_maxsz)
124 #define NFS4_enc_copy_sz (compound_encode_hdr_maxsz + \
125 encode_sequence_maxsz + \
126 encode_putfh_maxsz + \
127 encode_savefh_maxsz + \
128 encode_putfh_maxsz + \
129 encode_copy_maxsz + \
131 #define NFS4_dec_copy_sz (compound_decode_hdr_maxsz + \
132 decode_sequence_maxsz + \
133 decode_putfh_maxsz + \
134 decode_savefh_maxsz + \
135 decode_putfh_maxsz + \
136 decode_copy_maxsz + \
138 #define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \
139 encode_sequence_maxsz + \
140 encode_putfh_maxsz + \
141 encode_offload_cancel_maxsz)
142 #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \
143 decode_sequence_maxsz + \
144 decode_putfh_maxsz + \
145 decode_offload_cancel_maxsz)
146 #define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \
147 encode_putfh_maxsz + \
148 encode_copy_notify_maxsz)
149 #define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \
150 decode_putfh_maxsz + \
151 decode_copy_notify_maxsz)
152 #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
153 encode_sequence_maxsz + \
154 encode_putfh_maxsz + \
155 encode_deallocate_maxsz + \
156 encode_getattr_maxsz)
157 #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
158 decode_sequence_maxsz + \
159 decode_putfh_maxsz + \
160 decode_deallocate_maxsz + \
161 decode_getattr_maxsz)
162 #define NFS4_enc_read_plus_sz (compound_encode_hdr_maxsz + \
163 encode_sequence_maxsz + \
164 encode_putfh_maxsz + \
165 encode_read_plus_maxsz)
166 #define NFS4_dec_read_plus_sz (compound_decode_hdr_maxsz + \
167 decode_sequence_maxsz + \
168 decode_putfh_maxsz + \
169 decode_read_plus_maxsz)
170 #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
171 encode_sequence_maxsz + \
172 encode_putfh_maxsz + \
174 #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
175 decode_sequence_maxsz + \
176 decode_putfh_maxsz + \
178 #define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \
179 encode_sequence_maxsz + \
180 encode_putfh_maxsz + \
181 PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz)
182 #define NFS4_dec_layoutstats_sz (compound_decode_hdr_maxsz + \
183 decode_sequence_maxsz + \
184 decode_putfh_maxsz + \
185 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
186 #define NFS4_enc_layouterror_sz (compound_encode_hdr_maxsz + \
187 encode_sequence_maxsz + \
188 encode_putfh_maxsz + \
189 NFS42_LAYOUTERROR_MAX * \
190 encode_layouterror_maxsz)
191 #define NFS4_dec_layouterror_sz (compound_decode_hdr_maxsz + \
192 decode_sequence_maxsz + \
193 decode_putfh_maxsz + \
194 NFS42_LAYOUTERROR_MAX * \
195 decode_layouterror_maxsz)
196 #define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \
197 encode_sequence_maxsz + \
198 encode_putfh_maxsz + \
199 encode_savefh_maxsz + \
200 encode_putfh_maxsz + \
201 encode_clone_maxsz + \
202 encode_getattr_maxsz)
203 #define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \
204 decode_sequence_maxsz + \
205 decode_putfh_maxsz + \
206 decode_savefh_maxsz + \
207 decode_putfh_maxsz + \
208 decode_clone_maxsz + \
209 decode_getattr_maxsz)
210 #define NFS4_enc_getxattr_sz (compound_encode_hdr_maxsz + \
211 encode_sequence_maxsz + \
212 encode_putfh_maxsz + \
213 encode_getxattr_maxsz)
214 #define NFS4_dec_getxattr_sz (compound_decode_hdr_maxsz + \
215 decode_sequence_maxsz + \
216 decode_putfh_maxsz + \
217 decode_getxattr_maxsz)
218 #define NFS4_enc_setxattr_sz (compound_encode_hdr_maxsz + \
219 encode_sequence_maxsz + \
220 encode_putfh_maxsz + \
221 encode_setxattr_maxsz + \
222 encode_getattr_maxsz)
223 #define NFS4_dec_setxattr_sz (compound_decode_hdr_maxsz + \
224 decode_sequence_maxsz + \
225 decode_putfh_maxsz + \
226 decode_setxattr_maxsz + \
227 decode_getattr_maxsz)
228 #define NFS4_enc_listxattrs_sz (compound_encode_hdr_maxsz + \
229 encode_sequence_maxsz + \
230 encode_putfh_maxsz + \
231 encode_listxattrs_maxsz)
232 #define NFS4_dec_listxattrs_sz (compound_decode_hdr_maxsz + \
233 decode_sequence_maxsz + \
234 decode_putfh_maxsz + \
235 decode_listxattrs_maxsz)
236 #define NFS4_enc_removexattr_sz (compound_encode_hdr_maxsz + \
237 encode_sequence_maxsz + \
238 encode_putfh_maxsz + \
239 encode_removexattr_maxsz)
240 #define NFS4_dec_removexattr_sz (compound_decode_hdr_maxsz + \
241 decode_sequence_maxsz + \
242 decode_putfh_maxsz + \
243 decode_removexattr_maxsz)
246 * These values specify the maximum amount of data that is not
247 * associated with the extended attribute name or extended
248 * attribute list in the SETXATTR, GETXATTR and LISTXATTR
251 const u32 nfs42_maxsetxattr_overhead
= ((RPC_MAX_HEADER_WITH_AUTH
+
252 compound_encode_hdr_maxsz
+
253 encode_sequence_maxsz
+
254 encode_putfh_maxsz
+ 1 +
255 nfs4_xattr_name_maxsz
)
258 const u32 nfs42_maxgetxattr_overhead
= ((RPC_MAX_HEADER_WITH_AUTH
+
259 compound_decode_hdr_maxsz
+
260 decode_sequence_maxsz
+
261 decode_putfh_maxsz
+ 1) * XDR_UNIT
);
263 const u32 nfs42_maxlistxattrs_overhead
= ((RPC_MAX_HEADER_WITH_AUTH
+
264 compound_decode_hdr_maxsz
+
265 decode_sequence_maxsz
+
266 decode_putfh_maxsz
+ 3) * XDR_UNIT
);
268 static void encode_fallocate(struct xdr_stream
*xdr
,
269 const struct nfs42_falloc_args
*args
)
271 encode_nfs4_stateid(xdr
, &args
->falloc_stateid
);
272 encode_uint64(xdr
, args
->falloc_offset
);
273 encode_uint64(xdr
, args
->falloc_length
);
276 static void encode_allocate(struct xdr_stream
*xdr
,
277 const struct nfs42_falloc_args
*args
,
278 struct compound_hdr
*hdr
)
280 encode_op_hdr(xdr
, OP_ALLOCATE
, decode_allocate_maxsz
, hdr
);
281 encode_fallocate(xdr
, args
);
284 static void encode_nl4_server(struct xdr_stream
*xdr
,
285 const struct nl4_server
*ns
)
287 encode_uint32(xdr
, ns
->nl4_type
);
288 switch (ns
->nl4_type
) {
291 encode_string(xdr
, ns
->u
.nl4_str_sz
, ns
->u
.nl4_str
);
294 encode_string(xdr
, ns
->u
.nl4_addr
.netid_len
,
295 ns
->u
.nl4_addr
.netid
);
296 encode_string(xdr
, ns
->u
.nl4_addr
.addr_len
,
297 ns
->u
.nl4_addr
.addr
);
304 static void encode_copy(struct xdr_stream
*xdr
,
305 const struct nfs42_copy_args
*args
,
306 struct compound_hdr
*hdr
)
308 encode_op_hdr(xdr
, OP_COPY
, decode_copy_maxsz
, hdr
);
309 encode_nfs4_stateid(xdr
, &args
->src_stateid
);
310 encode_nfs4_stateid(xdr
, &args
->dst_stateid
);
312 encode_uint64(xdr
, args
->src_pos
);
313 encode_uint64(xdr
, args
->dst_pos
);
314 encode_uint64(xdr
, args
->count
);
316 encode_uint32(xdr
, 1); /* consecutive = true */
317 encode_uint32(xdr
, args
->sync
);
318 if (args
->cp_src
== NULL
) { /* intra-ssc */
319 encode_uint32(xdr
, 0); /* no src server list */
322 encode_uint32(xdr
, 1); /* supporting 1 server */
323 encode_nl4_server(xdr
, args
->cp_src
);
326 static void encode_copy_commit(struct xdr_stream
*xdr
,
327 const struct nfs42_copy_args
*args
,
328 struct compound_hdr
*hdr
)
332 encode_op_hdr(xdr
, OP_COMMIT
, decode_commit_maxsz
, hdr
);
333 p
= reserve_space(xdr
, 12);
334 p
= xdr_encode_hyper(p
, args
->dst_pos
);
335 *p
= cpu_to_be32(args
->count
);
338 static void encode_offload_cancel(struct xdr_stream
*xdr
,
339 const struct nfs42_offload_status_args
*args
,
340 struct compound_hdr
*hdr
)
342 encode_op_hdr(xdr
, OP_OFFLOAD_CANCEL
, decode_offload_cancel_maxsz
, hdr
);
343 encode_nfs4_stateid(xdr
, &args
->osa_stateid
);
346 static void encode_copy_notify(struct xdr_stream
*xdr
,
347 const struct nfs42_copy_notify_args
*args
,
348 struct compound_hdr
*hdr
)
350 encode_op_hdr(xdr
, OP_COPY_NOTIFY
, decode_copy_notify_maxsz
, hdr
);
351 encode_nfs4_stateid(xdr
, &args
->cna_src_stateid
);
352 encode_nl4_server(xdr
, &args
->cna_dst
);
355 static void encode_deallocate(struct xdr_stream
*xdr
,
356 const struct nfs42_falloc_args
*args
,
357 struct compound_hdr
*hdr
)
359 encode_op_hdr(xdr
, OP_DEALLOCATE
, decode_deallocate_maxsz
, hdr
);
360 encode_fallocate(xdr
, args
);
363 static void encode_read_plus(struct xdr_stream
*xdr
,
364 const struct nfs_pgio_args
*args
,
365 struct compound_hdr
*hdr
)
367 encode_op_hdr(xdr
, OP_READ_PLUS
, decode_read_plus_maxsz
, hdr
);
368 encode_nfs4_stateid(xdr
, &args
->stateid
);
369 encode_uint64(xdr
, args
->offset
);
370 encode_uint32(xdr
, args
->count
);
373 static void encode_seek(struct xdr_stream
*xdr
,
374 const struct nfs42_seek_args
*args
,
375 struct compound_hdr
*hdr
)
377 encode_op_hdr(xdr
, OP_SEEK
, decode_seek_maxsz
, hdr
);
378 encode_nfs4_stateid(xdr
, &args
->sa_stateid
);
379 encode_uint64(xdr
, args
->sa_offset
);
380 encode_uint32(xdr
, args
->sa_what
);
383 static void encode_layoutstats(struct xdr_stream
*xdr
,
384 const struct nfs42_layoutstat_args
*args
,
385 struct nfs42_layoutstat_devinfo
*devinfo
,
386 struct compound_hdr
*hdr
)
390 encode_op_hdr(xdr
, OP_LAYOUTSTATS
, decode_layoutstats_maxsz
, hdr
);
391 p
= reserve_space(xdr
, 8 + 8);
392 p
= xdr_encode_hyper(p
, devinfo
->offset
);
393 p
= xdr_encode_hyper(p
, devinfo
->length
);
394 encode_nfs4_stateid(xdr
, &args
->stateid
);
395 p
= reserve_space(xdr
, 4*8 + NFS4_DEVICEID4_SIZE
+ 4);
396 p
= xdr_encode_hyper(p
, devinfo
->read_count
);
397 p
= xdr_encode_hyper(p
, devinfo
->read_bytes
);
398 p
= xdr_encode_hyper(p
, devinfo
->write_count
);
399 p
= xdr_encode_hyper(p
, devinfo
->write_bytes
);
400 p
= xdr_encode_opaque_fixed(p
, devinfo
->dev_id
.data
,
401 NFS4_DEVICEID4_SIZE
);
402 /* Encode layoutupdate4 */
403 *p
++ = cpu_to_be32(devinfo
->layout_type
);
404 if (devinfo
->ld_private
.ops
)
405 devinfo
->ld_private
.ops
->encode(xdr
, args
,
406 &devinfo
->ld_private
);
408 encode_uint32(xdr
, 0);
411 static void encode_clone(struct xdr_stream
*xdr
,
412 const struct nfs42_clone_args
*args
,
413 struct compound_hdr
*hdr
)
417 encode_op_hdr(xdr
, OP_CLONE
, decode_clone_maxsz
, hdr
);
418 encode_nfs4_stateid(xdr
, &args
->src_stateid
);
419 encode_nfs4_stateid(xdr
, &args
->dst_stateid
);
420 p
= reserve_space(xdr
, 3*8);
421 p
= xdr_encode_hyper(p
, args
->src_offset
);
422 p
= xdr_encode_hyper(p
, args
->dst_offset
);
423 xdr_encode_hyper(p
, args
->count
);
426 static void encode_device_error(struct xdr_stream
*xdr
,
427 const struct nfs42_device_error
*error
)
431 p
= reserve_space(xdr
, NFS4_DEVICEID4_SIZE
+ 2*4);
432 p
= xdr_encode_opaque_fixed(p
, error
->dev_id
.data
,
433 NFS4_DEVICEID4_SIZE
);
434 *p
++ = cpu_to_be32(error
->status
);
435 *p
= cpu_to_be32(error
->opnum
);
438 static void encode_layouterror(struct xdr_stream
*xdr
,
439 const struct nfs42_layout_error
*args
,
440 struct compound_hdr
*hdr
)
444 encode_op_hdr(xdr
, OP_LAYOUTERROR
, decode_layouterror_maxsz
, hdr
);
445 p
= reserve_space(xdr
, 8 + 8);
446 p
= xdr_encode_hyper(p
, args
->offset
);
447 p
= xdr_encode_hyper(p
, args
->length
);
448 encode_nfs4_stateid(xdr
, &args
->stateid
);
449 p
= reserve_space(xdr
, 4);
451 encode_device_error(xdr
, &args
->errors
[0]);
454 static void encode_setxattr(struct xdr_stream
*xdr
,
455 const struct nfs42_setxattrargs
*arg
,
456 struct compound_hdr
*hdr
)
460 BUILD_BUG_ON(XATTR_CREATE
!= SETXATTR4_CREATE
);
461 BUILD_BUG_ON(XATTR_REPLACE
!= SETXATTR4_REPLACE
);
463 encode_op_hdr(xdr
, OP_SETXATTR
, decode_setxattr_maxsz
, hdr
);
464 p
= reserve_space(xdr
, 4);
465 *p
= cpu_to_be32(arg
->xattr_flags
);
466 encode_string(xdr
, strlen(arg
->xattr_name
), arg
->xattr_name
);
467 p
= reserve_space(xdr
, 4);
468 *p
= cpu_to_be32(arg
->xattr_len
);
470 xdr_write_pages(xdr
, arg
->xattr_pages
, 0, arg
->xattr_len
);
473 static void encode_getxattr(struct xdr_stream
*xdr
, const char *name
,
474 struct compound_hdr
*hdr
)
476 encode_op_hdr(xdr
, OP_GETXATTR
, decode_getxattr_maxsz
, hdr
);
477 encode_string(xdr
, strlen(name
), name
);
480 static void encode_removexattr(struct xdr_stream
*xdr
, const char *name
,
481 struct compound_hdr
*hdr
)
483 encode_op_hdr(xdr
, OP_REMOVEXATTR
, decode_removexattr_maxsz
, hdr
);
484 encode_string(xdr
, strlen(name
), name
);
487 static void encode_listxattrs(struct xdr_stream
*xdr
,
488 const struct nfs42_listxattrsargs
*arg
,
489 struct compound_hdr
*hdr
)
493 encode_op_hdr(xdr
, OP_LISTXATTRS
, decode_listxattrs_maxsz
, hdr
);
495 p
= reserve_space(xdr
, 12);
499 p
= xdr_encode_hyper(p
, arg
->cookie
);
501 * RFC 8276 says to specify the full max length of the LISTXATTRS
502 * XDR reply. Count is set to the XDR length of the names array
503 * plus the EOF marker. So, add the cookie and the names count.
505 *p
= cpu_to_be32(arg
->count
+ 8 + 4);
509 * Encode ALLOCATE request
511 static void nfs4_xdr_enc_allocate(struct rpc_rqst
*req
,
512 struct xdr_stream
*xdr
,
515 const struct nfs42_falloc_args
*args
= data
;
516 struct compound_hdr hdr
= {
517 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
520 encode_compound_hdr(xdr
, req
, &hdr
);
521 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
522 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
523 encode_allocate(xdr
, args
, &hdr
);
524 encode_getfattr(xdr
, args
->falloc_bitmask
, &hdr
);
529 * Encode COPY request
531 static void nfs4_xdr_enc_copy(struct rpc_rqst
*req
,
532 struct xdr_stream
*xdr
,
535 const struct nfs42_copy_args
*args
= data
;
536 struct compound_hdr hdr
= {
537 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
540 encode_compound_hdr(xdr
, req
, &hdr
);
541 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
542 encode_putfh(xdr
, args
->src_fh
, &hdr
);
543 encode_savefh(xdr
, &hdr
);
544 encode_putfh(xdr
, args
->dst_fh
, &hdr
);
545 encode_copy(xdr
, args
, &hdr
);
547 encode_copy_commit(xdr
, args
, &hdr
);
552 * Encode OFFLOAD_CANEL request
554 static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst
*req
,
555 struct xdr_stream
*xdr
,
558 const struct nfs42_offload_status_args
*args
= data
;
559 struct compound_hdr hdr
= {
560 .minorversion
= nfs4_xdr_minorversion(&args
->osa_seq_args
),
563 encode_compound_hdr(xdr
, req
, &hdr
);
564 encode_sequence(xdr
, &args
->osa_seq_args
, &hdr
);
565 encode_putfh(xdr
, args
->osa_src_fh
, &hdr
);
566 encode_offload_cancel(xdr
, args
, &hdr
);
571 * Encode COPY_NOTIFY request
573 static void nfs4_xdr_enc_copy_notify(struct rpc_rqst
*req
,
574 struct xdr_stream
*xdr
,
577 const struct nfs42_copy_notify_args
*args
= data
;
578 struct compound_hdr hdr
= {
579 .minorversion
= nfs4_xdr_minorversion(&args
->cna_seq_args
),
582 encode_compound_hdr(xdr
, req
, &hdr
);
583 encode_sequence(xdr
, &args
->cna_seq_args
, &hdr
);
584 encode_putfh(xdr
, args
->cna_src_fh
, &hdr
);
585 encode_copy_notify(xdr
, args
, &hdr
);
590 * Encode DEALLOCATE request
592 static void nfs4_xdr_enc_deallocate(struct rpc_rqst
*req
,
593 struct xdr_stream
*xdr
,
596 const struct nfs42_falloc_args
*args
= data
;
597 struct compound_hdr hdr
= {
598 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
601 encode_compound_hdr(xdr
, req
, &hdr
);
602 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
603 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
604 encode_deallocate(xdr
, args
, &hdr
);
605 encode_getfattr(xdr
, args
->falloc_bitmask
, &hdr
);
610 * Encode READ_PLUS request
612 static void nfs4_xdr_enc_read_plus(struct rpc_rqst
*req
,
613 struct xdr_stream
*xdr
,
616 const struct nfs_pgio_args
*args
= data
;
617 struct compound_hdr hdr
= {
618 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
621 encode_compound_hdr(xdr
, req
, &hdr
);
622 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
623 encode_putfh(xdr
, args
->fh
, &hdr
);
624 encode_read_plus(xdr
, args
, &hdr
);
626 rpc_prepare_reply_pages(req
, args
->pages
, args
->pgbase
, args
->count
,
627 hdr
.replen
- READ_PLUS_SEGMENT_SIZE_DIFF
);
632 * Encode SEEK request
634 static void nfs4_xdr_enc_seek(struct rpc_rqst
*req
,
635 struct xdr_stream
*xdr
,
638 const struct nfs42_seek_args
*args
= data
;
639 struct compound_hdr hdr
= {
640 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
643 encode_compound_hdr(xdr
, req
, &hdr
);
644 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
645 encode_putfh(xdr
, args
->sa_fh
, &hdr
);
646 encode_seek(xdr
, args
, &hdr
);
651 * Encode LAYOUTSTATS request
653 static void nfs4_xdr_enc_layoutstats(struct rpc_rqst
*req
,
654 struct xdr_stream
*xdr
,
657 const struct nfs42_layoutstat_args
*args
= data
;
660 struct compound_hdr hdr
= {
661 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
664 encode_compound_hdr(xdr
, req
, &hdr
);
665 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
666 encode_putfh(xdr
, args
->fh
, &hdr
);
667 WARN_ON(args
->num_dev
> PNFS_LAYOUTSTATS_MAXDEV
);
668 for (i
= 0; i
< args
->num_dev
; i
++)
669 encode_layoutstats(xdr
, args
, &args
->devinfo
[i
], &hdr
);
674 * Encode CLONE request
676 static void nfs4_xdr_enc_clone(struct rpc_rqst
*req
,
677 struct xdr_stream
*xdr
,
680 const struct nfs42_clone_args
*args
= data
;
681 struct compound_hdr hdr
= {
682 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
685 encode_compound_hdr(xdr
, req
, &hdr
);
686 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
687 encode_putfh(xdr
, args
->src_fh
, &hdr
);
688 encode_savefh(xdr
, &hdr
);
689 encode_putfh(xdr
, args
->dst_fh
, &hdr
);
690 encode_clone(xdr
, args
, &hdr
);
691 encode_getfattr(xdr
, args
->dst_bitmask
, &hdr
);
696 * Encode LAYOUTERROR request
698 static void nfs4_xdr_enc_layouterror(struct rpc_rqst
*req
,
699 struct xdr_stream
*xdr
,
702 const struct nfs42_layouterror_args
*args
= data
;
703 struct compound_hdr hdr
= {
704 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
708 encode_compound_hdr(xdr
, req
, &hdr
);
709 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
710 encode_putfh(xdr
, NFS_FH(args
->inode
), &hdr
);
711 for (i
= 0; i
< args
->num_errors
; i
++)
712 encode_layouterror(xdr
, &args
->errors
[i
], &hdr
);
717 * Encode SETXATTR request
719 static void nfs4_xdr_enc_setxattr(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
722 const struct nfs42_setxattrargs
*args
= data
;
723 struct compound_hdr hdr
= {
724 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
727 encode_compound_hdr(xdr
, req
, &hdr
);
728 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
729 encode_putfh(xdr
, args
->fh
, &hdr
);
730 encode_setxattr(xdr
, args
, &hdr
);
731 encode_getfattr(xdr
, args
->bitmask
, &hdr
);
736 * Encode GETXATTR request
738 static void nfs4_xdr_enc_getxattr(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
741 const struct nfs42_getxattrargs
*args
= data
;
742 struct compound_hdr hdr
= {
743 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
747 encode_compound_hdr(xdr
, req
, &hdr
);
748 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
749 encode_putfh(xdr
, args
->fh
, &hdr
);
750 replen
= hdr
.replen
+ op_decode_hdr_maxsz
+ 1;
751 encode_getxattr(xdr
, args
->xattr_name
, &hdr
);
753 rpc_prepare_reply_pages(req
, args
->xattr_pages
, 0, args
->xattr_len
,
760 * Encode LISTXATTR request
762 static void nfs4_xdr_enc_listxattrs(struct rpc_rqst
*req
,
763 struct xdr_stream
*xdr
, const void *data
)
765 const struct nfs42_listxattrsargs
*args
= data
;
766 struct compound_hdr hdr
= {
767 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
771 encode_compound_hdr(xdr
, req
, &hdr
);
772 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
773 encode_putfh(xdr
, args
->fh
, &hdr
);
774 replen
= hdr
.replen
+ op_decode_hdr_maxsz
+ 2 + 1;
775 encode_listxattrs(xdr
, args
, &hdr
);
777 rpc_prepare_reply_pages(req
, args
->xattr_pages
, 0, args
->count
, replen
);
783 * Encode REMOVEXATTR request
785 static void nfs4_xdr_enc_removexattr(struct rpc_rqst
*req
,
786 struct xdr_stream
*xdr
, const void *data
)
788 const struct nfs42_removexattrargs
*args
= data
;
789 struct compound_hdr hdr
= {
790 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
793 encode_compound_hdr(xdr
, req
, &hdr
);
794 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
795 encode_putfh(xdr
, args
->fh
, &hdr
);
796 encode_removexattr(xdr
, args
->xattr_name
, &hdr
);
800 static int decode_allocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
802 return decode_op_hdr(xdr
, OP_ALLOCATE
);
805 static int decode_write_response(struct xdr_stream
*xdr
,
806 struct nfs42_write_res
*res
)
811 p
= xdr_inline_decode(xdr
, 4);
814 count
= be32_to_cpup(p
);
817 else if (count
== 1) {
818 status
= decode_opaque_fixed(xdr
, &res
->stateid
,
820 if (unlikely(status
))
823 p
= xdr_inline_decode(xdr
, 8 + 4);
826 p
= xdr_decode_hyper(p
, &res
->count
);
827 res
->verifier
.committed
= be32_to_cpup(p
);
828 return decode_verifier(xdr
, &res
->verifier
.verifier
);
831 static int decode_nl4_server(struct xdr_stream
*xdr
, struct nl4_server
*ns
)
833 struct nfs42_netaddr
*naddr
;
840 p
= xdr_inline_decode(xdr
, 4);
843 ns
->nl4_type
= be32_to_cpup(p
);
844 switch (ns
->nl4_type
) {
847 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
848 if (unlikely(status
))
850 if (unlikely(dummy
> NFS4_OPAQUE_LIMIT
))
852 memcpy(&ns
->u
.nl4_str
, dummy_str
, dummy
);
853 ns
->u
.nl4_str_sz
= dummy
;
856 naddr
= &ns
->u
.nl4_addr
;
859 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
860 if (unlikely(status
))
862 if (unlikely(dummy
> RPCBIND_MAXNETIDLEN
))
864 naddr
->netid_len
= dummy
;
865 memcpy(naddr
->netid
, dummy_str
, naddr
->netid_len
);
868 status
= decode_opaque_inline(xdr
, &dummy
, &dummy_str
);
869 if (unlikely(status
))
871 if (unlikely(dummy
> RPCBIND_MAXUADDRLEN
))
873 naddr
->addr_len
= dummy
;
874 memcpy(naddr
->addr
, dummy_str
, naddr
->addr_len
);
883 static int decode_copy_requirements(struct xdr_stream
*xdr
,
884 struct nfs42_copy_res
*res
) {
887 p
= xdr_inline_decode(xdr
, 4 + 4);
891 res
->consecutive
= be32_to_cpup(p
++);
892 res
->synchronous
= be32_to_cpup(p
++);
896 static int decode_copy(struct xdr_stream
*xdr
, struct nfs42_copy_res
*res
)
900 status
= decode_op_hdr(xdr
, OP_COPY
);
901 if (status
== NFS4ERR_OFFLOAD_NO_REQS
) {
902 status
= decode_copy_requirements(xdr
, res
);
905 return NFS4ERR_OFFLOAD_NO_REQS
;
909 status
= decode_write_response(xdr
, &res
->write_res
);
913 return decode_copy_requirements(xdr
, res
);
916 static int decode_offload_cancel(struct xdr_stream
*xdr
,
917 struct nfs42_offload_status_res
*res
)
919 return decode_op_hdr(xdr
, OP_OFFLOAD_CANCEL
);
922 static int decode_copy_notify(struct xdr_stream
*xdr
,
923 struct nfs42_copy_notify_res
*res
)
928 status
= decode_op_hdr(xdr
, OP_COPY_NOTIFY
);
932 p
= xdr_inline_decode(xdr
, 12);
935 p
= xdr_decode_hyper(p
, &res
->cnr_lease_time
.seconds
);
936 res
->cnr_lease_time
.nseconds
= be32_to_cpup(p
);
938 status
= decode_opaque_fixed(xdr
, &res
->cnr_stateid
, NFS4_STATEID_SIZE
);
939 if (unlikely(status
))
942 /* number of source addresses */
943 p
= xdr_inline_decode(xdr
, 4);
947 count
= be32_to_cpup(p
);
949 pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n",
952 status
= decode_nl4_server(xdr
, &res
->cnr_src
);
953 if (unlikely(status
))
958 static int decode_deallocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
960 return decode_op_hdr(xdr
, OP_DEALLOCATE
);
963 struct read_plus_segment
{
964 enum data_content4 type
;
978 static inline uint64_t read_plus_segment_length(struct read_plus_segment
*seg
)
980 return seg
->type
== NFS4_CONTENT_DATA
? seg
->data
.length
: seg
->hole
.length
;
983 static int decode_read_plus_segment(struct xdr_stream
*xdr
,
984 struct read_plus_segment
*seg
)
988 p
= xdr_inline_decode(xdr
, 4);
991 seg
->type
= be32_to_cpup(p
++);
993 p
= xdr_inline_decode(xdr
, seg
->type
== NFS4_CONTENT_DATA
? 12 : 16);
996 p
= xdr_decode_hyper(p
, &seg
->offset
);
998 if (seg
->type
== NFS4_CONTENT_DATA
) {
1000 uint32_t len
= be32_to_cpup(p
);
1002 seg
->data
.length
= len
;
1003 seg
->data
.from
= xdr_stream_pos(xdr
);
1005 if (!xdr_stream_subsegment(xdr
, &buf
, xdr_align_size(len
)))
1007 } else if (seg
->type
== NFS4_CONTENT_HOLE
) {
1008 xdr_decode_hyper(p
, &seg
->hole
.length
);
1014 static int process_read_plus_segment(struct xdr_stream
*xdr
,
1015 struct nfs_pgio_args
*args
,
1016 struct nfs_pgio_res
*res
,
1017 struct read_plus_segment
*seg
)
1019 unsigned long offset
= seg
->offset
;
1020 unsigned long length
= read_plus_segment_length(seg
);
1021 unsigned int bufpos
;
1023 if (offset
+ length
< args
->offset
)
1025 else if (offset
> args
->offset
+ args
->count
) {
1028 } else if (offset
< args
->offset
) {
1029 length
-= (args
->offset
- offset
);
1030 offset
= args
->offset
;
1031 } else if (offset
+ length
> args
->offset
+ args
->count
) {
1032 length
= (args
->offset
+ args
->count
) - offset
;
1036 bufpos
= xdr
->buf
->head
[0].iov_len
+ (offset
- args
->offset
);
1037 if (seg
->type
== NFS4_CONTENT_HOLE
)
1038 return xdr_stream_zero(xdr
, bufpos
, length
);
1040 return xdr_stream_move_subsegment(xdr
, seg
->data
.from
, bufpos
, length
);
1043 static int decode_read_plus(struct xdr_stream
*xdr
, struct nfs_pgio_res
*res
)
1045 struct nfs_pgio_header
*hdr
=
1046 container_of(res
, struct nfs_pgio_header
, res
);
1047 struct nfs_pgio_args
*args
= &hdr
->args
;
1049 struct read_plus_segment
*segs
;
1053 status
= decode_op_hdr(xdr
, OP_READ_PLUS
);
1057 p
= xdr_inline_decode(xdr
, 4 + 4);
1062 res
->eof
= be32_to_cpup(p
++);
1063 segments
= be32_to_cpup(p
++);
1067 segs
= kmalloc_array(segments
, sizeof(*segs
), GFP_KERNEL
);
1071 for (i
= 0; i
< segments
; i
++) {
1072 status
= decode_read_plus_segment(xdr
, &segs
[i
]);
1077 xdr_set_pagelen(xdr
, xdr_align_size(args
->count
));
1078 for (i
= segments
; i
> 0; i
--)
1079 res
->count
+= process_read_plus_segment(xdr
, args
, res
, &segs
[i
-1]);
1087 static int decode_seek(struct xdr_stream
*xdr
, struct nfs42_seek_res
*res
)
1092 status
= decode_op_hdr(xdr
, OP_SEEK
);
1096 p
= xdr_inline_decode(xdr
, 4 + 8);
1100 res
->sr_eof
= be32_to_cpup(p
++);
1101 p
= xdr_decode_hyper(p
, &res
->sr_offset
);
1105 static int decode_layoutstats(struct xdr_stream
*xdr
)
1107 return decode_op_hdr(xdr
, OP_LAYOUTSTATS
);
1110 static int decode_clone(struct xdr_stream
*xdr
)
1112 return decode_op_hdr(xdr
, OP_CLONE
);
1115 static int decode_layouterror(struct xdr_stream
*xdr
)
1117 return decode_op_hdr(xdr
, OP_LAYOUTERROR
);
1120 static int decode_setxattr(struct xdr_stream
*xdr
,
1121 struct nfs4_change_info
*cinfo
)
1125 status
= decode_op_hdr(xdr
, OP_SETXATTR
);
1128 status
= decode_change_info(xdr
, cinfo
);
1133 static int decode_getxattr(struct xdr_stream
*xdr
,
1134 struct nfs42_getxattrres
*res
,
1135 struct rpc_rqst
*req
)
1141 status
= decode_op_hdr(xdr
, OP_GETXATTR
);
1145 p
= xdr_inline_decode(xdr
, 4);
1149 len
= be32_to_cpup(p
);
1152 * Only check against the page length here. The actual
1153 * requested length may be smaller, but that is only
1154 * checked against after possibly caching a valid reply.
1156 if (len
> req
->rq_rcv_buf
.page_len
)
1159 res
->xattr_len
= len
;
1162 rdlen
= xdr_read_pages(xdr
, len
);
1170 static int decode_removexattr(struct xdr_stream
*xdr
,
1171 struct nfs4_change_info
*cinfo
)
1175 status
= decode_op_hdr(xdr
, OP_REMOVEXATTR
);
1179 status
= decode_change_info(xdr
, cinfo
);
1184 static int decode_listxattrs(struct xdr_stream
*xdr
,
1185 struct nfs42_listxattrsres
*res
)
1189 u32 count
, len
, ulen
;
1190 size_t left
, copied
;
1193 status
= decode_op_hdr(xdr
, OP_LISTXATTRS
);
1196 * Special case: for LISTXATTRS, NFS4ERR_TOOSMALL
1197 * should be translated to ERANGE.
1199 if (status
== -ETOOSMALL
)
1202 * Special case: for LISTXATTRS, NFS4ERR_NOXATTR
1203 * should be translated to success with zero-length reply.
1205 if (status
== -ENODATA
) {
1212 p
= xdr_inline_decode(xdr
, 8);
1216 xdr_decode_hyper(p
, &res
->cookie
);
1218 p
= xdr_inline_decode(xdr
, 4);
1222 left
= res
->xattr_len
;
1223 buf
= res
->xattr_buf
;
1225 count
= be32_to_cpup(p
);
1229 * We have asked for enough room to encode the maximum number
1230 * of possible attribute names, so everything should fit.
1232 * But, don't rely on that assumption. Just decode entries
1233 * until they don't fit anymore, just in case the server did
1237 p
= xdr_inline_decode(xdr
, 4);
1241 len
= be32_to_cpup(p
);
1242 if (len
> (XATTR_NAME_MAX
- XATTR_USER_PREFIX_LEN
)) {
1247 p
= xdr_inline_decode(xdr
, len
);
1251 ulen
= len
+ XATTR_USER_PREFIX_LEN
+ 1;
1258 memcpy(buf
, XATTR_USER_PREFIX
, XATTR_USER_PREFIX_LEN
);
1259 memcpy(buf
+ XATTR_USER_PREFIX_LEN
, p
, len
);
1268 p
= xdr_inline_decode(xdr
, 4);
1272 res
->eof
= be32_to_cpup(p
);
1273 res
->copied
= copied
;
1276 if (status
== -ERANGE
&& res
->xattr_len
== XATTR_LIST_MAX
)
1283 * Decode ALLOCATE request
1285 static int nfs4_xdr_dec_allocate(struct rpc_rqst
*rqstp
,
1286 struct xdr_stream
*xdr
,
1289 struct nfs42_falloc_res
*res
= data
;
1290 struct compound_hdr hdr
;
1293 status
= decode_compound_hdr(xdr
, &hdr
);
1296 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1299 status
= decode_putfh(xdr
);
1302 status
= decode_allocate(xdr
, res
);
1305 decode_getfattr(xdr
, res
->falloc_fattr
, res
->falloc_server
);
1311 * Decode COPY response
1313 static int nfs4_xdr_dec_copy(struct rpc_rqst
*rqstp
,
1314 struct xdr_stream
*xdr
,
1317 struct nfs42_copy_res
*res
= data
;
1318 struct compound_hdr hdr
;
1321 status
= decode_compound_hdr(xdr
, &hdr
);
1324 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1327 status
= decode_putfh(xdr
);
1330 status
= decode_savefh(xdr
);
1333 status
= decode_putfh(xdr
);
1336 status
= decode_copy(xdr
, res
);
1339 if (res
->commit_res
.verf
)
1340 status
= decode_commit(xdr
, &res
->commit_res
);
1346 * Decode OFFLOAD_CANCEL response
1348 static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst
*rqstp
,
1349 struct xdr_stream
*xdr
,
1352 struct nfs42_offload_status_res
*res
= data
;
1353 struct compound_hdr hdr
;
1356 status
= decode_compound_hdr(xdr
, &hdr
);
1359 status
= decode_sequence(xdr
, &res
->osr_seq_res
, rqstp
);
1362 status
= decode_putfh(xdr
);
1365 status
= decode_offload_cancel(xdr
, res
);
1372 * Decode COPY_NOTIFY response
1374 static int nfs4_xdr_dec_copy_notify(struct rpc_rqst
*rqstp
,
1375 struct xdr_stream
*xdr
,
1378 struct nfs42_copy_notify_res
*res
= data
;
1379 struct compound_hdr hdr
;
1382 status
= decode_compound_hdr(xdr
, &hdr
);
1385 status
= decode_sequence(xdr
, &res
->cnr_seq_res
, rqstp
);
1388 status
= decode_putfh(xdr
);
1391 status
= decode_copy_notify(xdr
, res
);
1398 * Decode DEALLOCATE request
1400 static int nfs4_xdr_dec_deallocate(struct rpc_rqst
*rqstp
,
1401 struct xdr_stream
*xdr
,
1404 struct nfs42_falloc_res
*res
= data
;
1405 struct compound_hdr hdr
;
1408 status
= decode_compound_hdr(xdr
, &hdr
);
1411 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1414 status
= decode_putfh(xdr
);
1417 status
= decode_deallocate(xdr
, res
);
1420 decode_getfattr(xdr
, res
->falloc_fattr
, res
->falloc_server
);
1426 * Decode READ_PLUS request
1428 static int nfs4_xdr_dec_read_plus(struct rpc_rqst
*rqstp
,
1429 struct xdr_stream
*xdr
,
1432 struct nfs_pgio_res
*res
= data
;
1433 struct compound_hdr hdr
;
1436 xdr_set_scratch_buffer(xdr
, res
->scratch
, READ_PLUS_SCRATCH_SIZE
);
1438 status
= decode_compound_hdr(xdr
, &hdr
);
1441 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1444 status
= decode_putfh(xdr
);
1447 status
= decode_read_plus(xdr
, res
);
1449 status
= res
->count
;
1455 * Decode SEEK request
1457 static int nfs4_xdr_dec_seek(struct rpc_rqst
*rqstp
,
1458 struct xdr_stream
*xdr
,
1461 struct nfs42_seek_res
*res
= data
;
1462 struct compound_hdr hdr
;
1465 status
= decode_compound_hdr(xdr
, &hdr
);
1468 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1471 status
= decode_putfh(xdr
);
1474 status
= decode_seek(xdr
, res
);
1480 * Decode LAYOUTSTATS request
1482 static int nfs4_xdr_dec_layoutstats(struct rpc_rqst
*rqstp
,
1483 struct xdr_stream
*xdr
,
1486 struct nfs42_layoutstat_res
*res
= data
;
1487 struct compound_hdr hdr
;
1490 status
= decode_compound_hdr(xdr
, &hdr
);
1493 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1496 status
= decode_putfh(xdr
);
1499 WARN_ON(res
->num_dev
> PNFS_LAYOUTSTATS_MAXDEV
);
1500 for (i
= 0; i
< res
->num_dev
; i
++) {
1501 status
= decode_layoutstats(xdr
);
1506 res
->rpc_status
= status
;
1511 * Decode CLONE request
1513 static int nfs4_xdr_dec_clone(struct rpc_rqst
*rqstp
,
1514 struct xdr_stream
*xdr
,
1517 struct nfs42_clone_res
*res
= data
;
1518 struct compound_hdr hdr
;
1521 status
= decode_compound_hdr(xdr
, &hdr
);
1524 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1527 status
= decode_putfh(xdr
);
1530 status
= decode_savefh(xdr
);
1533 status
= decode_putfh(xdr
);
1536 status
= decode_clone(xdr
);
1539 decode_getfattr(xdr
, res
->dst_fattr
, res
->server
);
1541 res
->rpc_status
= status
;
1546 * Decode LAYOUTERROR request
1548 static int nfs4_xdr_dec_layouterror(struct rpc_rqst
*rqstp
,
1549 struct xdr_stream
*xdr
,
1552 struct nfs42_layouterror_res
*res
= data
;
1553 struct compound_hdr hdr
;
1556 status
= decode_compound_hdr(xdr
, &hdr
);
1559 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1562 status
= decode_putfh(xdr
);
1564 for (i
= 0; i
< res
->num_errors
&& status
== 0; i
++)
1565 status
= decode_layouterror(xdr
);
1567 res
->rpc_status
= status
;
1572 * Decode SETXATTR request
1574 static int nfs4_xdr_dec_setxattr(struct rpc_rqst
*req
, struct xdr_stream
*xdr
,
1577 struct nfs42_setxattrres
*res
= data
;
1578 struct compound_hdr hdr
;
1581 status
= decode_compound_hdr(xdr
, &hdr
);
1584 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
1587 status
= decode_putfh(xdr
);
1590 status
= decode_setxattr(xdr
, &res
->cinfo
);
1593 status
= decode_getfattr(xdr
, res
->fattr
, res
->server
);
1599 * Decode GETXATTR request
1601 static int nfs4_xdr_dec_getxattr(struct rpc_rqst
*rqstp
,
1602 struct xdr_stream
*xdr
, void *data
)
1604 struct nfs42_getxattrres
*res
= data
;
1605 struct compound_hdr hdr
;
1608 status
= decode_compound_hdr(xdr
, &hdr
);
1611 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1614 status
= decode_putfh(xdr
);
1617 status
= decode_getxattr(xdr
, res
, rqstp
);
1623 * Decode LISTXATTR request
1625 static int nfs4_xdr_dec_listxattrs(struct rpc_rqst
*rqstp
,
1626 struct xdr_stream
*xdr
, void *data
)
1628 struct nfs42_listxattrsres
*res
= data
;
1629 struct compound_hdr hdr
;
1632 xdr_set_scratch_page(xdr
, res
->scratch
);
1634 status
= decode_compound_hdr(xdr
, &hdr
);
1637 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
1640 status
= decode_putfh(xdr
);
1643 status
= decode_listxattrs(xdr
, res
);
1649 * Decode REMOVEXATTR request
1651 static int nfs4_xdr_dec_removexattr(struct rpc_rqst
*req
,
1652 struct xdr_stream
*xdr
, void *data
)
1654 struct nfs42_removexattrres
*res
= data
;
1655 struct compound_hdr hdr
;
1658 status
= decode_compound_hdr(xdr
, &hdr
);
1661 status
= decode_sequence(xdr
, &res
->seq_res
, req
);
1664 status
= decode_putfh(xdr
);
1668 status
= decode_removexattr(xdr
, &res
->cinfo
);
1672 #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */