aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2009-08-14 10:19:52 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-14 13:26:27 -0400
commit07d30434cfe2f1a1553143c6b20f1fe68d2ef80a (patch)
tree936996af58783a24ce8ea2f3d5c87f4f8e9854c5 /fs
parent686841b3cc3a71918b45ed148be7a01a4f10e3f8 (diff)
nfs: nfs4xdr: introduce decode_opaque_fixed and decode_stateid helpers
Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4xdr.c71
1 files changed, 40 insertions, 31 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 8255ec7079d4..86e6983ef4fa 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -3290,19 +3290,34 @@ static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
3290 return 0; 3290 return 0;
3291} 3291}
3292 3292
3293static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) 3293static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
3294{ 3294{
3295 __be32 *p; 3295 __be32 *p;
3296
3297 p = xdr_inline_decode(xdr, len);
3298 if (likely(p)) {
3299 memcpy(buf, p, len);
3300 return 0;
3301 }
3302 print_overflow_msg(__func__, xdr);
3303 return -EIO;
3304}
3305
3306static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
3307{
3308 return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);
3309}
3310
3311static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
3312{
3296 int status; 3313 int status;
3297 3314
3298 status = decode_op_hdr(xdr, OP_CLOSE); 3315 status = decode_op_hdr(xdr, OP_CLOSE);
3299 if (status != -EIO) 3316 if (status != -EIO)
3300 nfs_increment_open_seqid(status, res->seqid); 3317 nfs_increment_open_seqid(status, res->seqid);
3301 if (status) 3318 if (!status)
3302 return status; 3319 status = decode_stateid(xdr, &res->stateid);
3303 READ_BUF(NFS4_STATEID_SIZE); 3320 return status;
3304 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3305 return 0;
3306} 3321}
3307 3322
3308static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) 3323static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
@@ -3635,15 +3650,15 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
3635 3650
3636static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) 3651static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
3637{ 3652{
3638 __be32 *p;
3639 int status; 3653 int status;
3640 3654
3641 status = decode_op_hdr(xdr, OP_LOCK); 3655 status = decode_op_hdr(xdr, OP_LOCK);
3642 if (status == -EIO) 3656 if (status == -EIO)
3643 goto out; 3657 goto out;
3644 if (status == 0) { 3658 if (status == 0) {
3645 READ_BUF(NFS4_STATEID_SIZE); 3659 status = decode_stateid(xdr, &res->stateid);
3646 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE); 3660 if (unlikely(status))
3661 goto out;
3647 } else if (status == -NFS4ERR_DENIED) 3662 } else if (status == -NFS4ERR_DENIED)
3648 status = decode_lock_denied(xdr, NULL); 3663 status = decode_lock_denied(xdr, NULL);
3649 if (res->open_seqid != NULL) 3664 if (res->open_seqid != NULL)
@@ -3664,16 +3679,13 @@ static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
3664 3679
3665static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) 3680static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
3666{ 3681{
3667 __be32 *p;
3668 int status; 3682 int status;
3669 3683
3670 status = decode_op_hdr(xdr, OP_LOCKU); 3684 status = decode_op_hdr(xdr, OP_LOCKU);
3671 if (status != -EIO) 3685 if (status != -EIO)
3672 nfs_increment_lock_seqid(status, res->seqid); 3686 nfs_increment_lock_seqid(status, res->seqid);
3673 if (status == 0) { 3687 if (status == 0)
3674 READ_BUF(NFS4_STATEID_SIZE); 3688 status = decode_stateid(xdr, &res->stateid);
3675 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3676 }
3677 return status; 3689 return status;
3678} 3690}
3679 3691
@@ -3706,6 +3718,7 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3706{ 3718{
3707 __be32 *p; 3719 __be32 *p;
3708 uint32_t delegation_type; 3720 uint32_t delegation_type;
3721 int status;
3709 3722
3710 READ_BUF(4); 3723 READ_BUF(4);
3711 delegation_type = be32_to_cpup(p++); 3724 delegation_type = be32_to_cpup(p++);
@@ -3713,8 +3726,10 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3713 res->delegation_type = 0; 3726 res->delegation_type = 0;
3714 return 0; 3727 return 0;
3715 } 3728 }
3716 READ_BUF(NFS4_STATEID_SIZE+4); 3729 status = decode_stateid(xdr, &res->delegation);
3717 COPYMEM(res->delegation.data, NFS4_STATEID_SIZE); 3730 if (unlikely(status))
3731 return status;
3732 READ_BUF(4);
3718 res->do_recall = be32_to_cpup(p++); 3733 res->do_recall = be32_to_cpup(p++);
3719 3734
3720 switch (delegation_type) { 3735 switch (delegation_type) {
@@ -3738,10 +3753,10 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3738 status = decode_op_hdr(xdr, OP_OPEN); 3753 status = decode_op_hdr(xdr, OP_OPEN);
3739 if (status != -EIO) 3754 if (status != -EIO)
3740 nfs_increment_open_seqid(status, res->seqid); 3755 nfs_increment_open_seqid(status, res->seqid);
3741 if (status) 3756 if (!status)
3757 status = decode_stateid(xdr, &res->stateid);
3758 if (unlikely(status))
3742 return status; 3759 return status;
3743 READ_BUF(NFS4_STATEID_SIZE);
3744 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3745 3760
3746 decode_change_info(xdr, &res->cinfo); 3761 decode_change_info(xdr, &res->cinfo);
3747 3762
@@ -3766,32 +3781,26 @@ xdr_error:
3766 3781
3767static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) 3782static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
3768{ 3783{
3769 __be32 *p;
3770 int status; 3784 int status;
3771 3785
3772 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); 3786 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
3773 if (status != -EIO) 3787 if (status != -EIO)
3774 nfs_increment_open_seqid(status, res->seqid); 3788 nfs_increment_open_seqid(status, res->seqid);
3775 if (status) 3789 if (!status)
3776 return status; 3790 status = decode_stateid(xdr, &res->stateid);
3777 READ_BUF(NFS4_STATEID_SIZE); 3791 return status;
3778 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3779 return 0;
3780} 3792}
3781 3793
3782static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) 3794static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
3783{ 3795{
3784 __be32 *p;
3785 int status; 3796 int status;
3786 3797
3787 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); 3798 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
3788 if (status != -EIO) 3799 if (status != -EIO)
3789 nfs_increment_open_seqid(status, res->seqid); 3800 nfs_increment_open_seqid(status, res->seqid);
3790 if (status) 3801 if (!status)
3791 return status; 3802 status = decode_stateid(xdr, &res->stateid);
3792 READ_BUF(NFS4_STATEID_SIZE); 3803 return status;
3793 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3794 return 0;
3795} 3804}
3796 3805
3797static int decode_putfh(struct xdr_stream *xdr) 3806static int decode_putfh(struct xdr_stream *xdr)