nfs4xdr.c (2e72448b07dc3ff1b7593e9bfff91db182262857) nfs4xdr.c (93b717fd81bf6b9a73c3702e9b079b4de8148b34)
1/*
2 * fs/nfs/nfs4xdr.c
3 *
4 * Client-side XDR for NFSv4.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *

--- 4256 unchanged lines hidden (view full) ---

4265 return -EIO;
4266}
4267
4268static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4269{
4270 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4271}
4272
1/*
2 * fs/nfs/nfs4xdr.c
3 *
4 * Client-side XDR for NFSv4.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *

--- 4256 unchanged lines hidden (view full) ---

4265 return -EIO;
4266}
4267
4268static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4269{
4270 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4271}
4272
4273static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4274{
4275 stateid->type = NFS4_OPEN_STATEID_TYPE;
4276 return decode_stateid(xdr, stateid);
4277}
4278
4279static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4280{
4281 stateid->type = NFS4_LOCK_STATEID_TYPE;
4282 return decode_stateid(xdr, stateid);
4283}
4284
4285static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4286{
4287 stateid->type = NFS4_DELEGATION_STATEID_TYPE;
4288 return decode_stateid(xdr, stateid);
4289}
4290
4273static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4274{
4275 int status;
4276
4277 status = decode_op_hdr(xdr, OP_CLOSE);
4278 if (status != -EIO)
4279 nfs_increment_open_seqid(status, res->seqid);
4280 if (!status)
4291static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4292{
4293 int status;
4294
4295 status = decode_op_hdr(xdr, OP_CLOSE);
4296 if (status != -EIO)
4297 nfs_increment_open_seqid(status, res->seqid);
4298 if (!status)
4281 status = decode_stateid(xdr, &res->stateid);
4299 status = decode_open_stateid(xdr, &res->stateid);
4282 return status;
4283}
4284
4285static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4286{
4287 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4288}
4289

--- 642 unchanged lines hidden (view full) ---

4932static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
4933{
4934 int status;
4935
4936 status = decode_op_hdr(xdr, OP_LOCK);
4937 if (status == -EIO)
4938 goto out;
4939 if (status == 0) {
4300 return status;
4301}
4302
4303static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4304{
4305 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4306}
4307

--- 642 unchanged lines hidden (view full) ---

4950static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
4951{
4952 int status;
4953
4954 status = decode_op_hdr(xdr, OP_LOCK);
4955 if (status == -EIO)
4956 goto out;
4957 if (status == 0) {
4940 status = decode_stateid(xdr, &res->stateid);
4958 status = decode_lock_stateid(xdr, &res->stateid);
4941 if (unlikely(status))
4942 goto out;
4943 } else if (status == -NFS4ERR_DENIED)
4944 status = decode_lock_denied(xdr, NULL);
4945 if (res->open_seqid != NULL)
4946 nfs_increment_open_seqid(status, res->open_seqid);
4947 nfs_increment_lock_seqid(status, res->lock_seqid);
4948out:

--- 12 unchanged lines hidden (view full) ---

4961static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
4962{
4963 int status;
4964
4965 status = decode_op_hdr(xdr, OP_LOCKU);
4966 if (status != -EIO)
4967 nfs_increment_lock_seqid(status, res->seqid);
4968 if (status == 0)
4959 if (unlikely(status))
4960 goto out;
4961 } else if (status == -NFS4ERR_DENIED)
4962 status = decode_lock_denied(xdr, NULL);
4963 if (res->open_seqid != NULL)
4964 nfs_increment_open_seqid(status, res->open_seqid);
4965 nfs_increment_lock_seqid(status, res->lock_seqid);
4966out:

--- 12 unchanged lines hidden (view full) ---

4979static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
4980{
4981 int status;
4982
4983 status = decode_op_hdr(xdr, OP_LOCKU);
4984 if (status != -EIO)
4985 nfs_increment_lock_seqid(status, res->seqid);
4986 if (status == 0)
4969 status = decode_stateid(xdr, &res->stateid);
4987 status = decode_lock_stateid(xdr, &res->stateid);
4970 return status;
4971}
4972
4973static int decode_release_lockowner(struct xdr_stream *xdr)
4974{
4975 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
4976}
4977

--- 33 unchanged lines hidden (view full) ---

5011
5012static int decode_rw_delegation(struct xdr_stream *xdr,
5013 uint32_t delegation_type,
5014 struct nfs_openres *res)
5015{
5016 __be32 *p;
5017 int status;
5018
4988 return status;
4989}
4990
4991static int decode_release_lockowner(struct xdr_stream *xdr)
4992{
4993 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
4994}
4995

--- 33 unchanged lines hidden (view full) ---

5029
5030static int decode_rw_delegation(struct xdr_stream *xdr,
5031 uint32_t delegation_type,
5032 struct nfs_openres *res)
5033{
5034 __be32 *p;
5035 int status;
5036
5019 status = decode_stateid(xdr, &res->delegation);
5037 status = decode_delegation_stateid(xdr, &res->delegation);
5020 if (unlikely(status))
5021 return status;
5022 p = xdr_inline_decode(xdr, 4);
5023 if (unlikely(!p))
5024 goto out_overflow;
5025 res->do_recall = be32_to_cpup(p);
5026
5027 switch (delegation_type) {

--- 63 unchanged lines hidden (view full) ---

5091 uint32_t savewords, bmlen, i;
5092 int status;
5093
5094 if (!__decode_op_hdr(xdr, OP_OPEN, &status))
5095 return status;
5096 nfs_increment_open_seqid(status, res->seqid);
5097 if (status)
5098 return status;
5038 if (unlikely(status))
5039 return status;
5040 p = xdr_inline_decode(xdr, 4);
5041 if (unlikely(!p))
5042 goto out_overflow;
5043 res->do_recall = be32_to_cpup(p);
5044
5045 switch (delegation_type) {

--- 63 unchanged lines hidden (view full) ---

5109 uint32_t savewords, bmlen, i;
5110 int status;
5111
5112 if (!__decode_op_hdr(xdr, OP_OPEN, &status))
5113 return status;
5114 nfs_increment_open_seqid(status, res->seqid);
5115 if (status)
5116 return status;
5099 status = decode_stateid(xdr, &res->stateid);
5117 status = decode_open_stateid(xdr, &res->stateid);
5100 if (unlikely(status))
5101 return status;
5102
5103 decode_change_info(xdr, &res->cinfo);
5104
5105 p = xdr_inline_decode(xdr, 8);
5106 if (unlikely(!p))
5107 goto out_overflow;

--- 23 unchanged lines hidden (view full) ---

5131static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
5132{
5133 int status;
5134
5135 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
5136 if (status != -EIO)
5137 nfs_increment_open_seqid(status, res->seqid);
5138 if (!status)
5118 if (unlikely(status))
5119 return status;
5120
5121 decode_change_info(xdr, &res->cinfo);
5122
5123 p = xdr_inline_decode(xdr, 8);
5124 if (unlikely(!p))
5125 goto out_overflow;

--- 23 unchanged lines hidden (view full) ---

5149static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
5150{
5151 int status;
5152
5153 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
5154 if (status != -EIO)
5155 nfs_increment_open_seqid(status, res->seqid);
5156 if (!status)
5139 status = decode_stateid(xdr, &res->stateid);
5157 status = decode_open_stateid(xdr, &res->stateid);
5140 return status;
5141}
5142
5143static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
5144{
5145 int status;
5146
5147 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
5148 if (status != -EIO)
5149 nfs_increment_open_seqid(status, res->seqid);
5150 if (!status)
5158 return status;
5159}
5160
5161static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
5162{
5163 int status;
5164
5165 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
5166 if (status != -EIO)
5167 nfs_increment_open_seqid(status, res->seqid);
5168 if (!status)
5151 status = decode_stateid(xdr, &res->stateid);
5169 status = decode_open_stateid(xdr, &res->stateid);
5152 return status;
5153}
5154
5155static int decode_putfh(struct xdr_stream *xdr)
5156{
5157 return decode_op_hdr(xdr, OP_PUTFH);
5158}
5159

--- 673 unchanged lines hidden (view full) ---

5833 status = -EIO;
5834 goto out_err;
5835#else /* CONFIG_NFS_V4_1 */
5836 return 0;
5837#endif /* CONFIG_NFS_V4_1 */
5838}
5839
5840#if defined(CONFIG_NFS_V4_1)
5170 return status;
5171}
5172
5173static int decode_putfh(struct xdr_stream *xdr)
5174{
5175 return decode_op_hdr(xdr, OP_PUTFH);
5176}
5177

--- 673 unchanged lines hidden (view full) ---

5851 status = -EIO;
5852 goto out_err;
5853#else /* CONFIG_NFS_V4_1 */
5854 return 0;
5855#endif /* CONFIG_NFS_V4_1 */
5856}
5857
5858#if defined(CONFIG_NFS_V4_1)
5859static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
5860{
5861 stateid->type = NFS4_LAYOUT_STATEID_TYPE;
5862 return decode_stateid(xdr, stateid);
5863}
5864
5841static int decode_getdeviceinfo(struct xdr_stream *xdr,
5842 struct nfs4_getdeviceinfo_res *res)
5843{
5844 struct pnfs_device *pdev = res->pdev;
5845 __be32 *p;
5846 uint32_t len, type;
5847 int status;
5848

--- 65 unchanged lines hidden (view full) ---

5914
5915 status = decode_op_hdr(xdr, OP_LAYOUTGET);
5916 if (status)
5917 return status;
5918 p = xdr_inline_decode(xdr, 4);
5919 if (unlikely(!p))
5920 goto out_overflow;
5921 res->return_on_close = be32_to_cpup(p);
5865static int decode_getdeviceinfo(struct xdr_stream *xdr,
5866 struct nfs4_getdeviceinfo_res *res)
5867{
5868 struct pnfs_device *pdev = res->pdev;
5869 __be32 *p;
5870 uint32_t len, type;
5871 int status;
5872

--- 65 unchanged lines hidden (view full) ---

5938
5939 status = decode_op_hdr(xdr, OP_LAYOUTGET);
5940 if (status)
5941 return status;
5942 p = xdr_inline_decode(xdr, 4);
5943 if (unlikely(!p))
5944 goto out_overflow;
5945 res->return_on_close = be32_to_cpup(p);
5922 decode_stateid(xdr, &res->stateid);
5946 decode_layout_stateid(xdr, &res->stateid);
5923 p = xdr_inline_decode(xdr, 4);
5924 if (unlikely(!p))
5925 goto out_overflow;
5926 layout_count = be32_to_cpup(p);
5927 if (!layout_count) {
5928 dprintk("%s: server responded with empty layout array\n",
5929 __func__);
5930 return -EINVAL;

--- 49 unchanged lines hidden (view full) ---

5980 status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
5981 if (status)
5982 return status;
5983 p = xdr_inline_decode(xdr, 4);
5984 if (unlikely(!p))
5985 goto out_overflow;
5986 res->lrs_present = be32_to_cpup(p);
5987 if (res->lrs_present)
5947 p = xdr_inline_decode(xdr, 4);
5948 if (unlikely(!p))
5949 goto out_overflow;
5950 layout_count = be32_to_cpup(p);
5951 if (!layout_count) {
5952 dprintk("%s: server responded with empty layout array\n",
5953 __func__);
5954 return -EINVAL;

--- 49 unchanged lines hidden (view full) ---

6004 status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
6005 if (status)
6006 return status;
6007 p = xdr_inline_decode(xdr, 4);
6008 if (unlikely(!p))
6009 goto out_overflow;
6010 res->lrs_present = be32_to_cpup(p);
6011 if (res->lrs_present)
5988 status = decode_stateid(xdr, &res->stateid);
6012 status = decode_layout_stateid(xdr, &res->stateid);
5989 return status;
5990out_overflow:
5991 print_overflow_msg(__func__, xdr);
5992 return -EIO;
5993}
5994
5995static int decode_layoutcommit(struct xdr_stream *xdr,
5996 struct rpc_rqst *req,

--- 1536 unchanged lines hidden ---
6013 return status;
6014out_overflow:
6015 print_overflow_msg(__func__, xdr);
6016 return -EIO;
6017}
6018
6019static int decode_layoutcommit(struct xdr_stream *xdr,
6020 struct rpc_rqst *req,

--- 1536 unchanged lines hidden ---