summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2016-05-16 17:42:43 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2016-05-17 15:48:06 -0400
commit93b717fd81bf6b9a73c3702e9b079b4de8148b34 (patch)
tree0ae5ec7f5a79410e12710941fffc9725a687c6d8 /fs/nfs/nfs4xdr.c
parent9a8f6b5ea275ff01fc8ef3b8630a3d4ed6b0a362 (diff)
NFSv4: Label stateids with the type
In order to more easily distinguish what kind of stateid we are dealing with, introduce a type that can be used to label the stateid structure. The label will be useful both for debugging, but also when dealing with operations like SETATTR, READ and WRITE that can take several different types of stateid as arguments. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index d1c96fc62c51..661e753fe1c9 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4270,6 +4270,24 @@ static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4270 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); 4270 return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
4271} 4271}
4272 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) 4291static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4274{ 4292{
4275 int status; 4293 int status;
@@ -4278,7 +4296,7 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
4278 if (status != -EIO) 4296 if (status != -EIO)
4279 nfs_increment_open_seqid(status, res->seqid); 4297 nfs_increment_open_seqid(status, res->seqid);
4280 if (!status) 4298 if (!status)
4281 status = decode_stateid(xdr, &res->stateid); 4299 status = decode_open_stateid(xdr, &res->stateid);
4282 return status; 4300 return status;
4283} 4301}
4284 4302
@@ -4937,7 +4955,7 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
4937 if (status == -EIO) 4955 if (status == -EIO)
4938 goto out; 4956 goto out;
4939 if (status == 0) { 4957 if (status == 0) {
4940 status = decode_stateid(xdr, &res->stateid); 4958 status = decode_lock_stateid(xdr, &res->stateid);
4941 if (unlikely(status)) 4959 if (unlikely(status))
4942 goto out; 4960 goto out;
4943 } else if (status == -NFS4ERR_DENIED) 4961 } else if (status == -NFS4ERR_DENIED)
@@ -4966,7 +4984,7 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
4966 if (status != -EIO) 4984 if (status != -EIO)
4967 nfs_increment_lock_seqid(status, res->seqid); 4985 nfs_increment_lock_seqid(status, res->seqid);
4968 if (status == 0) 4986 if (status == 0)
4969 status = decode_stateid(xdr, &res->stateid); 4987 status = decode_lock_stateid(xdr, &res->stateid);
4970 return status; 4988 return status;
4971} 4989}
4972 4990
@@ -5016,7 +5034,7 @@ static int decode_rw_delegation(struct xdr_stream *xdr,
5016 __be32 *p; 5034 __be32 *p;
5017 int status; 5035 int status;
5018 5036
5019 status = decode_stateid(xdr, &res->delegation); 5037 status = decode_delegation_stateid(xdr, &res->delegation);
5020 if (unlikely(status)) 5038 if (unlikely(status))
5021 return status; 5039 return status;
5022 p = xdr_inline_decode(xdr, 4); 5040 p = xdr_inline_decode(xdr, 4);
@@ -5096,7 +5114,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
5096 nfs_increment_open_seqid(status, res->seqid); 5114 nfs_increment_open_seqid(status, res->seqid);
5097 if (status) 5115 if (status)
5098 return status; 5116 return status;
5099 status = decode_stateid(xdr, &res->stateid); 5117 status = decode_open_stateid(xdr, &res->stateid);
5100 if (unlikely(status)) 5118 if (unlikely(status))
5101 return status; 5119 return status;
5102 5120
@@ -5136,7 +5154,7 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
5136 if (status != -EIO) 5154 if (status != -EIO)
5137 nfs_increment_open_seqid(status, res->seqid); 5155 nfs_increment_open_seqid(status, res->seqid);
5138 if (!status) 5156 if (!status)
5139 status = decode_stateid(xdr, &res->stateid); 5157 status = decode_open_stateid(xdr, &res->stateid);
5140 return status; 5158 return status;
5141} 5159}
5142 5160
@@ -5148,7 +5166,7 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re
5148 if (status != -EIO) 5166 if (status != -EIO)
5149 nfs_increment_open_seqid(status, res->seqid); 5167 nfs_increment_open_seqid(status, res->seqid);
5150 if (!status) 5168 if (!status)
5151 status = decode_stateid(xdr, &res->stateid); 5169 status = decode_open_stateid(xdr, &res->stateid);
5152 return status; 5170 return status;
5153} 5171}
5154 5172
@@ -5838,6 +5856,12 @@ out_overflow:
5838} 5856}
5839 5857
5840#if defined(CONFIG_NFS_V4_1) 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, 5865static int decode_getdeviceinfo(struct xdr_stream *xdr,
5842 struct nfs4_getdeviceinfo_res *res) 5866 struct nfs4_getdeviceinfo_res *res)
5843{ 5867{
@@ -5919,7 +5943,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
5919 if (unlikely(!p)) 5943 if (unlikely(!p))
5920 goto out_overflow; 5944 goto out_overflow;
5921 res->return_on_close = be32_to_cpup(p); 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); 5947 p = xdr_inline_decode(xdr, 4);
5924 if (unlikely(!p)) 5948 if (unlikely(!p))
5925 goto out_overflow; 5949 goto out_overflow;
@@ -5985,7 +6009,7 @@ static int decode_layoutreturn(struct xdr_stream *xdr,
5985 goto out_overflow; 6009 goto out_overflow;
5986 res->lrs_present = be32_to_cpup(p); 6010 res->lrs_present = be32_to_cpup(p);
5987 if (res->lrs_present) 6011 if (res->lrs_present)
5988 status = decode_stateid(xdr, &res->stateid); 6012 status = decode_layout_stateid(xdr, &res->stateid);
5989 return status; 6013 return status;
5990out_overflow: 6014out_overflow:
5991 print_overflow_msg(__func__, xdr); 6015 print_overflow_msg(__func__, xdr);