diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-12-14 09:59:29 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-12-16 12:37:25 -0500 |
commit | bf2695516db982e90a22fc94f93491b481796bb1 (patch) | |
tree | 367bf134ef892bfc3fcd2c4fe676b14102d97467 /fs/lockd | |
parent | 9f06c719f474be7003763284a990bed6377bb0d4 (diff) |
SUNRPC: New xdr_streams XDR decoder API
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 <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/clnt4xdr.c | 20 | ||||
-rw-r--r-- | fs/lockd/clntxdr.c | 20 | ||||
-rw-r--r-- | fs/lockd/mon.c | 30 |
3 files changed, 33 insertions, 37 deletions
diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index 974f1d9cd323..f848b52c67b1 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c | |||
@@ -529,17 +529,16 @@ out: | |||
529 | return error; | 529 | return error; |
530 | } | 530 | } |
531 | 531 | ||
532 | static int nlm4_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, | 532 | static int nlm4_xdr_dec_testres(struct rpc_rqst *req, |
533 | struct xdr_stream *xdr, | ||
533 | struct nlm_res *result) | 534 | struct nlm_res *result) |
534 | { | 535 | { |
535 | struct xdr_stream xdr; | ||
536 | int error; | 536 | int error; |
537 | 537 | ||
538 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 538 | error = decode_cookie(xdr, &result->cookie); |
539 | error = decode_cookie(&xdr, &result->cookie); | ||
540 | if (unlikely(error)) | 539 | if (unlikely(error)) |
541 | goto out; | 540 | goto out; |
542 | error = decode_nlm4_testrply(&xdr, result); | 541 | error = decode_nlm4_testrply(xdr, result); |
543 | out: | 542 | out: |
544 | return error; | 543 | return error; |
545 | } | 544 | } |
@@ -550,17 +549,16 @@ out: | |||
550 | * nlm4_stat stat; | 549 | * nlm4_stat stat; |
551 | * }; | 550 | * }; |
552 | */ | 551 | */ |
553 | static int nlm4_xdr_dec_res(struct rpc_rqst *req, __be32 *p, | 552 | static int nlm4_xdr_dec_res(struct rpc_rqst *req, |
553 | struct xdr_stream *xdr, | ||
554 | struct nlm_res *result) | 554 | struct nlm_res *result) |
555 | { | 555 | { |
556 | struct xdr_stream xdr; | ||
557 | int error; | 556 | int error; |
558 | 557 | ||
559 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 558 | error = decode_cookie(xdr, &result->cookie); |
560 | error = decode_cookie(&xdr, &result->cookie); | ||
561 | if (unlikely(error)) | 559 | if (unlikely(error)) |
562 | goto out; | 560 | goto out; |
563 | error = decode_nlm4_stat(&xdr, &result->status); | 561 | error = decode_nlm4_stat(xdr, &result->status); |
564 | out: | 562 | out: |
565 | return error; | 563 | return error; |
566 | } | 564 | } |
@@ -575,7 +573,7 @@ out: | |||
575 | [NLMPROC_##proc] = { \ | 573 | [NLMPROC_##proc] = { \ |
576 | .p_proc = NLMPROC_##proc, \ | 574 | .p_proc = NLMPROC_##proc, \ |
577 | .p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \ | 575 | .p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \ |
578 | .p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \ | 576 | .p_decode = (kxdrdproc_t)nlm4_xdr_dec_##restype, \ |
579 | .p_arglen = NLM4_##argtype##_sz, \ | 577 | .p_arglen = NLM4_##argtype##_sz, \ |
580 | .p_replen = NLM4_##restype##_sz, \ | 578 | .p_replen = NLM4_##restype##_sz, \ |
581 | .p_statidx = NLMPROC_##proc, \ | 579 | .p_statidx = NLMPROC_##proc, \ |
diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c index c6fda8fb1c5b..180ac34feb9a 100644 --- a/fs/lockd/clntxdr.c +++ b/fs/lockd/clntxdr.c | |||
@@ -527,17 +527,16 @@ out: | |||
527 | return error; | 527 | return error; |
528 | } | 528 | } |
529 | 529 | ||
530 | static int nlm_xdr_dec_testres(struct rpc_rqst *req, __be32 *p, | 530 | static int nlm_xdr_dec_testres(struct rpc_rqst *req, |
531 | struct xdr_stream *xdr, | ||
531 | struct nlm_res *result) | 532 | struct nlm_res *result) |
532 | { | 533 | { |
533 | struct xdr_stream xdr; | ||
534 | int error; | 534 | int error; |
535 | 535 | ||
536 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 536 | error = decode_cookie(xdr, &result->cookie); |
537 | error = decode_cookie(&xdr, &result->cookie); | ||
538 | if (unlikely(error)) | 537 | if (unlikely(error)) |
539 | goto out; | 538 | goto out; |
540 | error = decode_nlm_testrply(&xdr, result); | 539 | error = decode_nlm_testrply(xdr, result); |
541 | out: | 540 | out: |
542 | return error; | 541 | return error; |
543 | } | 542 | } |
@@ -548,17 +547,16 @@ out: | |||
548 | * nlm_stat stat; | 547 | * nlm_stat stat; |
549 | * }; | 548 | * }; |
550 | */ | 549 | */ |
551 | static int nlm_xdr_dec_res(struct rpc_rqst *req, __be32 *p, | 550 | static int nlm_xdr_dec_res(struct rpc_rqst *req, |
551 | struct xdr_stream *xdr, | ||
552 | struct nlm_res *result) | 552 | struct nlm_res *result) |
553 | { | 553 | { |
554 | struct xdr_stream xdr; | ||
555 | int error; | 554 | int error; |
556 | 555 | ||
557 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 556 | error = decode_cookie(xdr, &result->cookie); |
558 | error = decode_cookie(&xdr, &result->cookie); | ||
559 | if (unlikely(error)) | 557 | if (unlikely(error)) |
560 | goto out; | 558 | goto out; |
561 | error = decode_nlm_stat(&xdr, &result->status); | 559 | error = decode_nlm_stat(xdr, &result->status); |
562 | out: | 560 | out: |
563 | return error; | 561 | return error; |
564 | } | 562 | } |
@@ -573,7 +571,7 @@ out: | |||
573 | [NLMPROC_##proc] = { \ | 571 | [NLMPROC_##proc] = { \ |
574 | .p_proc = NLMPROC_##proc, \ | 572 | .p_proc = NLMPROC_##proc, \ |
575 | .p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \ | 573 | .p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \ |
576 | .p_decode = (kxdrproc_t)nlm_xdr_dec_##restype, \ | 574 | .p_decode = (kxdrdproc_t)nlm_xdr_dec_##restype, \ |
577 | .p_arglen = NLM_##argtype##_sz, \ | 575 | .p_arglen = NLM_##argtype##_sz, \ |
578 | .p_replen = NLM_##restype##_sz, \ | 576 | .p_replen = NLM_##restype##_sz, \ |
579 | .p_statidx = NLMPROC_##proc, \ | 577 | .p_statidx = NLMPROC_##proc, \ |
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index baa77bc9d825..23d7451b2938 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c | |||
@@ -472,35 +472,35 @@ static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr, | |||
472 | encode_mon_id(xdr, argp); | 472 | encode_mon_id(xdr, argp); |
473 | } | 473 | } |
474 | 474 | ||
475 | static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, | 475 | static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp, |
476 | struct nsm_res *resp) | 476 | struct xdr_stream *xdr, |
477 | struct nsm_res *resp) | ||
477 | { | 478 | { |
478 | struct xdr_stream xdr; | 479 | __be32 *p; |
479 | 480 | ||
480 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 481 | p = xdr_inline_decode(xdr, 4 + 4); |
481 | p = xdr_inline_decode(&xdr, 4 + 4); | ||
482 | if (unlikely(p == NULL)) | 482 | if (unlikely(p == NULL)) |
483 | return -EIO; | 483 | return -EIO; |
484 | resp->status = be32_to_cpup(p++); | 484 | resp->status = be32_to_cpup(p++); |
485 | resp->state = be32_to_cpup(p); | 485 | resp->state = be32_to_cpup(p); |
486 | 486 | ||
487 | dprintk("lockd: xdr_dec_stat_res status %d state %d\n", | 487 | dprintk("lockd: %s status %d state %d\n", |
488 | resp->status, resp->state); | 488 | __func__, resp->status, resp->state); |
489 | return 0; | 489 | return 0; |
490 | } | 490 | } |
491 | 491 | ||
492 | static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p, | 492 | static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp, |
493 | struct nsm_res *resp) | 493 | struct xdr_stream *xdr, |
494 | struct nsm_res *resp) | ||
494 | { | 495 | { |
495 | struct xdr_stream xdr; | 496 | __be32 *p; |
496 | 497 | ||
497 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 498 | p = xdr_inline_decode(xdr, 4); |
498 | p = xdr_inline_decode(&xdr, 4); | ||
499 | if (unlikely(p == NULL)) | 499 | if (unlikely(p == NULL)) |
500 | return -EIO; | 500 | return -EIO; |
501 | resp->state = be32_to_cpup(p); | 501 | resp->state = be32_to_cpup(p); |
502 | 502 | ||
503 | dprintk("lockd: xdr_dec_stat state %d\n", resp->state); | 503 | dprintk("lockd: %s state %d\n", __func__, resp->state); |
504 | return 0; | 504 | return 0; |
505 | } | 505 | } |
506 | 506 | ||
@@ -517,7 +517,7 @@ static struct rpc_procinfo nsm_procedures[] = { | |||
517 | [NSMPROC_MON] = { | 517 | [NSMPROC_MON] = { |
518 | .p_proc = NSMPROC_MON, | 518 | .p_proc = NSMPROC_MON, |
519 | .p_encode = (kxdreproc_t)nsm_xdr_enc_mon, | 519 | .p_encode = (kxdreproc_t)nsm_xdr_enc_mon, |
520 | .p_decode = (kxdrproc_t)xdr_dec_stat_res, | 520 | .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat_res, |
521 | .p_arglen = SM_mon_sz, | 521 | .p_arglen = SM_mon_sz, |
522 | .p_replen = SM_monres_sz, | 522 | .p_replen = SM_monres_sz, |
523 | .p_statidx = NSMPROC_MON, | 523 | .p_statidx = NSMPROC_MON, |
@@ -526,7 +526,7 @@ static struct rpc_procinfo nsm_procedures[] = { | |||
526 | [NSMPROC_UNMON] = { | 526 | [NSMPROC_UNMON] = { |
527 | .p_proc = NSMPROC_UNMON, | 527 | .p_proc = NSMPROC_UNMON, |
528 | .p_encode = (kxdreproc_t)nsm_xdr_enc_unmon, | 528 | .p_encode = (kxdreproc_t)nsm_xdr_enc_unmon, |
529 | .p_decode = (kxdrproc_t)xdr_dec_stat, | 529 | .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat, |
530 | .p_arglen = SM_mon_id_sz, | 530 | .p_arglen = SM_mon_id_sz, |
531 | .p_replen = SM_unmonres_sz, | 531 | .p_replen = SM_unmonres_sz, |
532 | .p_statidx = NSMPROC_UNMON, | 532 | .p_statidx = NSMPROC_UNMON, |