1 // SPDX-License-Identifier: GPL-2.0
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 1 + /* One cnr_source_server */\
27 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
28 #define decode_copy_maxsz (op_decode_hdr_maxsz + \
29 NFS42_WRITE_RES_SIZE + \
30 1 /* cr_consecutive */ + \
31 1 /* cr_synchronous */)
32 #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
33 XDR_QUADLEN(NFS4_STATEID_SIZE))
34 #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
35 #define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \
36 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
38 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
39 #define decode_copy_notify_maxsz (op_decode_hdr_maxsz + \
40 3 + /* cnr_lease_time */\
41 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
42 1 + /* Support 1 cnr_source_server */\
44 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
45 #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
46 encode_fallocate_maxsz)
47 #define decode_deallocate_maxsz (op_decode_hdr_maxsz)
48 #define encode_seek_maxsz (op_encode_hdr_maxsz + \
49 encode_stateid_maxsz + \
52 #define decode_seek_maxsz (op_decode_hdr_maxsz + \
57 #define encode_io_info_maxsz 4
58 #define encode_layoutstats_maxsz (op_decode_hdr_maxsz + \
61 encode_stateid_maxsz + \
62 encode_io_info_maxsz + \
63 encode_io_info_maxsz + \
64 1 /* opaque devaddr4 length */ + \
65 XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
66 #define decode_layoutstats_maxsz (op_decode_hdr_maxsz)
67 #define encode_device_error_maxsz (XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
68 1 /* status */ + 1 /* opnum */)
69 #define encode_layouterror_maxsz (op_decode_hdr_maxsz + \
72 encode_stateid_maxsz + \
73 1 /* Array size */ + \
74 encode_device_error_maxsz)
75 #define decode_layouterror_maxsz (op_decode_hdr_maxsz)
76 #define encode_clone_maxsz (encode_stateid_maxsz + \
77 encode_stateid_maxsz + \
78 2 /* src offset */ + \
79 2 /* dst offset */ + \
81 #define decode_clone_maxsz (op_decode_hdr_maxsz)
83 #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
84 encode_sequence_maxsz + \
85 encode_putfh_maxsz + \
86 encode_allocate_maxsz + \
88 #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
89 decode_sequence_maxsz + \
90 decode_putfh_maxsz + \
91 decode_allocate_maxsz + \
93 #define NFS4_enc_copy_sz (compound_encode_hdr_maxsz + \
94 encode_sequence_maxsz + \
95 encode_putfh_maxsz + \
96 encode_savefh_maxsz + \
97 encode_putfh_maxsz + \
100 #define NFS4_dec_copy_sz (compound_decode_hdr_maxsz + \
101 decode_sequence_maxsz + \
102 decode_putfh_maxsz + \
103 decode_savefh_maxsz + \
104 decode_putfh_maxsz + \
105 decode_copy_maxsz + \
107 #define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \
108 encode_sequence_maxsz + \
109 encode_putfh_maxsz + \
110 encode_offload_cancel_maxsz)
111 #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \
112 decode_sequence_maxsz + \
113 decode_putfh_maxsz + \
114 decode_offload_cancel_maxsz)
115 #define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \
116 encode_putfh_maxsz + \
117 encode_copy_notify_maxsz)
118 #define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \
119 decode_putfh_maxsz + \
120 decode_copy_notify_maxsz)
121 #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
122 encode_sequence_maxsz + \
123 encode_putfh_maxsz + \
124 encode_deallocate_maxsz + \
125 encode_getattr_maxsz)
126 #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
127 decode_sequence_maxsz + \
128 decode_putfh_maxsz + \
129 decode_deallocate_maxsz + \
130 decode_getattr_maxsz)
131 #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
132 encode_sequence_maxsz + \
133 encode_putfh_maxsz + \
135 #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
136 decode_sequence_maxsz + \
137 decode_putfh_maxsz + \
139 #define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \
140 encode_sequence_maxsz + \
141 encode_putfh_maxsz + \
142 PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz)
143 #define NFS4_dec_layoutstats_sz (compound_decode_hdr_maxsz + \
144 decode_sequence_maxsz + \
145 decode_putfh_maxsz + \
146 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
147 #define NFS4_enc_layouterror_sz (compound_encode_hdr_maxsz + \
148 encode_sequence_maxsz + \
149 encode_putfh_maxsz + \
150 NFS42_LAYOUTERROR_MAX * \
151 encode_layouterror_maxsz)
152 #define NFS4_dec_layouterror_sz (compound_decode_hdr_maxsz + \
153 decode_sequence_maxsz + \
154 decode_putfh_maxsz + \
155 NFS42_LAYOUTERROR_MAX * \
156 decode_layouterror_maxsz)
157 #define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \
158 encode_sequence_maxsz + \
159 encode_putfh_maxsz + \
160 encode_savefh_maxsz + \
161 encode_putfh_maxsz + \
162 encode_clone_maxsz + \
163 encode_getattr_maxsz)
164 #define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \
165 decode_sequence_maxsz + \
166 decode_putfh_maxsz + \
167 decode_savefh_maxsz + \
168 decode_putfh_maxsz + \
169 decode_clone_maxsz + \
170 decode_getattr_maxsz)
172 static void encode_fallocate(struct xdr_stream *xdr,
173 const struct nfs42_falloc_args *args)
175 encode_nfs4_stateid(xdr, &args->falloc_stateid);
176 encode_uint64(xdr, args->falloc_offset);
177 encode_uint64(xdr, args->falloc_length);
180 static void encode_allocate(struct xdr_stream *xdr,
181 const struct nfs42_falloc_args *args,
182 struct compound_hdr *hdr)
184 encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr);
185 encode_fallocate(xdr, args);
188 static void encode_nl4_server(struct xdr_stream *xdr,
189 const struct nl4_server *ns)
191 encode_uint32(xdr, ns->nl4_type);
192 switch (ns->nl4_type) {
195 encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str);
198 encode_string(xdr, ns->u.nl4_addr.netid_len,
199 ns->u.nl4_addr.netid);
200 encode_string(xdr, ns->u.nl4_addr.addr_len,
201 ns->u.nl4_addr.addr);
208 static void encode_copy(struct xdr_stream *xdr,
209 const struct nfs42_copy_args *args,
210 struct compound_hdr *hdr)
212 encode_op_hdr(xdr, OP_COPY, decode_copy_maxsz, hdr);
213 encode_nfs4_stateid(xdr, &args->src_stateid);
214 encode_nfs4_stateid(xdr, &args->dst_stateid);
216 encode_uint64(xdr, args->src_pos);
217 encode_uint64(xdr, args->dst_pos);
218 encode_uint64(xdr, args->count);
220 encode_uint32(xdr, 1); /* consecutive = true */
221 encode_uint32(xdr, args->sync);
222 if (args->cp_src == NULL) { /* intra-ssc */
223 encode_uint32(xdr, 0); /* no src server list */
226 encode_uint32(xdr, 1); /* supporting 1 server */
227 encode_nl4_server(xdr, args->cp_src);
230 static void encode_offload_cancel(struct xdr_stream *xdr,
231 const struct nfs42_offload_status_args *args,
232 struct compound_hdr *hdr)
234 encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
235 encode_nfs4_stateid(xdr, &args->osa_stateid);
238 static void encode_copy_notify(struct xdr_stream *xdr,
239 const struct nfs42_copy_notify_args *args,
240 struct compound_hdr *hdr)
242 encode_op_hdr(xdr, OP_COPY_NOTIFY, decode_copy_notify_maxsz, hdr);
243 encode_nfs4_stateid(xdr, &args->cna_src_stateid);
244 encode_nl4_server(xdr, &args->cna_dst);
247 static void encode_deallocate(struct xdr_stream *xdr,
248 const struct nfs42_falloc_args *args,
249 struct compound_hdr *hdr)
251 encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr);
252 encode_fallocate(xdr, args);
255 static void encode_seek(struct xdr_stream *xdr,
256 const struct nfs42_seek_args *args,
257 struct compound_hdr *hdr)
259 encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr);
260 encode_nfs4_stateid(xdr, &args->sa_stateid);
261 encode_uint64(xdr, args->sa_offset);
262 encode_uint32(xdr, args->sa_what);
265 static void encode_layoutstats(struct xdr_stream *xdr,
266 const struct nfs42_layoutstat_args *args,
267 struct nfs42_layoutstat_devinfo *devinfo,
268 struct compound_hdr *hdr)
272 encode_op_hdr(xdr, OP_LAYOUTSTATS, decode_layoutstats_maxsz, hdr);
273 p = reserve_space(xdr, 8 + 8);
274 p = xdr_encode_hyper(p, devinfo->offset);
275 p = xdr_encode_hyper(p, devinfo->length);
276 encode_nfs4_stateid(xdr, &args->stateid);
277 p = reserve_space(xdr, 4*8 + NFS4_DEVICEID4_SIZE + 4);
278 p = xdr_encode_hyper(p, devinfo->read_count);
279 p = xdr_encode_hyper(p, devinfo->read_bytes);
280 p = xdr_encode_hyper(p, devinfo->write_count);
281 p = xdr_encode_hyper(p, devinfo->write_bytes);
282 p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data,
283 NFS4_DEVICEID4_SIZE);
284 /* Encode layoutupdate4 */
285 *p++ = cpu_to_be32(devinfo->layout_type);
286 if (devinfo->ld_private.ops)
287 devinfo->ld_private.ops->encode(xdr, args,
288 &devinfo->ld_private);
290 encode_uint32(xdr, 0);
293 static void encode_clone(struct xdr_stream *xdr,
294 const struct nfs42_clone_args *args,
295 struct compound_hdr *hdr)
299 encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr);
300 encode_nfs4_stateid(xdr, &args->src_stateid);
301 encode_nfs4_stateid(xdr, &args->dst_stateid);
302 p = reserve_space(xdr, 3*8);
303 p = xdr_encode_hyper(p, args->src_offset);
304 p = xdr_encode_hyper(p, args->dst_offset);
305 xdr_encode_hyper(p, args->count);
308 static void encode_device_error(struct xdr_stream *xdr,
309 const struct nfs42_device_error *error)
313 p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 2*4);
314 p = xdr_encode_opaque_fixed(p, error->dev_id.data,
315 NFS4_DEVICEID4_SIZE);
316 *p++ = cpu_to_be32(error->status);
317 *p = cpu_to_be32(error->opnum);
320 static void encode_layouterror(struct xdr_stream *xdr,
321 const struct nfs42_layout_error *args,
322 struct compound_hdr *hdr)
326 encode_op_hdr(xdr, OP_LAYOUTERROR, decode_layouterror_maxsz, hdr);
327 p = reserve_space(xdr, 8 + 8);
328 p = xdr_encode_hyper(p, args->offset);
329 p = xdr_encode_hyper(p, args->length);
330 encode_nfs4_stateid(xdr, &args->stateid);
331 p = reserve_space(xdr, 4);
333 encode_device_error(xdr, &args->errors[0]);
337 * Encode ALLOCATE request
339 static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
340 struct xdr_stream *xdr,
343 const struct nfs42_falloc_args *args = data;
344 struct compound_hdr hdr = {
345 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
348 encode_compound_hdr(xdr, req, &hdr);
349 encode_sequence(xdr, &args->seq_args, &hdr);
350 encode_putfh(xdr, args->falloc_fh, &hdr);
351 encode_allocate(xdr, args, &hdr);
352 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
356 static void encode_copy_commit(struct xdr_stream *xdr,
357 const struct nfs42_copy_args *args,
358 struct compound_hdr *hdr)
362 encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
363 p = reserve_space(xdr, 12);
364 p = xdr_encode_hyper(p, args->dst_pos);
365 *p = cpu_to_be32(args->count);
369 * Encode COPY request
371 static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
372 struct xdr_stream *xdr,
375 const struct nfs42_copy_args *args = data;
376 struct compound_hdr hdr = {
377 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
380 encode_compound_hdr(xdr, req, &hdr);
381 encode_sequence(xdr, &args->seq_args, &hdr);
382 encode_putfh(xdr, args->src_fh, &hdr);
383 encode_savefh(xdr, &hdr);
384 encode_putfh(xdr, args->dst_fh, &hdr);
385 encode_copy(xdr, args, &hdr);
387 encode_copy_commit(xdr, args, &hdr);
392 * Encode OFFLOAD_CANEL request
394 static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
395 struct xdr_stream *xdr,
398 const struct nfs42_offload_status_args *args = data;
399 struct compound_hdr hdr = {
400 .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
403 encode_compound_hdr(xdr, req, &hdr);
404 encode_sequence(xdr, &args->osa_seq_args, &hdr);
405 encode_putfh(xdr, args->osa_src_fh, &hdr);
406 encode_offload_cancel(xdr, args, &hdr);
411 * Encode COPY_NOTIFY request
413 static void nfs4_xdr_enc_copy_notify(struct rpc_rqst *req,
414 struct xdr_stream *xdr,
417 const struct nfs42_copy_notify_args *args = data;
418 struct compound_hdr hdr = {
419 .minorversion = nfs4_xdr_minorversion(&args->cna_seq_args),
422 encode_compound_hdr(xdr, req, &hdr);
423 encode_sequence(xdr, &args->cna_seq_args, &hdr);
424 encode_putfh(xdr, args->cna_src_fh, &hdr);
425 encode_copy_notify(xdr, args, &hdr);
430 * Encode DEALLOCATE request
432 static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
433 struct xdr_stream *xdr,
436 const struct nfs42_falloc_args *args = data;
437 struct compound_hdr hdr = {
438 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
441 encode_compound_hdr(xdr, req, &hdr);
442 encode_sequence(xdr, &args->seq_args, &hdr);
443 encode_putfh(xdr, args->falloc_fh, &hdr);
444 encode_deallocate(xdr, args, &hdr);
445 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
450 * Encode SEEK request
452 static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
453 struct xdr_stream *xdr,
456 const struct nfs42_seek_args *args = data;
457 struct compound_hdr hdr = {
458 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
461 encode_compound_hdr(xdr, req, &hdr);
462 encode_sequence(xdr, &args->seq_args, &hdr);
463 encode_putfh(xdr, args->sa_fh, &hdr);
464 encode_seek(xdr, args, &hdr);
469 * Encode LAYOUTSTATS request
471 static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
472 struct xdr_stream *xdr,
475 const struct nfs42_layoutstat_args *args = data;
478 struct compound_hdr hdr = {
479 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
482 encode_compound_hdr(xdr, req, &hdr);
483 encode_sequence(xdr, &args->seq_args, &hdr);
484 encode_putfh(xdr, args->fh, &hdr);
485 WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
486 for (i = 0; i < args->num_dev; i++)
487 encode_layoutstats(xdr, args, &args->devinfo[i], &hdr);
492 * Encode CLONE request
494 static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
495 struct xdr_stream *xdr,
498 const struct nfs42_clone_args *args = data;
499 struct compound_hdr hdr = {
500 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
503 encode_compound_hdr(xdr, req, &hdr);
504 encode_sequence(xdr, &args->seq_args, &hdr);
505 encode_putfh(xdr, args->src_fh, &hdr);
506 encode_savefh(xdr, &hdr);
507 encode_putfh(xdr, args->dst_fh, &hdr);
508 encode_clone(xdr, args, &hdr);
509 encode_getfattr(xdr, args->dst_bitmask, &hdr);
514 * Encode LAYOUTERROR request
516 static void nfs4_xdr_enc_layouterror(struct rpc_rqst *req,
517 struct xdr_stream *xdr,
520 const struct nfs42_layouterror_args *args = data;
521 struct compound_hdr hdr = {
522 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
526 encode_compound_hdr(xdr, req, &hdr);
527 encode_sequence(xdr, &args->seq_args, &hdr);
528 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
529 for (i = 0; i < args->num_errors; i++)
530 encode_layouterror(xdr, &args->errors[i], &hdr);
534 static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
536 return decode_op_hdr(xdr, OP_ALLOCATE);
539 static int decode_write_response(struct xdr_stream *xdr,
540 struct nfs42_write_res *res)
545 p = xdr_inline_decode(xdr, 4);
548 count = be32_to_cpup(p);
551 else if (count == 1) {
552 status = decode_opaque_fixed(xdr, &res->stateid,
554 if (unlikely(status))
557 p = xdr_inline_decode(xdr, 8 + 4);
560 p = xdr_decode_hyper(p, &res->count);
561 res->verifier.committed = be32_to_cpup(p);
562 return decode_verifier(xdr, &res->verifier.verifier);
565 static int decode_nl4_server(struct xdr_stream *xdr, struct nl4_server *ns)
567 struct nfs42_netaddr *naddr;
574 p = xdr_inline_decode(xdr, 4);
577 ns->nl4_type = be32_to_cpup(p);
578 switch (ns->nl4_type) {
581 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
582 if (unlikely(status))
584 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
586 memcpy(&ns->u.nl4_str, dummy_str, dummy);
587 ns->u.nl4_str_sz = dummy;
590 naddr = &ns->u.nl4_addr;
593 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
594 if (unlikely(status))
596 if (unlikely(dummy > RPCBIND_MAXNETIDLEN))
598 naddr->netid_len = dummy;
599 memcpy(naddr->netid, dummy_str, naddr->netid_len);
602 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
603 if (unlikely(status))
605 if (unlikely(dummy > RPCBIND_MAXUADDRLEN))
607 naddr->addr_len = dummy;
608 memcpy(naddr->addr, dummy_str, naddr->addr_len);
617 static int decode_copy_requirements(struct xdr_stream *xdr,
618 struct nfs42_copy_res *res) {
621 p = xdr_inline_decode(xdr, 4 + 4);
625 res->consecutive = be32_to_cpup(p++);
626 res->synchronous = be32_to_cpup(p++);
630 static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
634 status = decode_op_hdr(xdr, OP_COPY);
635 if (status == NFS4ERR_OFFLOAD_NO_REQS) {
636 status = decode_copy_requirements(xdr, res);
639 return NFS4ERR_OFFLOAD_NO_REQS;
643 status = decode_write_response(xdr, &res->write_res);
647 return decode_copy_requirements(xdr, res);
650 static int decode_offload_cancel(struct xdr_stream *xdr,
651 struct nfs42_offload_status_res *res)
653 return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
656 static int decode_copy_notify(struct xdr_stream *xdr,
657 struct nfs42_copy_notify_res *res)
662 status = decode_op_hdr(xdr, OP_COPY_NOTIFY);
666 p = xdr_inline_decode(xdr, 12);
669 p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds);
670 res->cnr_lease_time.nseconds = be32_to_cpup(p);
672 status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE);
673 if (unlikely(status))
676 /* number of source addresses */
677 p = xdr_inline_decode(xdr, 4);
681 count = be32_to_cpup(p);
683 pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n",
686 status = decode_nl4_server(xdr, &res->cnr_src);
687 if (unlikely(status))
692 static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
694 return decode_op_hdr(xdr, OP_DEALLOCATE);
697 static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
702 status = decode_op_hdr(xdr, OP_SEEK);
706 p = xdr_inline_decode(xdr, 4 + 8);
710 res->sr_eof = be32_to_cpup(p++);
711 p = xdr_decode_hyper(p, &res->sr_offset);
715 static int decode_layoutstats(struct xdr_stream *xdr)
717 return decode_op_hdr(xdr, OP_LAYOUTSTATS);
720 static int decode_clone(struct xdr_stream *xdr)
722 return decode_op_hdr(xdr, OP_CLONE);
725 static int decode_layouterror(struct xdr_stream *xdr)
727 return decode_op_hdr(xdr, OP_LAYOUTERROR);
731 * Decode ALLOCATE request
733 static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp,
734 struct xdr_stream *xdr,
737 struct nfs42_falloc_res *res = data;
738 struct compound_hdr hdr;
741 status = decode_compound_hdr(xdr, &hdr);
744 status = decode_sequence(xdr, &res->seq_res, rqstp);
747 status = decode_putfh(xdr);
750 status = decode_allocate(xdr, res);
753 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
759 * Decode COPY response
761 static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
762 struct xdr_stream *xdr,
765 struct nfs42_copy_res *res = data;
766 struct compound_hdr hdr;
769 status = decode_compound_hdr(xdr, &hdr);
772 status = decode_sequence(xdr, &res->seq_res, rqstp);
775 status = decode_putfh(xdr);
778 status = decode_savefh(xdr);
781 status = decode_putfh(xdr);
784 status = decode_copy(xdr, res);
787 if (res->commit_res.verf)
788 status = decode_commit(xdr, &res->commit_res);
794 * Decode OFFLOAD_CANCEL response
796 static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
797 struct xdr_stream *xdr,
800 struct nfs42_offload_status_res *res = data;
801 struct compound_hdr hdr;
804 status = decode_compound_hdr(xdr, &hdr);
807 status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
810 status = decode_putfh(xdr);
813 status = decode_offload_cancel(xdr, res);
820 * Decode COPY_NOTIFY response
822 static int nfs4_xdr_dec_copy_notify(struct rpc_rqst *rqstp,
823 struct xdr_stream *xdr,
826 struct nfs42_copy_notify_res *res = data;
827 struct compound_hdr hdr;
830 status = decode_compound_hdr(xdr, &hdr);
833 status = decode_sequence(xdr, &res->cnr_seq_res, rqstp);
836 status = decode_putfh(xdr);
839 status = decode_copy_notify(xdr, res);
846 * Decode DEALLOCATE request
848 static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
849 struct xdr_stream *xdr,
852 struct nfs42_falloc_res *res = data;
853 struct compound_hdr hdr;
856 status = decode_compound_hdr(xdr, &hdr);
859 status = decode_sequence(xdr, &res->seq_res, rqstp);
862 status = decode_putfh(xdr);
865 status = decode_deallocate(xdr, res);
868 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
874 * Decode SEEK request
876 static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,
877 struct xdr_stream *xdr,
880 struct nfs42_seek_res *res = data;
881 struct compound_hdr hdr;
884 status = decode_compound_hdr(xdr, &hdr);
887 status = decode_sequence(xdr, &res->seq_res, rqstp);
890 status = decode_putfh(xdr);
893 status = decode_seek(xdr, res);
899 * Decode LAYOUTSTATS request
901 static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp,
902 struct xdr_stream *xdr,
905 struct nfs42_layoutstat_res *res = data;
906 struct compound_hdr hdr;
909 status = decode_compound_hdr(xdr, &hdr);
912 status = decode_sequence(xdr, &res->seq_res, rqstp);
915 status = decode_putfh(xdr);
918 WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
919 for (i = 0; i < res->num_dev; i++) {
920 status = decode_layoutstats(xdr);
925 res->rpc_status = status;
930 * Decode CLONE request
932 static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
933 struct xdr_stream *xdr,
936 struct nfs42_clone_res *res = data;
937 struct compound_hdr hdr;
940 status = decode_compound_hdr(xdr, &hdr);
943 status = decode_sequence(xdr, &res->seq_res, rqstp);
946 status = decode_putfh(xdr);
949 status = decode_savefh(xdr);
952 status = decode_putfh(xdr);
955 status = decode_clone(xdr);
958 status = decode_getfattr(xdr, res->dst_fattr, res->server);
961 res->rpc_status = status;
966 * Decode LAYOUTERROR request
968 static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp,
969 struct xdr_stream *xdr,
972 struct nfs42_layouterror_res *res = data;
973 struct compound_hdr hdr;
976 status = decode_compound_hdr(xdr, &hdr);
979 status = decode_sequence(xdr, &res->seq_res, rqstp);
982 status = decode_putfh(xdr);
984 for (i = 0; i < res->num_errors && status == 0; i++)
985 status = decode_layouterror(xdr);
987 res->rpc_status = status;
991 #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */