Skip to content

Commit

Permalink
SUNRPC: New xdr_streams XDR decoder API
Browse files Browse the repository at this point in the history
Now that all client-side XDR decoder routines use xdr_streams, there
should be no need to support the legacy calling sequence [rpc_rqst *,
__be32 *, RPC res *] anywhere.  We can construct an xdr_stream in the
generic RPC code, instead of in each decoder function.

This is a refactoring change.  It should not cause different behavior.

Signed-off-by: Chuck Lever <[email protected]>
Tested-by: J. Bruce Fields <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
chucklever authored and Trond Myklebust committed Dec 16, 2010
1 parent 9f06c71 commit bf26955
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 566 deletions.
20 changes: 9 additions & 11 deletions fs/lockd/clnt4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,16 @@ static int decode_nlm4_testrply(struct xdr_stream *xdr,
return error;
}

static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
static int nlm4_xdr_dec_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result)
{
struct xdr_stream xdr;
int error;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
error = decode_cookie(&xdr, &result->cookie);
error = decode_cookie(xdr, &result->cookie);
if (unlikely(error))
goto out;
error = decode_nlm4_testrply(&xdr, result);
error = decode_nlm4_testrply(xdr, result);
out:
return error;
}
Expand All @@ -550,17 +549,16 @@ static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
* nlm4_stat stat;
* };
*/
static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
static int nlm4_xdr_dec_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result)
{
struct xdr_stream xdr;
int error;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
error = decode_cookie(&xdr, &result->cookie);
error = decode_cookie(xdr, &result->cookie);
if (unlikely(error))
goto out;
error = decode_nlm4_stat(&xdr, &result->status);
error = decode_nlm4_stat(xdr, &result->status);
out:
return error;
}
Expand All @@ -575,7 +573,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \
.p_decode = (kxdrdproc_t)nlm4_xdr_dec_##restype, \
.p_arglen = NLM4_##argtype##_sz, \
.p_replen = NLM4_##restype##_sz, \
.p_statidx = NLMPROC_##proc, \
Expand Down
20 changes: 9 additions & 11 deletions fs/lockd/clntxdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,16 @@ static int decode_nlm_testrply(struct xdr_stream *xdr,
return error;
}

static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
static int nlm_xdr_dec_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result)
{
struct xdr_stream xdr;
int error;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
error = decode_cookie(&xdr, &result->cookie);
error = decode_cookie(xdr, &result->cookie);
if (unlikely(error))
goto out;
error = decode_nlm_testrply(&xdr, result);
error = decode_nlm_testrply(xdr, result);
out:
return error;
}
Expand All @@ -548,17 +547,16 @@ static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p,
* nlm_stat stat;
* };
*/
static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
static int nlm_xdr_dec_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct nlm_res *result)
{
struct xdr_stream xdr;
int error;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
error = decode_cookie(&xdr, &result->cookie);
error = decode_cookie(xdr, &result->cookie);
if (unlikely(error))
goto out;
error = decode_nlm_stat(&xdr, &result->status);
error = decode_nlm_stat(xdr, &result->status);
out:
return error;
}
Expand All @@ -573,7 +571,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p,
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm_xdr_dec_##restype, \
.p_decode = (kxdrdproc_t)nlm_xdr_dec_##restype, \
.p_arglen = NLM_##argtype##_sz, \
.p_replen = NLM_##restype##_sz, \
.p_statidx = NLMPROC_##proc, \
Expand Down
30 changes: 15 additions & 15 deletions fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,35 +472,35 @@ static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr,
encode_mon_id(xdr, argp);
}

static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p,
struct nsm_res *resp)
static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp,
struct xdr_stream *xdr,
struct nsm_res *resp)
{
struct xdr_stream xdr;
__be32 *p;

xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
p = xdr_inline_decode(&xdr, 4 + 4);
p = xdr_inline_decode(xdr, 4 + 4);
if (unlikely(p == NULL))
return -EIO;
resp->status = be32_to_cpup(p++);
resp->state = be32_to_cpup(p);

dprintk("lockd: xdr_dec_stat_res status %d state %d\n",
resp->status, resp->state);
dprintk("lockd: %s status %d state %d\n",
__func__, resp->status, resp->state);
return 0;
}

static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p,
struct nsm_res *resp)
static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp,
struct xdr_stream *xdr,
struct nsm_res *resp)
{
struct xdr_stream xdr;
__be32 *p;

xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
p = xdr_inline_decode(&xdr, 4);
p = xdr_inline_decode(xdr, 4);
if (unlikely(p == NULL))
return -EIO;
resp->state = be32_to_cpup(p);

dprintk("lockd: xdr_dec_stat state %d\n", resp->state);
dprintk("lockd: %s state %d\n", __func__, resp->state);
return 0;
}

Expand All @@ -517,7 +517,7 @@ static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_MON] = {
.p_proc = NSMPROC_MON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_mon,
.p_decode = (kxdrproc_t)xdr_dec_stat_res,
.p_decode = (kxdrdproc_t)nsm_xdr_dec_stat_res,
.p_arglen = SM_mon_sz,
.p_replen = SM_monres_sz,
.p_statidx = NSMPROC_MON,
Expand All @@ -526,7 +526,7 @@ static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_UNMON] = {
.p_proc = NSMPROC_UNMON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_unmon,
.p_decode = (kxdrproc_t)xdr_dec_stat,
.p_decode = (kxdrdproc_t)nsm_xdr_dec_stat,
.p_arglen = SM_mon_id_sz,
.p_replen = SM_unmonres_sz,
.p_statidx = NSMPROC_UNMON,
Expand Down
30 changes: 13 additions & 17 deletions fs/nfs/mount_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,16 @@ static int decode_fhandle(struct xdr_stream *xdr, struct mountres *res)
return 0;
}

static int mnt_dec_mountres(struct rpc_rqst *req, __be32 *p,
struct mountres *res)
static int mnt_xdr_dec_mountres(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct mountres *res)
{
struct xdr_stream xdr;
int status;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);

status = decode_status(&xdr, res);
status = decode_status(xdr, res);
if (unlikely(status != 0 || res->errno != 0))
return status;
return decode_fhandle(&xdr, res);
return decode_fhandle(xdr, res);
}

static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res)
Expand Down Expand Up @@ -434,30 +432,28 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res)
return 0;
}

static int mnt_dec_mountres3(struct rpc_rqst *req, __be32 *p,
struct mountres *res)
static int mnt_xdr_dec_mountres3(struct rpc_rqst *req,
struct xdr_stream *xdr,
struct mountres *res)
{
struct xdr_stream xdr;
int status;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);

status = decode_fhs_status(&xdr, res);
status = decode_fhs_status(xdr, res);
if (unlikely(status != 0 || res->errno != 0))
return status;
status = decode_fhandle3(&xdr, res);
status = decode_fhandle3(xdr, res);
if (unlikely(status != 0)) {
res->errno = -EBADHANDLE;
return 0;
}
return decode_auth_flavors(&xdr, res);
return decode_auth_flavors(xdr, res);
}

static struct rpc_procinfo mnt_procedures[] = {
[MOUNTPROC_MNT] = {
.p_proc = MOUNTPROC_MNT,
.p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
.p_decode = (kxdrproc_t)mnt_dec_mountres,
.p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres,
.p_arglen = MNT_enc_dirpath_sz,
.p_replen = MNT_dec_mountres_sz,
.p_statidx = MOUNTPROC_MNT,
Expand All @@ -476,7 +472,7 @@ static struct rpc_procinfo mnt3_procedures[] = {
[MOUNTPROC3_MNT] = {
.p_proc = MOUNTPROC3_MNT,
.p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
.p_decode = (kxdrproc_t)mnt_dec_mountres3,
.p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres3,
.p_arglen = MNT_enc_dirpath_sz,
.p_replen = MNT_dec_mountres3_sz,
.p_statidx = MOUNTPROC3_MNT,
Expand Down
Loading

0 comments on commit bf26955

Please sign in to comment.