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 #define encode_fallocate_maxsz (encode_stateid_maxsz + \
13 #define NFS42_WRITE_RES_SIZE (1 /* wr_callback_id size */ +\
14 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
16 1 /* wr_committed */ + \
17 XDR_QUADLEN(NFS4_VERIFIER_SIZE))
18 #define encode_allocate_maxsz (op_encode_hdr_maxsz + \
19 encode_fallocate_maxsz)
20 #define decode_allocate_maxsz (op_decode_hdr_maxsz)
21 #define encode_copy_maxsz (op_encode_hdr_maxsz + \
22 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
23 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
24 2 + 2 + 2 + 1 + 1 + 1)
25 #define decode_copy_maxsz (op_decode_hdr_maxsz + \
26 NFS42_WRITE_RES_SIZE + \
27 1 /* cr_consecutive */ + \
28 1 /* cr_synchronous */)
29 #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
30 XDR_QUADLEN(NFS4_STATEID_SIZE))
31 #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
32 #define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \
33 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
35 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
36 #define decode_copy_notify_maxsz (op_decode_hdr_maxsz + \
37 3 + /* cnr_lease_time */\
38 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
39 1 + /* Support 1 cnr_source_server */\
41 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
42 #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
43 encode_fallocate_maxsz)
44 #define decode_deallocate_maxsz (op_decode_hdr_maxsz)
45 #define encode_seek_maxsz (op_encode_hdr_maxsz + \
46 encode_stateid_maxsz + \
49 #define decode_seek_maxsz (op_decode_hdr_maxsz + \
54 #define encode_io_info_maxsz 4
55 #define encode_layoutstats_maxsz (op_decode_hdr_maxsz + \
58 encode_stateid_maxsz + \
59 encode_io_info_maxsz + \
60 encode_io_info_maxsz + \
61 1 /* opaque devaddr4 length */ + \
62 XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
63 #define decode_layoutstats_maxsz (op_decode_hdr_maxsz)
64 #define encode_device_error_maxsz (XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
65 1 /* status */ + 1 /* opnum */)
66 #define encode_layouterror_maxsz (op_decode_hdr_maxsz + \
69 encode_stateid_maxsz + \
70 1 /* Array size */ + \
71 encode_device_error_maxsz)
72 #define decode_layouterror_maxsz (op_decode_hdr_maxsz)
73 #define encode_clone_maxsz (encode_stateid_maxsz + \
74 encode_stateid_maxsz + \
75 2 /* src offset */ + \
76 2 /* dst offset */ + \
78 #define decode_clone_maxsz (op_decode_hdr_maxsz)
80 #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
81 encode_sequence_maxsz + \
82 encode_putfh_maxsz + \
83 encode_allocate_maxsz + \
85 #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
86 decode_sequence_maxsz + \
87 decode_putfh_maxsz + \
88 decode_allocate_maxsz + \
90 #define NFS4_enc_copy_sz (compound_encode_hdr_maxsz + \
91 encode_sequence_maxsz + \
92 encode_putfh_maxsz + \
93 encode_savefh_maxsz + \
94 encode_putfh_maxsz + \
97 #define NFS4_dec_copy_sz (compound_decode_hdr_maxsz + \
98 decode_sequence_maxsz + \
99 decode_putfh_maxsz + \
100 decode_savefh_maxsz + \
101 decode_putfh_maxsz + \
102 decode_copy_maxsz + \
104 #define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \
105 encode_sequence_maxsz + \
106 encode_putfh_maxsz + \
107 encode_offload_cancel_maxsz)
108 #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \
109 decode_sequence_maxsz + \
110 decode_putfh_maxsz + \
111 decode_offload_cancel_maxsz)
112 #define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \
113 encode_putfh_maxsz + \
114 encode_copy_notify_maxsz)
115 #define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \
116 decode_putfh_maxsz + \
117 decode_copy_notify_maxsz)
118 #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
119 encode_sequence_maxsz + \
120 encode_putfh_maxsz + \
121 encode_deallocate_maxsz + \
122 encode_getattr_maxsz)
123 #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
124 decode_sequence_maxsz + \
125 decode_putfh_maxsz + \
126 decode_deallocate_maxsz + \
127 decode_getattr_maxsz)
128 #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
129 encode_sequence_maxsz + \
130 encode_putfh_maxsz + \
132 #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
133 decode_sequence_maxsz + \
134 decode_putfh_maxsz + \
136 #define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \
137 encode_sequence_maxsz + \
138 encode_putfh_maxsz + \
139 PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz)
140 #define NFS4_dec_layoutstats_sz (compound_decode_hdr_maxsz + \
141 decode_sequence_maxsz + \
142 decode_putfh_maxsz + \
143 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
144 #define NFS4_enc_layouterror_sz (compound_encode_hdr_maxsz + \
145 encode_sequence_maxsz + \
146 encode_putfh_maxsz + \
147 NFS42_LAYOUTERROR_MAX * \
148 encode_layouterror_maxsz)
149 #define NFS4_dec_layouterror_sz (compound_decode_hdr_maxsz + \
150 decode_sequence_maxsz + \
151 decode_putfh_maxsz + \
152 NFS42_LAYOUTERROR_MAX * \
153 decode_layouterror_maxsz)
154 #define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \
155 encode_sequence_maxsz + \
156 encode_putfh_maxsz + \
157 encode_savefh_maxsz + \
158 encode_putfh_maxsz + \
159 encode_clone_maxsz + \
160 encode_getattr_maxsz)
161 #define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \
162 decode_sequence_maxsz + \
163 decode_putfh_maxsz + \
164 decode_savefh_maxsz + \
165 decode_putfh_maxsz + \
166 decode_clone_maxsz + \
167 decode_getattr_maxsz)
169 static void encode_fallocate(struct xdr_stream *xdr,
170 const struct nfs42_falloc_args *args)
172 encode_nfs4_stateid(xdr, &args->falloc_stateid);
173 encode_uint64(xdr, args->falloc_offset);
174 encode_uint64(xdr, args->falloc_length);
177 static void encode_allocate(struct xdr_stream *xdr,
178 const struct nfs42_falloc_args *args,
179 struct compound_hdr *hdr)
181 encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr);
182 encode_fallocate(xdr, args);
185 static void encode_nl4_server(struct xdr_stream *xdr,
186 const struct nl4_server *ns)
188 encode_uint32(xdr, ns->nl4_type);
189 switch (ns->nl4_type) {
192 encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str);
195 encode_string(xdr, ns->u.nl4_addr.netid_len,
196 ns->u.nl4_addr.netid);
197 encode_string(xdr, ns->u.nl4_addr.addr_len,
198 ns->u.nl4_addr.addr);
205 static void encode_copy(struct xdr_stream *xdr,
206 const struct nfs42_copy_args *args,
207 struct compound_hdr *hdr)
209 encode_op_hdr(xdr, OP_COPY, decode_copy_maxsz, hdr);
210 encode_nfs4_stateid(xdr, &args->src_stateid);
211 encode_nfs4_stateid(xdr, &args->dst_stateid);
213 encode_uint64(xdr, args->src_pos);
214 encode_uint64(xdr, args->dst_pos);
215 encode_uint64(xdr, args->count);
217 encode_uint32(xdr, 1); /* consecutive = true */
218 encode_uint32(xdr, args->sync);
219 encode_uint32(xdr, 0); /* src server list */
222 static void encode_offload_cancel(struct xdr_stream *xdr,
223 const struct nfs42_offload_status_args *args,
224 struct compound_hdr *hdr)
226 encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
227 encode_nfs4_stateid(xdr, &args->osa_stateid);
230 static void encode_copy_notify(struct xdr_stream *xdr,
231 const struct nfs42_copy_notify_args *args,
232 struct compound_hdr *hdr)
234 encode_op_hdr(xdr, OP_COPY_NOTIFY, decode_copy_notify_maxsz, hdr);
235 encode_nfs4_stateid(xdr, &args->cna_src_stateid);
236 encode_nl4_server(xdr, &args->cna_dst);
239 static void encode_deallocate(struct xdr_stream *xdr,
240 const struct nfs42_falloc_args *args,
241 struct compound_hdr *hdr)
243 encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr);
244 encode_fallocate(xdr, args);
247 static void encode_seek(struct xdr_stream *xdr,
248 const struct nfs42_seek_args *args,
249 struct compound_hdr *hdr)
251 encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr);
252 encode_nfs4_stateid(xdr, &args->sa_stateid);
253 encode_uint64(xdr, args->sa_offset);
254 encode_uint32(xdr, args->sa_what);
257 static void encode_layoutstats(struct xdr_stream *xdr,
258 const struct nfs42_layoutstat_args *args,
259 struct nfs42_layoutstat_devinfo *devinfo,
260 struct compound_hdr *hdr)
264 encode_op_hdr(xdr, OP_LAYOUTSTATS, decode_layoutstats_maxsz, hdr);
265 p = reserve_space(xdr, 8 + 8);
266 p = xdr_encode_hyper(p, devinfo->offset);
267 p = xdr_encode_hyper(p, devinfo->length);
268 encode_nfs4_stateid(xdr, &args->stateid);
269 p = reserve_space(xdr, 4*8 + NFS4_DEVICEID4_SIZE + 4);
270 p = xdr_encode_hyper(p, devinfo->read_count);
271 p = xdr_encode_hyper(p, devinfo->read_bytes);
272 p = xdr_encode_hyper(p, devinfo->write_count);
273 p = xdr_encode_hyper(p, devinfo->write_bytes);
274 p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data,
275 NFS4_DEVICEID4_SIZE);
276 /* Encode layoutupdate4 */
277 *p++ = cpu_to_be32(devinfo->layout_type);
278 if (devinfo->ld_private.ops)
279 devinfo->ld_private.ops->encode(xdr, args,
280 &devinfo->ld_private);
282 encode_uint32(xdr, 0);
285 static void encode_clone(struct xdr_stream *xdr,
286 const struct nfs42_clone_args *args,
287 struct compound_hdr *hdr)
291 encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr);
292 encode_nfs4_stateid(xdr, &args->src_stateid);
293 encode_nfs4_stateid(xdr, &args->dst_stateid);
294 p = reserve_space(xdr, 3*8);
295 p = xdr_encode_hyper(p, args->src_offset);
296 p = xdr_encode_hyper(p, args->dst_offset);
297 xdr_encode_hyper(p, args->count);
300 static void encode_device_error(struct xdr_stream *xdr,
301 const struct nfs42_device_error *error)
305 p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 2*4);
306 p = xdr_encode_opaque_fixed(p, error->dev_id.data,
307 NFS4_DEVICEID4_SIZE);
308 *p++ = cpu_to_be32(error->status);
309 *p = cpu_to_be32(error->opnum);
312 static void encode_layouterror(struct xdr_stream *xdr,
313 const struct nfs42_layout_error *args,
314 struct compound_hdr *hdr)
318 encode_op_hdr(xdr, OP_LAYOUTERROR, decode_layouterror_maxsz, hdr);
319 p = reserve_space(xdr, 8 + 8);
320 p = xdr_encode_hyper(p, args->offset);
321 p = xdr_encode_hyper(p, args->length);
322 encode_nfs4_stateid(xdr, &args->stateid);
323 p = reserve_space(xdr, 4);
325 encode_device_error(xdr, &args->errors[0]);
329 * Encode ALLOCATE request
331 static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
332 struct xdr_stream *xdr,
335 const struct nfs42_falloc_args *args = data;
336 struct compound_hdr hdr = {
337 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
340 encode_compound_hdr(xdr, req, &hdr);
341 encode_sequence(xdr, &args->seq_args, &hdr);
342 encode_putfh(xdr, args->falloc_fh, &hdr);
343 encode_allocate(xdr, args, &hdr);
344 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
348 static void encode_copy_commit(struct xdr_stream *xdr,
349 const struct nfs42_copy_args *args,
350 struct compound_hdr *hdr)
354 encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
355 p = reserve_space(xdr, 12);
356 p = xdr_encode_hyper(p, args->dst_pos);
357 *p = cpu_to_be32(args->count);
361 * Encode COPY request
363 static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
364 struct xdr_stream *xdr,
367 const struct nfs42_copy_args *args = data;
368 struct compound_hdr hdr = {
369 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
372 encode_compound_hdr(xdr, req, &hdr);
373 encode_sequence(xdr, &args->seq_args, &hdr);
374 encode_putfh(xdr, args->src_fh, &hdr);
375 encode_savefh(xdr, &hdr);
376 encode_putfh(xdr, args->dst_fh, &hdr);
377 encode_copy(xdr, args, &hdr);
379 encode_copy_commit(xdr, args, &hdr);
384 * Encode OFFLOAD_CANEL request
386 static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
387 struct xdr_stream *xdr,
390 const struct nfs42_offload_status_args *args = data;
391 struct compound_hdr hdr = {
392 .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
395 encode_compound_hdr(xdr, req, &hdr);
396 encode_sequence(xdr, &args->osa_seq_args, &hdr);
397 encode_putfh(xdr, args->osa_src_fh, &hdr);
398 encode_offload_cancel(xdr, args, &hdr);
403 * Encode COPY_NOTIFY request
405 static void nfs4_xdr_enc_copy_notify(struct rpc_rqst *req,
406 struct xdr_stream *xdr,
409 const struct nfs42_copy_notify_args *args = data;
410 struct compound_hdr hdr = {
411 .minorversion = nfs4_xdr_minorversion(&args->cna_seq_args),
414 encode_compound_hdr(xdr, req, &hdr);
415 encode_sequence(xdr, &args->cna_seq_args, &hdr);
416 encode_putfh(xdr, args->cna_src_fh, &hdr);
417 encode_copy_notify(xdr, args, &hdr);
422 * Encode DEALLOCATE request
424 static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
425 struct xdr_stream *xdr,
428 const struct nfs42_falloc_args *args = data;
429 struct compound_hdr hdr = {
430 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
433 encode_compound_hdr(xdr, req, &hdr);
434 encode_sequence(xdr, &args->seq_args, &hdr);
435 encode_putfh(xdr, args->falloc_fh, &hdr);
436 encode_deallocate(xdr, args, &hdr);
437 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
442 * Encode SEEK request
444 static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
445 struct xdr_stream *xdr,
448 const struct nfs42_seek_args *args = data;
449 struct compound_hdr hdr = {
450 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
453 encode_compound_hdr(xdr, req, &hdr);
454 encode_sequence(xdr, &args->seq_args, &hdr);
455 encode_putfh(xdr, args->sa_fh, &hdr);
456 encode_seek(xdr, args, &hdr);
461 * Encode LAYOUTSTATS request
463 static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
464 struct xdr_stream *xdr,
467 const struct nfs42_layoutstat_args *args = data;
470 struct compound_hdr hdr = {
471 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
474 encode_compound_hdr(xdr, req, &hdr);
475 encode_sequence(xdr, &args->seq_args, &hdr);
476 encode_putfh(xdr, args->fh, &hdr);
477 WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
478 for (i = 0; i < args->num_dev; i++)
479 encode_layoutstats(xdr, args, &args->devinfo[i], &hdr);
484 * Encode CLONE request
486 static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
487 struct xdr_stream *xdr,
490 const struct nfs42_clone_args *args = data;
491 struct compound_hdr hdr = {
492 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
495 encode_compound_hdr(xdr, req, &hdr);
496 encode_sequence(xdr, &args->seq_args, &hdr);
497 encode_putfh(xdr, args->src_fh, &hdr);
498 encode_savefh(xdr, &hdr);
499 encode_putfh(xdr, args->dst_fh, &hdr);
500 encode_clone(xdr, args, &hdr);
501 encode_getfattr(xdr, args->dst_bitmask, &hdr);
506 * Encode LAYOUTERROR request
508 static void nfs4_xdr_enc_layouterror(struct rpc_rqst *req,
509 struct xdr_stream *xdr,
512 const struct nfs42_layouterror_args *args = data;
513 struct compound_hdr hdr = {
514 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
518 encode_compound_hdr(xdr, req, &hdr);
519 encode_sequence(xdr, &args->seq_args, &hdr);
520 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
521 for (i = 0; i < args->num_errors; i++)
522 encode_layouterror(xdr, &args->errors[i], &hdr);
526 static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
528 return decode_op_hdr(xdr, OP_ALLOCATE);
531 static int decode_write_response(struct xdr_stream *xdr,
532 struct nfs42_write_res *res)
537 p = xdr_inline_decode(xdr, 4);
540 count = be32_to_cpup(p);
543 else if (count == 1) {
544 status = decode_opaque_fixed(xdr, &res->stateid,
546 if (unlikely(status))
549 p = xdr_inline_decode(xdr, 8 + 4);
552 p = xdr_decode_hyper(p, &res->count);
553 res->verifier.committed = be32_to_cpup(p);
554 return decode_verifier(xdr, &res->verifier.verifier);
557 static int decode_nl4_server(struct xdr_stream *xdr, struct nl4_server *ns)
559 struct nfs42_netaddr *naddr;
566 p = xdr_inline_decode(xdr, 4);
569 ns->nl4_type = be32_to_cpup(p);
570 switch (ns->nl4_type) {
573 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
574 if (unlikely(status))
576 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
578 memcpy(&ns->u.nl4_str, dummy_str, dummy);
579 ns->u.nl4_str_sz = dummy;
582 naddr = &ns->u.nl4_addr;
585 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
586 if (unlikely(status))
588 if (unlikely(dummy > RPCBIND_MAXNETIDLEN))
590 naddr->netid_len = dummy;
591 memcpy(naddr->netid, dummy_str, naddr->netid_len);
594 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
595 if (unlikely(status))
597 if (unlikely(dummy > RPCBIND_MAXUADDRLEN))
599 naddr->addr_len = dummy;
600 memcpy(naddr->addr, dummy_str, naddr->addr_len);
609 static int decode_copy_requirements(struct xdr_stream *xdr,
610 struct nfs42_copy_res *res) {
613 p = xdr_inline_decode(xdr, 4 + 4);
617 res->consecutive = be32_to_cpup(p++);
618 res->synchronous = be32_to_cpup(p++);
622 static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
626 status = decode_op_hdr(xdr, OP_COPY);
627 if (status == NFS4ERR_OFFLOAD_NO_REQS) {
628 status = decode_copy_requirements(xdr, res);
631 return NFS4ERR_OFFLOAD_NO_REQS;
635 status = decode_write_response(xdr, &res->write_res);
639 return decode_copy_requirements(xdr, res);
642 static int decode_offload_cancel(struct xdr_stream *xdr,
643 struct nfs42_offload_status_res *res)
645 return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
648 static int decode_copy_notify(struct xdr_stream *xdr,
649 struct nfs42_copy_notify_res *res)
654 status = decode_op_hdr(xdr, OP_COPY_NOTIFY);
658 p = xdr_inline_decode(xdr, 12);
661 p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds);
662 res->cnr_lease_time.nseconds = be32_to_cpup(p);
664 status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE);
665 if (unlikely(status))
668 /* number of source addresses */
669 p = xdr_inline_decode(xdr, 4);
673 count = be32_to_cpup(p);
675 pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n",
678 status = decode_nl4_server(xdr, &res->cnr_src);
679 if (unlikely(status))
684 static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
686 return decode_op_hdr(xdr, OP_DEALLOCATE);
689 static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
694 status = decode_op_hdr(xdr, OP_SEEK);
698 p = xdr_inline_decode(xdr, 4 + 8);
702 res->sr_eof = be32_to_cpup(p++);
703 p = xdr_decode_hyper(p, &res->sr_offset);
707 static int decode_layoutstats(struct xdr_stream *xdr)
709 return decode_op_hdr(xdr, OP_LAYOUTSTATS);
712 static int decode_clone(struct xdr_stream *xdr)
714 return decode_op_hdr(xdr, OP_CLONE);
717 static int decode_layouterror(struct xdr_stream *xdr)
719 return decode_op_hdr(xdr, OP_LAYOUTERROR);
723 * Decode ALLOCATE request
725 static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp,
726 struct xdr_stream *xdr,
729 struct nfs42_falloc_res *res = data;
730 struct compound_hdr hdr;
733 status = decode_compound_hdr(xdr, &hdr);
736 status = decode_sequence(xdr, &res->seq_res, rqstp);
739 status = decode_putfh(xdr);
742 status = decode_allocate(xdr, res);
745 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
751 * Decode COPY response
753 static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
754 struct xdr_stream *xdr,
757 struct nfs42_copy_res *res = data;
758 struct compound_hdr hdr;
761 status = decode_compound_hdr(xdr, &hdr);
764 status = decode_sequence(xdr, &res->seq_res, rqstp);
767 status = decode_putfh(xdr);
770 status = decode_savefh(xdr);
773 status = decode_putfh(xdr);
776 status = decode_copy(xdr, res);
779 if (res->commit_res.verf)
780 status = decode_commit(xdr, &res->commit_res);
786 * Decode OFFLOAD_CANCEL response
788 static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
789 struct xdr_stream *xdr,
792 struct nfs42_offload_status_res *res = data;
793 struct compound_hdr hdr;
796 status = decode_compound_hdr(xdr, &hdr);
799 status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
802 status = decode_putfh(xdr);
805 status = decode_offload_cancel(xdr, res);
812 * Decode COPY_NOTIFY response
814 static int nfs4_xdr_dec_copy_notify(struct rpc_rqst *rqstp,
815 struct xdr_stream *xdr,
818 struct nfs42_copy_notify_res *res = data;
819 struct compound_hdr hdr;
822 status = decode_compound_hdr(xdr, &hdr);
825 status = decode_sequence(xdr, &res->cnr_seq_res, rqstp);
828 status = decode_putfh(xdr);
831 status = decode_copy_notify(xdr, res);
838 * Decode DEALLOCATE request
840 static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
841 struct xdr_stream *xdr,
844 struct nfs42_falloc_res *res = data;
845 struct compound_hdr hdr;
848 status = decode_compound_hdr(xdr, &hdr);
851 status = decode_sequence(xdr, &res->seq_res, rqstp);
854 status = decode_putfh(xdr);
857 status = decode_deallocate(xdr, res);
860 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
866 * Decode SEEK request
868 static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,
869 struct xdr_stream *xdr,
872 struct nfs42_seek_res *res = data;
873 struct compound_hdr hdr;
876 status = decode_compound_hdr(xdr, &hdr);
879 status = decode_sequence(xdr, &res->seq_res, rqstp);
882 status = decode_putfh(xdr);
885 status = decode_seek(xdr, res);
891 * Decode LAYOUTSTATS request
893 static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp,
894 struct xdr_stream *xdr,
897 struct nfs42_layoutstat_res *res = data;
898 struct compound_hdr hdr;
901 status = decode_compound_hdr(xdr, &hdr);
904 status = decode_sequence(xdr, &res->seq_res, rqstp);
907 status = decode_putfh(xdr);
910 WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
911 for (i = 0; i < res->num_dev; i++) {
912 status = decode_layoutstats(xdr);
917 res->rpc_status = status;
922 * Decode CLONE request
924 static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
925 struct xdr_stream *xdr,
928 struct nfs42_clone_res *res = data;
929 struct compound_hdr hdr;
932 status = decode_compound_hdr(xdr, &hdr);
935 status = decode_sequence(xdr, &res->seq_res, rqstp);
938 status = decode_putfh(xdr);
941 status = decode_savefh(xdr);
944 status = decode_putfh(xdr);
947 status = decode_clone(xdr);
950 status = decode_getfattr(xdr, res->dst_fattr, res->server);
953 res->rpc_status = status;
958 * Decode LAYOUTERROR request
960 static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp,
961 struct xdr_stream *xdr,
964 struct nfs42_layouterror_res *res = data;
965 struct compound_hdr hdr;
968 status = decode_compound_hdr(xdr, &hdr);
971 status = decode_sequence(xdr, &res->seq_res, rqstp);
974 status = decode_putfh(xdr);
976 for (i = 0; i < res->num_errors && status == 0; i++)
977 status = decode_layouterror(xdr);
979 res->rpc_status = status;
983 #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */