Commit e2f282b9 authored by Benny Halevy's avatar Benny Halevy Committed by J. Bruce Fields

nfsd: nfs4xdr encode_stateid helper function

Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 5033b77a
...@@ -1950,6 +1950,17 @@ fail: ...@@ -1950,6 +1950,17 @@ fail:
return -EINVAL; return -EINVAL;
} }
static void
nfsd4_encode_stateid(struct nfsd4_compoundres *resp, stateid_t *sid)
{
ENCODE_HEAD;
RESERVE_SPACE(sizeof(stateid_t));
WRITE32(sid->si_generation);
WRITEMEM(&sid->si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
}
static __be32 static __be32
nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access) nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access)
{ {
...@@ -1969,12 +1980,9 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c ...@@ -1969,12 +1980,9 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c
{ {
ENCODE_SEQID_OP_HEAD; ENCODE_SEQID_OP_HEAD;
if (!nfserr) { if (!nfserr)
RESERVE_SPACE(sizeof(stateid_t)); nfsd4_encode_stateid(resp, &close->cl_stateid);
WRITE32(close->cl_stateid.si_generation);
WRITEMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
}
ENCODE_SEQID_OP_TAIL(close->cl_stateowner); ENCODE_SEQID_OP_TAIL(close->cl_stateowner);
return nfserr; return nfserr;
} }
...@@ -2074,12 +2082,9 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo ...@@ -2074,12 +2082,9 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo
{ {
ENCODE_SEQID_OP_HEAD; ENCODE_SEQID_OP_HEAD;
if (!nfserr) { if (!nfserr)
RESERVE_SPACE(4 + sizeof(stateid_t)); nfsd4_encode_stateid(resp, &lock->lk_resp_stateid);
WRITE32(lock->lk_resp_stateid.si_generation); else if (nfserr == nfserr_denied)
WRITEMEM(&lock->lk_resp_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
} else if (nfserr == nfserr_denied)
nfsd4_encode_lock_denied(resp, &lock->lk_denied); nfsd4_encode_lock_denied(resp, &lock->lk_denied);
ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner); ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner);
...@@ -2099,13 +2104,9 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l ...@@ -2099,13 +2104,9 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l
{ {
ENCODE_SEQID_OP_HEAD; ENCODE_SEQID_OP_HEAD;
if (!nfserr) { if (!nfserr)
RESERVE_SPACE(sizeof(stateid_t)); nfsd4_encode_stateid(resp, &locku->lu_stateid);
WRITE32(locku->lu_stateid.si_generation);
WRITEMEM(&locku->lu_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
}
ENCODE_SEQID_OP_TAIL(locku->lu_stateowner); ENCODE_SEQID_OP_TAIL(locku->lu_stateowner);
return nfserr; return nfserr;
} }
...@@ -2133,9 +2134,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -2133,9 +2134,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
if (nfserr) if (nfserr)
goto out; goto out;
RESERVE_SPACE(40 + sizeof(stateid_t)); nfsd4_encode_stateid(resp, &open->op_stateid);
WRITE32(open->op_stateid.si_generation); RESERVE_SPACE(40);
WRITEMEM(&open->op_stateid.si_opaque, sizeof(stateid_opaque_t));
WRITECINFO(open->op_cinfo); WRITECINFO(open->op_cinfo);
WRITE32(open->op_rflags); WRITE32(open->op_rflags);
WRITE32(2); WRITE32(2);
...@@ -2148,10 +2148,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -2148,10 +2148,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
case NFS4_OPEN_DELEGATE_NONE: case NFS4_OPEN_DELEGATE_NONE:
break; break;
case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_READ:
RESERVE_SPACE(20 + sizeof(stateid_t)); nfsd4_encode_stateid(resp, &open->op_delegate_stateid);
WRITE32(open->op_delegate_stateid.si_generation); RESERVE_SPACE(20);
WRITEMEM(&open->op_delegate_stateid.si_opaque,
sizeof(stateid_opaque_t));
WRITE32(open->op_recall); WRITE32(open->op_recall);
/* /*
...@@ -2164,10 +2162,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -2164,10 +2162,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
ADJUST_ARGS(); ADJUST_ARGS();
break; break;
case NFS4_OPEN_DELEGATE_WRITE: case NFS4_OPEN_DELEGATE_WRITE:
RESERVE_SPACE(32 + sizeof(stateid_t)); nfsd4_encode_stateid(resp, &open->op_delegate_stateid);
WRITE32(open->op_delegate_stateid.si_generation); RESERVE_SPACE(32);
WRITEMEM(&open->op_delegate_stateid.si_opaque,
sizeof(stateid_opaque_t));
WRITE32(0); WRITE32(0);
/* /*
...@@ -2199,13 +2195,9 @@ static __be32 ...@@ -2199,13 +2195,9 @@ static __be32
nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc) nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc)
{ {
ENCODE_SEQID_OP_HEAD; ENCODE_SEQID_OP_HEAD;
if (!nfserr) { if (!nfserr)
RESERVE_SPACE(sizeof(stateid_t)); nfsd4_encode_stateid(resp, &oc->oc_resp_stateid);
WRITE32(oc->oc_resp_stateid.si_generation);
WRITEMEM(&oc->oc_resp_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
}
ENCODE_SEQID_OP_TAIL(oc->oc_stateowner); ENCODE_SEQID_OP_TAIL(oc->oc_stateowner);
return nfserr; return nfserr;
...@@ -2215,13 +2207,9 @@ static __be32 ...@@ -2215,13 +2207,9 @@ static __be32
nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od) nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od)
{ {
ENCODE_SEQID_OP_HEAD; ENCODE_SEQID_OP_HEAD;
if (!nfserr) { if (!nfserr)
RESERVE_SPACE(sizeof(stateid_t)); nfsd4_encode_stateid(resp, &od->od_stateid);
WRITE32(od->od_stateid.si_generation);
WRITEMEM(&od->od_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS();
}
ENCODE_SEQID_OP_TAIL(od->od_stateowner); ENCODE_SEQID_OP_TAIL(od->od_stateowner);
return nfserr; return nfserr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment