aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs2xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:59:18 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:25 -0500
commit9f06c719f474be7003763284a990bed6377bb0d4 (patch)
tree409ebc3505f943bfdb933ab0acd76ffb5347b372 /fs/nfs/nfs2xdr.c
parent1ac7c23e4af5e83525137661595000099f1ce94f (diff)
SUNRPC: New xdr_streams XDR encoder API
Now that all client-side XDR encoder routines use xdr_streams, there should be no need to support the legacy calling sequence [rpc_rqst *, __be32 *, RPC arg *] anywhere. We can construct an xdr_stream in the generic RPC code, instead of in each encoder function. Also, all the client-side encoder functions return 0 now, making a return value superfluous. Take this opportunity to convert them to return void instead. This is a refactoring change. It should not cause different behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs2xdr.c')
-rw-r--r--fs/nfs/nfs2xdr.c147
1 files changed, 56 insertions, 91 deletions
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index a9b848edbd2e..8f3acbec761f 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -558,14 +558,11 @@ out_default:
558 * "NFS: Network File System Protocol Specification". 558 * "NFS: Network File System Protocol Specification".
559 */ 559 */
560 560
561static int nfs2_xdr_enc_fhandle(struct rpc_rqst *req, __be32 *p, 561static void nfs2_xdr_enc_fhandle(struct rpc_rqst *req,
562 const struct nfs_fh *fh) 562 struct xdr_stream *xdr,
563 const struct nfs_fh *fh)
563{ 564{
564 struct xdr_stream xdr; 565 encode_fhandle(xdr, fh);
565
566 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
567 encode_fhandle(&xdr, fh);
568 return 0;
569} 566}
570 567
571/* 568/*
@@ -576,37 +573,28 @@ static int nfs2_xdr_enc_fhandle(struct rpc_rqst *req, __be32 *p,
576 * sattr attributes; 573 * sattr attributes;
577 * }; 574 * };
578 */ 575 */
579static int nfs2_xdr_enc_sattrargs(struct rpc_rqst *req, __be32 *p, 576static void nfs2_xdr_enc_sattrargs(struct rpc_rqst *req,
580 const struct nfs_sattrargs *args) 577 struct xdr_stream *xdr,
578 const struct nfs_sattrargs *args)
581{ 579{
582 struct xdr_stream xdr; 580 encode_fhandle(xdr, args->fh);
583 581 encode_sattr(xdr, args->sattr);
584 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
585 encode_fhandle(&xdr, args->fh);
586 encode_sattr(&xdr, args->sattr);
587 return 0;
588} 582}
589 583
590static int nfs2_xdr_enc_diropargs(struct rpc_rqst *req, __be32 *p, 584static void nfs2_xdr_enc_diropargs(struct rpc_rqst *req,
591 const struct nfs_diropargs *args) 585 struct xdr_stream *xdr,
586 const struct nfs_diropargs *args)
592{ 587{
593 struct xdr_stream xdr; 588 encode_diropargs(xdr, args->fh, args->name, args->len);
594
595 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
596 encode_diropargs(&xdr, args->fh, args->name, args->len);
597 return 0;
598} 589}
599 590
600static int nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req, __be32 *p, 591static void nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req,
601 const struct nfs_readlinkargs *args) 592 struct xdr_stream *xdr,
593 const struct nfs_readlinkargs *args)
602{ 594{
603 struct xdr_stream xdr; 595 encode_fhandle(xdr, args->fh);
604
605 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
606 encode_fhandle(&xdr, args->fh);
607 prepare_reply_buffer(req, args->pages, args->pgbase, 596 prepare_reply_buffer(req, args->pages, args->pgbase,
608 args->pglen, NFS_readlinkres_sz); 597 args->pglen, NFS_readlinkres_sz);
609 return 0;
610} 598}
611 599
612/* 600/*
@@ -634,17 +622,14 @@ static void encode_readargs(struct xdr_stream *xdr,
634 *p = cpu_to_be32(count); 622 *p = cpu_to_be32(count);
635} 623}
636 624
637static int nfs2_xdr_enc_readargs(struct rpc_rqst *req, __be32 *p, 625static void nfs2_xdr_enc_readargs(struct rpc_rqst *req,
638 const struct nfs_readargs *args) 626 struct xdr_stream *xdr,
627 const struct nfs_readargs *args)
639{ 628{
640 struct xdr_stream xdr; 629 encode_readargs(xdr, args);
641
642 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
643 encode_readargs(&xdr, args);
644 prepare_reply_buffer(req, args->pages, args->pgbase, 630 prepare_reply_buffer(req, args->pages, args->pgbase,
645 args->count, NFS_readres_sz); 631 args->count, NFS_readres_sz);
646 req->rq_rcv_buf.flags |= XDRBUF_READ; 632 req->rq_rcv_buf.flags |= XDRBUF_READ;
647 return 0;
648} 633}
649 634
650/* 635/*
@@ -677,15 +662,12 @@ static void encode_writeargs(struct xdr_stream *xdr,
677 xdr_write_pages(xdr, args->pages, args->pgbase, count); 662 xdr_write_pages(xdr, args->pages, args->pgbase, count);
678} 663}
679 664
680static int nfs2_xdr_enc_writeargs(struct rpc_rqst *req, __be32 *p, 665static void nfs2_xdr_enc_writeargs(struct rpc_rqst *req,
681 const struct nfs_writeargs *args) 666 struct xdr_stream *xdr,
667 const struct nfs_writeargs *args)
682{ 668{
683 struct xdr_stream xdr; 669 encode_writeargs(xdr, args);
684 670 xdr->buf->flags |= XDRBUF_WRITE;
685 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
686 encode_writeargs(&xdr, args);
687 xdr.buf->flags |= XDRBUF_WRITE;
688 return 0;
689} 671}
690 672
691/* 673/*
@@ -696,25 +678,19 @@ static int nfs2_xdr_enc_writeargs(struct rpc_rqst *req, __be32 *p,
696 * sattr attributes; 678 * sattr attributes;
697 * }; 679 * };
698 */ 680 */
699static int nfs2_xdr_enc_createargs(struct rpc_rqst *req, __be32 *p, 681static void nfs2_xdr_enc_createargs(struct rpc_rqst *req,
700 const struct nfs_createargs *args) 682 struct xdr_stream *xdr,
683 const struct nfs_createargs *args)
701{ 684{
702 struct xdr_stream xdr; 685 encode_diropargs(xdr, args->fh, args->name, args->len);
703 686 encode_sattr(xdr, args->sattr);
704 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
705 encode_diropargs(&xdr, args->fh, args->name, args->len);
706 encode_sattr(&xdr, args->sattr);
707 return 0;
708} 687}
709 688
710static int nfs2_xdr_enc_removeargs(struct rpc_rqst *req, __be32 *p, 689static void nfs2_xdr_enc_removeargs(struct rpc_rqst *req,
711 const struct nfs_removeargs *args) 690 struct xdr_stream *xdr,
691 const struct nfs_removeargs *args)
712{ 692{
713 struct xdr_stream xdr; 693 encode_diropargs(xdr, args->fh, args->name.name, args->name.len);
714
715 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
716 encode_diropargs(&xdr, args->fh, args->name.name, args->name.len);
717 return 0;
718} 694}
719 695
720/* 696/*
@@ -725,17 +701,15 @@ static int nfs2_xdr_enc_removeargs(struct rpc_rqst *req, __be32 *p,
725 * diropargs to; 701 * diropargs to;
726 * }; 702 * };
727 */ 703 */
728static int nfs2_xdr_enc_renameargs(struct rpc_rqst *req, __be32 *p, 704static void nfs2_xdr_enc_renameargs(struct rpc_rqst *req,
729 const struct nfs_renameargs *args) 705 struct xdr_stream *xdr,
706 const struct nfs_renameargs *args)
730{ 707{
731 const struct qstr *old = args->old_name; 708 const struct qstr *old = args->old_name;
732 const struct qstr *new = args->new_name; 709 const struct qstr *new = args->new_name;
733 struct xdr_stream xdr;
734 710
735 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 711 encode_diropargs(xdr, args->old_dir, old->name, old->len);
736 encode_diropargs(&xdr, args->old_dir, old->name, old->len); 712 encode_diropargs(xdr, args->new_dir, new->name, new->len);
737 encode_diropargs(&xdr, args->new_dir, new->name, new->len);
738 return 0;
739} 713}
740 714
741/* 715/*
@@ -746,15 +720,12 @@ static int nfs2_xdr_enc_renameargs(struct rpc_rqst *req, __be32 *p,
746 * diropargs to; 720 * diropargs to;
747 * }; 721 * };
748 */ 722 */
749static int nfs2_xdr_enc_linkargs(struct rpc_rqst *req, __be32 *p, 723static void nfs2_xdr_enc_linkargs(struct rpc_rqst *req,
750 const struct nfs_linkargs *args) 724 struct xdr_stream *xdr,
725 const struct nfs_linkargs *args)
751{ 726{
752 struct xdr_stream xdr; 727 encode_fhandle(xdr, args->fromfh);
753 728 encode_diropargs(xdr, args->tofh, args->toname, args->tolen);
754 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
755 encode_fhandle(&xdr, args->fromfh);
756 encode_diropargs(&xdr, args->tofh, args->toname, args->tolen);
757 return 0;
758} 729}
759 730
760/* 731/*
@@ -766,16 +737,13 @@ static int nfs2_xdr_enc_linkargs(struct rpc_rqst *req, __be32 *p,
766 * sattr attributes; 737 * sattr attributes;
767 * }; 738 * };
768 */ 739 */
769static int nfs2_xdr_enc_symlinkargs(struct rpc_rqst *req, __be32 *p, 740static void nfs2_xdr_enc_symlinkargs(struct rpc_rqst *req,
770 const struct nfs_symlinkargs *args) 741 struct xdr_stream *xdr,
742 const struct nfs_symlinkargs *args)
771{ 743{
772 struct xdr_stream xdr; 744 encode_diropargs(xdr, args->fromfh, args->fromname, args->fromlen);
773 745 encode_path(xdr, args->pages, args->pathlen);
774 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 746 encode_sattr(xdr, args->sattr);
775 encode_diropargs(&xdr, args->fromfh, args->fromname, args->fromlen);
776 encode_path(&xdr, args->pages, args->pathlen);
777 encode_sattr(&xdr, args->sattr);
778 return 0;
779} 747}
780 748
781/* 749/*
@@ -799,16 +767,13 @@ static void encode_readdirargs(struct xdr_stream *xdr,
799 *p = cpu_to_be32(args->count); 767 *p = cpu_to_be32(args->count);
800} 768}
801 769
802static int nfs2_xdr_enc_readdirargs(struct rpc_rqst *req, __be32 *p, 770static void nfs2_xdr_enc_readdirargs(struct rpc_rqst *req,
803 const struct nfs_readdirargs *args) 771 struct xdr_stream *xdr,
772 const struct nfs_readdirargs *args)
804{ 773{
805 struct xdr_stream xdr; 774 encode_readdirargs(xdr, args);
806
807 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
808 encode_readdirargs(&xdr, args);
809 prepare_reply_buffer(req, args->pages, 0, 775 prepare_reply_buffer(req, args->pages, 0,
810 args->count, NFS_readdirres_sz); 776 args->count, NFS_readdirres_sz);
811 return 0;
812} 777}
813 778
814/* 779/*
@@ -1184,7 +1149,7 @@ int nfs_stat_to_errno(enum nfs_stat status)
1184#define PROC(proc, argtype, restype, timer) \ 1149#define PROC(proc, argtype, restype, timer) \
1185[NFSPROC_##proc] = { \ 1150[NFSPROC_##proc] = { \
1186 .p_proc = NFSPROC_##proc, \ 1151 .p_proc = NFSPROC_##proc, \
1187 .p_encode = (kxdrproc_t)nfs2_xdr_enc_##argtype, \ 1152 .p_encode = (kxdreproc_t)nfs2_xdr_enc_##argtype, \
1188 .p_decode = (kxdrproc_t)nfs2_xdr_dec_##restype, \ 1153 .p_decode = (kxdrproc_t)nfs2_xdr_dec_##restype, \
1189 .p_arglen = NFS_##argtype##_sz, \ 1154 .p_arglen = NFS_##argtype##_sz, \
1190 .p_replen = NFS_##restype##_sz, \ 1155 .p_replen = NFS_##restype##_sz, \