Lines Matching +full:encode +full:- +full:only

1 // SPDX-License-Identifier: GPL-2.0
61 #define READ_PLUS_SEGMENT_SIZE_DIFF (NFS42_READ_PLUS_HOLE_SEGMENT_SIZE - \
271 encode_nfs4_stateid(xdr, &args->falloc_stateid); in encode_fallocate()
272 encode_uint64(xdr, args->falloc_offset); in encode_fallocate()
273 encode_uint64(xdr, args->falloc_length); in encode_fallocate()
287 encode_uint32(xdr, ns->nl4_type); in encode_nl4_server()
288 switch (ns->nl4_type) { in encode_nl4_server()
291 encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str); in encode_nl4_server()
294 encode_string(xdr, ns->u.nl4_addr.netid_len, in encode_nl4_server()
295 ns->u.nl4_addr.netid); in encode_nl4_server()
296 encode_string(xdr, ns->u.nl4_addr.addr_len, in encode_nl4_server()
297 ns->u.nl4_addr.addr); in encode_nl4_server()
309 encode_nfs4_stateid(xdr, &args->src_stateid); in encode_copy()
310 encode_nfs4_stateid(xdr, &args->dst_stateid); in encode_copy()
312 encode_uint64(xdr, args->src_pos); in encode_copy()
313 encode_uint64(xdr, args->dst_pos); in encode_copy()
314 encode_uint64(xdr, args->count); in encode_copy()
317 encode_uint32(xdr, args->sync); in encode_copy()
318 if (args->cp_src == NULL) { /* intra-ssc */ in encode_copy()
323 encode_nl4_server(xdr, args->cp_src); in encode_copy()
334 p = xdr_encode_hyper(p, args->dst_pos); in encode_copy_commit()
335 *p = cpu_to_be32(args->count); in encode_copy_commit()
343 encode_nfs4_stateid(xdr, &args->osa_stateid); in encode_offload_cancel()
351 encode_nfs4_stateid(xdr, &args->cna_src_stateid); in encode_copy_notify()
352 encode_nl4_server(xdr, &args->cna_dst); in encode_copy_notify()
368 encode_nfs4_stateid(xdr, &args->stateid); in encode_read_plus()
369 encode_uint64(xdr, args->offset); in encode_read_plus()
370 encode_uint32(xdr, args->count); in encode_read_plus()
378 encode_nfs4_stateid(xdr, &args->sa_stateid); in encode_seek()
379 encode_uint64(xdr, args->sa_offset); in encode_seek()
380 encode_uint32(xdr, args->sa_what); in encode_seek()
392 p = xdr_encode_hyper(p, devinfo->offset); in encode_layoutstats()
393 p = xdr_encode_hyper(p, devinfo->length); in encode_layoutstats()
394 encode_nfs4_stateid(xdr, &args->stateid); in encode_layoutstats()
396 p = xdr_encode_hyper(p, devinfo->read_count); in encode_layoutstats()
397 p = xdr_encode_hyper(p, devinfo->read_bytes); in encode_layoutstats()
398 p = xdr_encode_hyper(p, devinfo->write_count); in encode_layoutstats()
399 p = xdr_encode_hyper(p, devinfo->write_bytes); in encode_layoutstats()
400 p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data, in encode_layoutstats()
402 /* Encode layoutupdate4 */ in encode_layoutstats()
403 *p++ = cpu_to_be32(devinfo->layout_type); in encode_layoutstats()
404 if (devinfo->ld_private.ops) in encode_layoutstats()
405 devinfo->ld_private.ops->encode(xdr, args, in encode_layoutstats()
406 &devinfo->ld_private); in encode_layoutstats()
418 encode_nfs4_stateid(xdr, &args->src_stateid); in encode_clone()
419 encode_nfs4_stateid(xdr, &args->dst_stateid); in encode_clone()
421 p = xdr_encode_hyper(p, args->src_offset); in encode_clone()
422 p = xdr_encode_hyper(p, args->dst_offset); in encode_clone()
423 xdr_encode_hyper(p, args->count); in encode_clone()
432 p = xdr_encode_opaque_fixed(p, error->dev_id.data, in encode_device_error()
434 *p++ = cpu_to_be32(error->status); in encode_device_error()
435 *p = cpu_to_be32(error->opnum); in encode_device_error()
446 p = xdr_encode_hyper(p, args->offset); in encode_layouterror()
447 p = xdr_encode_hyper(p, args->length); in encode_layouterror()
448 encode_nfs4_stateid(xdr, &args->stateid); in encode_layouterror()
451 encode_device_error(xdr, &args->errors[0]); in encode_layouterror()
465 *p = cpu_to_be32(arg->xattr_flags); in encode_setxattr()
466 encode_string(xdr, strlen(arg->xattr_name), arg->xattr_name); in encode_setxattr()
468 *p = cpu_to_be32(arg->xattr_len); in encode_setxattr()
469 if (arg->xattr_len) in encode_setxattr()
470 xdr_write_pages(xdr, arg->xattr_pages, 0, arg->xattr_len); in encode_setxattr()
499 p = xdr_encode_hyper(p, arg->cookie); in encode_listxattrs()
505 *p = cpu_to_be32(arg->count + 8 + 4); in encode_listxattrs()
509 * Encode ALLOCATE request
517 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_allocate()
521 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_allocate()
522 encode_putfh(xdr, args->falloc_fh, &hdr); in nfs4_xdr_enc_allocate()
524 encode_getfattr(xdr, args->falloc_bitmask, &hdr); in nfs4_xdr_enc_allocate()
529 * Encode COPY request
537 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_copy()
541 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_copy()
542 encode_putfh(xdr, args->src_fh, &hdr); in nfs4_xdr_enc_copy()
544 encode_putfh(xdr, args->dst_fh, &hdr); in nfs4_xdr_enc_copy()
546 if (args->sync) in nfs4_xdr_enc_copy()
552 * Encode OFFLOAD_CANEL request
560 .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args), in nfs4_xdr_enc_offload_cancel()
564 encode_sequence(xdr, &args->osa_seq_args, &hdr); in nfs4_xdr_enc_offload_cancel()
565 encode_putfh(xdr, args->osa_src_fh, &hdr); in nfs4_xdr_enc_offload_cancel()
571 * Encode COPY_NOTIFY request
579 .minorversion = nfs4_xdr_minorversion(&args->cna_seq_args), in nfs4_xdr_enc_copy_notify()
583 encode_sequence(xdr, &args->cna_seq_args, &hdr); in nfs4_xdr_enc_copy_notify()
584 encode_putfh(xdr, args->cna_src_fh, &hdr); in nfs4_xdr_enc_copy_notify()
590 * Encode DEALLOCATE request
598 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_deallocate()
602 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_deallocate()
603 encode_putfh(xdr, args->falloc_fh, &hdr); in nfs4_xdr_enc_deallocate()
605 encode_getfattr(xdr, args->falloc_bitmask, &hdr); in nfs4_xdr_enc_deallocate()
610 * Encode READ_PLUS request
618 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_read_plus()
622 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_read_plus()
623 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_read_plus()
626 rpc_prepare_reply_pages(req, args->pages, args->pgbase, args->count, in nfs4_xdr_enc_read_plus()
627 hdr.replen - READ_PLUS_SEGMENT_SIZE_DIFF); in nfs4_xdr_enc_read_plus()
632 * Encode SEEK request
640 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_seek()
644 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_seek()
645 encode_putfh(xdr, args->sa_fh, &hdr); in nfs4_xdr_enc_seek()
651 * Encode LAYOUTSTATS request
661 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_layoutstats()
665 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_layoutstats()
666 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_layoutstats()
667 WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV); in nfs4_xdr_enc_layoutstats()
668 for (i = 0; i < args->num_dev; i++) in nfs4_xdr_enc_layoutstats()
669 encode_layoutstats(xdr, args, &args->devinfo[i], &hdr); in nfs4_xdr_enc_layoutstats()
674 * Encode CLONE request
682 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_clone()
686 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_clone()
687 encode_putfh(xdr, args->src_fh, &hdr); in nfs4_xdr_enc_clone()
689 encode_putfh(xdr, args->dst_fh, &hdr); in nfs4_xdr_enc_clone()
691 encode_getfattr(xdr, args->dst_bitmask, &hdr); in nfs4_xdr_enc_clone()
696 * Encode LAYOUTERROR request
704 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_layouterror()
709 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_layouterror()
710 encode_putfh(xdr, NFS_FH(args->inode), &hdr); in nfs4_xdr_enc_layouterror()
711 for (i = 0; i < args->num_errors; i++) in nfs4_xdr_enc_layouterror()
712 encode_layouterror(xdr, &args->errors[i], &hdr); in nfs4_xdr_enc_layouterror()
717 * Encode SETXATTR request
724 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_setxattr()
728 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_setxattr()
729 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_setxattr()
731 encode_getfattr(xdr, args->bitmask, &hdr); in nfs4_xdr_enc_setxattr()
736 * Encode GETXATTR request
743 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_getxattr()
748 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_getxattr()
749 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_getxattr()
751 encode_getxattr(xdr, args->xattr_name, &hdr); in nfs4_xdr_enc_getxattr()
753 rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->xattr_len, in nfs4_xdr_enc_getxattr()
760 * Encode LISTXATTR request
767 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_listxattrs()
772 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_listxattrs()
773 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_listxattrs()
777 rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count, replen); in nfs4_xdr_enc_listxattrs()
783 * Encode REMOVEXATTR request
790 .minorversion = nfs4_xdr_minorversion(&args->seq_args), in nfs4_xdr_enc_removexattr()
794 encode_sequence(xdr, &args->seq_args, &hdr); in nfs4_xdr_enc_removexattr()
795 encode_putfh(xdr, args->fh, &hdr); in nfs4_xdr_enc_removexattr()
796 encode_removexattr(xdr, args->xattr_name, &hdr); in nfs4_xdr_enc_removexattr()
813 return -EIO; in decode_write_response()
816 return -EREMOTEIO; in decode_write_response()
818 status = decode_opaque_fixed(xdr, &res->stateid, in decode_write_response()
821 return -EIO; in decode_write_response()
825 return -EIO; in decode_write_response()
826 p = xdr_decode_hyper(p, &res->count); in decode_write_response()
827 res->verifier.committed = be32_to_cpup(p); in decode_write_response()
828 return decode_verifier(xdr, &res->verifier.verifier); in decode_write_response()
842 return -EIO; in decode_nl4_server()
843 ns->nl4_type = be32_to_cpup(p); in decode_nl4_server()
844 switch (ns->nl4_type) { in decode_nl4_server()
851 return -EIO; in decode_nl4_server()
852 memcpy(&ns->u.nl4_str, dummy_str, dummy); in decode_nl4_server()
853 ns->u.nl4_str_sz = dummy; in decode_nl4_server()
856 naddr = &ns->u.nl4_addr; in decode_nl4_server()
863 return -EIO; in decode_nl4_server()
864 naddr->netid_len = dummy; in decode_nl4_server()
865 memcpy(naddr->netid, dummy_str, naddr->netid_len); in decode_nl4_server()
872 return -EIO; in decode_nl4_server()
873 naddr->addr_len = dummy; in decode_nl4_server()
874 memcpy(naddr->addr, dummy_str, naddr->addr_len); in decode_nl4_server()
878 return -EIO; in decode_nl4_server()
889 return -EIO; in decode_copy_requirements()
891 res->consecutive = be32_to_cpup(p++); in decode_copy_requirements()
892 res->synchronous = be32_to_cpup(p++); in decode_copy_requirements()
909 status = decode_write_response(xdr, &res->write_res); in decode_copy()
934 return -EIO; in decode_copy_notify()
935 p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds); in decode_copy_notify()
936 res->cnr_lease_time.nseconds = be32_to_cpup(p); in decode_copy_notify()
938 status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE); in decode_copy_notify()
940 return -EIO; in decode_copy_notify()
945 return -EIO; in decode_copy_notify()
952 status = decode_nl4_server(xdr, &res->cnr_src); in decode_copy_notify()
954 return -EIO; in decode_copy_notify()
980 return seg->type == NFS4_CONTENT_DATA ? seg->data.length : seg->hole.length; in read_plus_segment_length()
990 return -EIO; in decode_read_plus_segment()
991 seg->type = be32_to_cpup(p++); in decode_read_plus_segment()
993 p = xdr_inline_decode(xdr, seg->type == NFS4_CONTENT_DATA ? 12 : 16); in decode_read_plus_segment()
995 return -EIO; in decode_read_plus_segment()
996 p = xdr_decode_hyper(p, &seg->offset); in decode_read_plus_segment()
998 if (seg->type == NFS4_CONTENT_DATA) { in decode_read_plus_segment()
1002 seg->data.length = len; in decode_read_plus_segment()
1003 seg->data.from = xdr_stream_pos(xdr); in decode_read_plus_segment()
1006 return -EIO; in decode_read_plus_segment()
1007 } else if (seg->type == NFS4_CONTENT_HOLE) { in decode_read_plus_segment()
1008 xdr_decode_hyper(p, &seg->hole.length); in decode_read_plus_segment()
1010 return -EINVAL; in decode_read_plus_segment()
1019 unsigned long offset = seg->offset; in process_read_plus_segment()
1023 if (offset + length < args->offset) in process_read_plus_segment()
1025 else if (offset > args->offset + args->count) { in process_read_plus_segment()
1026 res->eof = 0; in process_read_plus_segment()
1028 } else if (offset < args->offset) { in process_read_plus_segment()
1029 length -= (args->offset - offset); in process_read_plus_segment()
1030 offset = args->offset; in process_read_plus_segment()
1031 } else if (offset + length > args->offset + args->count) { in process_read_plus_segment()
1032 length = (args->offset + args->count) - offset; in process_read_plus_segment()
1033 res->eof = 0; in process_read_plus_segment()
1036 bufpos = xdr->buf->head[0].iov_len + (offset - args->offset); in process_read_plus_segment()
1037 if (seg->type == NFS4_CONTENT_HOLE) in process_read_plus_segment()
1040 return xdr_stream_move_subsegment(xdr, seg->data.from, bufpos, length); in process_read_plus_segment()
1047 struct nfs_pgio_args *args = &hdr->args; in decode_read_plus()
1059 return -EIO; in decode_read_plus()
1061 res->count = 0; in decode_read_plus()
1062 res->eof = be32_to_cpup(p++); in decode_read_plus()
1069 return -ENOMEM; in decode_read_plus()
1077 xdr_set_pagelen(xdr, xdr_align_size(args->count)); in decode_read_plus()
1078 for (i = segments; i > 0; i--) in decode_read_plus()
1079 res->count += process_read_plus_segment(xdr, args, res, &segs[i-1]); in decode_read_plus()
1098 return -EIO; in decode_seek()
1100 res->sr_eof = be32_to_cpup(p++); in decode_seek()
1101 p = xdr_decode_hyper(p, &res->sr_offset); in decode_seek()
1147 return -EIO; in decode_getxattr()
1152 * Only check against the page length here. The actual in decode_getxattr()
1153 * requested length may be smaller, but that is only in decode_getxattr()
1156 if (len > req->rq_rcv_buf.page_len) in decode_getxattr()
1157 return -ERANGE; in decode_getxattr()
1159 res->xattr_len = len; in decode_getxattr()
1164 return -EIO; in decode_getxattr()
1199 if (status == -ETOOSMALL) in decode_listxattrs()
1200 status = -ERANGE; in decode_listxattrs()
1203 * should be translated to success with zero-length reply. in decode_listxattrs()
1205 if (status == -ENODATA) { in decode_listxattrs()
1206 res->eof = true; in decode_listxattrs()
1214 return -EIO; in decode_listxattrs()
1216 xdr_decode_hyper(p, &res->cookie); in decode_listxattrs()
1220 return -EIO; in decode_listxattrs()
1222 left = res->xattr_len; in decode_listxattrs()
1223 buf = res->xattr_buf; in decode_listxattrs()
1229 * We have asked for enough room to encode the maximum number in decode_listxattrs()
1236 while (count--) { in decode_listxattrs()
1239 return -EIO; in decode_listxattrs()
1242 if (len > (XATTR_NAME_MAX - XATTR_USER_PREFIX_LEN)) { in decode_listxattrs()
1243 status = -ERANGE; in decode_listxattrs()
1249 return -EIO; in decode_listxattrs()
1254 status = -ERANGE; in decode_listxattrs()
1261 buf[ulen - 1] = 0; in decode_listxattrs()
1263 left -= ulen; in decode_listxattrs()
1270 return -EIO; in decode_listxattrs()
1272 res->eof = be32_to_cpup(p); in decode_listxattrs()
1273 res->copied = copied; in decode_listxattrs()
1276 if (status == -ERANGE && res->xattr_len == XATTR_LIST_MAX) in decode_listxattrs()
1277 status = -E2BIG; in decode_listxattrs()
1296 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_allocate()
1305 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server); in nfs4_xdr_dec_allocate()
1324 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_copy()
1339 if (res->commit_res.verf) in nfs4_xdr_dec_copy()
1340 status = decode_commit(xdr, &res->commit_res); in nfs4_xdr_dec_copy()
1359 status = decode_sequence(xdr, &res->osr_seq_res, rqstp); in nfs4_xdr_dec_offload_cancel()
1385 status = decode_sequence(xdr, &res->cnr_seq_res, rqstp); in nfs4_xdr_dec_copy_notify()
1411 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_deallocate()
1420 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server); in nfs4_xdr_dec_deallocate()
1436 xdr_set_scratch_buffer(xdr, res->scratch, READ_PLUS_SCRATCH_SIZE); in nfs4_xdr_dec_read_plus()
1441 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_read_plus()
1449 status = res->count; in nfs4_xdr_dec_read_plus()
1468 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_seek()
1493 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_layoutstats()
1499 WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV); in nfs4_xdr_dec_layoutstats()
1500 for (i = 0; i < res->num_dev; i++) { in nfs4_xdr_dec_layoutstats()
1506 res->rpc_status = status; in nfs4_xdr_dec_layoutstats()
1524 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_clone()
1539 decode_getfattr(xdr, res->dst_fattr, res->server); in nfs4_xdr_dec_clone()
1541 res->rpc_status = status; in nfs4_xdr_dec_clone()
1559 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_layouterror()
1564 for (i = 0; i < res->num_errors && status == 0; i++) in nfs4_xdr_dec_layouterror()
1567 res->rpc_status = status; in nfs4_xdr_dec_layouterror()
1584 status = decode_sequence(xdr, &res->seq_res, req); in nfs4_xdr_dec_setxattr()
1590 status = decode_setxattr(xdr, &res->cinfo); in nfs4_xdr_dec_setxattr()
1593 status = decode_getfattr(xdr, res->fattr, res->server); in nfs4_xdr_dec_setxattr()
1611 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_getxattr()
1632 xdr_set_scratch_page(xdr, res->scratch); in nfs4_xdr_dec_listxattrs()
1637 status = decode_sequence(xdr, &res->seq_res, rqstp); in nfs4_xdr_dec_listxattrs()
1661 status = decode_sequence(xdr, &res->seq_res, req); in nfs4_xdr_dec_removexattr()
1668 status = decode_removexattr(xdr, &res->cinfo); in nfs4_xdr_dec_removexattr()