aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/clnt4xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:59:18 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:25 -0500
commit9f06c719f474be7003763284a990bed6377bb0d4 (patch)
tree409ebc3505f943bfdb933ab0acd76ffb5347b372 /fs/lockd/clnt4xdr.c
parent1ac7c23e4af5e83525137661595000099f1ce94f (diff)
SUNRPC: New xdr_streams XDR encoder API
Now that all client-side XDR encoder routines use xdr_streams, there should be no need to support the legacy calling sequence [rpc_rqst *, __be32 *, RPC arg *] anywhere. We can construct an xdr_stream in the generic RPC code, instead of in each encoder function. Also, all the client-side encoder functions return 0 now, making a return value superfluous. Take this opportunity to convert them to return void instead. 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/clnt4xdr.c')
-rw-r--r--fs/lockd/clnt4xdr.c92
1 files changed, 39 insertions, 53 deletions
diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c
index 1a1c3e21ed2c..974f1d9cd323 100644
--- a/fs/lockd/clnt4xdr.c
+++ b/fs/lockd/clnt4xdr.c
@@ -385,17 +385,15 @@ static void encode_nlm4_lock(struct xdr_stream *xdr,
385 * struct nlm4_lock alock; 385 * struct nlm4_lock alock;
386 * }; 386 * };
387 */ 387 */
388static int nlm4_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p, 388static void nlm4_xdr_enc_testargs(struct rpc_rqst *req,
389 const struct nlm_args *args) 389 struct xdr_stream *xdr,
390 const struct nlm_args *args)
390{ 391{
391 const struct nlm_lock *lock = &args->lock; 392 const struct nlm_lock *lock = &args->lock;
392 struct xdr_stream xdr;
393 393
394 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 394 encode_cookie(xdr, &args->cookie);
395 encode_cookie(&xdr, &args->cookie); 395 encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
396 encode_bool(&xdr, lock->fl.fl_type == F_WRLCK); 396 encode_nlm4_lock(xdr, lock);
397 encode_nlm4_lock(&xdr, lock);
398 return 0;
399} 397}
400 398
401/* 399/*
@@ -408,20 +406,18 @@ static int nlm4_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p,
408 * int state; 406 * int state;
409 * }; 407 * };
410 */ 408 */
411static int nlm4_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p, 409static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req,
412 const struct nlm_args *args) 410 struct xdr_stream *xdr,
411 const struct nlm_args *args)
413{ 412{
414 const struct nlm_lock *lock = &args->lock; 413 const struct nlm_lock *lock = &args->lock;
415 struct xdr_stream xdr;
416 414
417 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 415 encode_cookie(xdr, &args->cookie);
418 encode_cookie(&xdr, &args->cookie); 416 encode_bool(xdr, args->block);
419 encode_bool(&xdr, args->block); 417 encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
420 encode_bool(&xdr, lock->fl.fl_type == F_WRLCK); 418 encode_nlm4_lock(xdr, lock);
421 encode_nlm4_lock(&xdr, lock); 419 encode_bool(xdr, args->reclaim);
422 encode_bool(&xdr, args->reclaim); 420 encode_int32(xdr, args->state);
423 encode_int32(&xdr, args->state);
424 return 0;
425} 421}
426 422
427/* 423/*
@@ -432,18 +428,16 @@ static int nlm4_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p,
432 * struct nlm4_lock alock; 428 * struct nlm4_lock alock;
433 * }; 429 * };
434 */ 430 */
435static int nlm4_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p, 431static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req,
436 const struct nlm_args *args) 432 struct xdr_stream *xdr,
433 const struct nlm_args *args)
437{ 434{
438 const struct nlm_lock *lock = &args->lock; 435 const struct nlm_lock *lock = &args->lock;
439 struct xdr_stream xdr;
440 436
441 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 437 encode_cookie(xdr, &args->cookie);
442 encode_cookie(&xdr, &args->cookie); 438 encode_bool(xdr, args->block);
443 encode_bool(&xdr, args->block); 439 encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
444 encode_bool(&xdr, lock->fl.fl_type == F_WRLCK); 440 encode_nlm4_lock(xdr, lock);
445 encode_nlm4_lock(&xdr, lock);
446 return 0;
447} 441}
448 442
449/* 443/*
@@ -452,16 +446,14 @@ static int nlm4_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p,
452 * struct nlm4_lock alock; 446 * struct nlm4_lock alock;
453 * }; 447 * };
454 */ 448 */
455static int nlm4_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p, 449static void nlm4_xdr_enc_unlockargs(struct rpc_rqst *req,
456 const struct nlm_args *args) 450 struct xdr_stream *xdr,
451 const struct nlm_args *args)
457{ 452{
458 const struct nlm_lock *lock = &args->lock; 453 const struct nlm_lock *lock = &args->lock;
459 struct xdr_stream xdr;
460 454
461 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 455 encode_cookie(xdr, &args->cookie);
462 encode_cookie(&xdr, &args->cookie); 456 encode_nlm4_lock(xdr, lock);
463 encode_nlm4_lock(&xdr, lock);
464 return 0;
465} 457}
466 458
467/* 459/*
@@ -470,15 +462,12 @@ static int nlm4_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p,
470 * nlm4_stat stat; 462 * nlm4_stat stat;
471 * }; 463 * };
472 */ 464 */
473static int nlm4_xdr_enc_res(struct rpc_rqst *req, __be32 *p, 465static void nlm4_xdr_enc_res(struct rpc_rqst *req,
474 const struct nlm_res *result) 466 struct xdr_stream *xdr,
467 const struct nlm_res *result)
475{ 468{
476 struct xdr_stream xdr; 469 encode_cookie(xdr, &result->cookie);
477 470 encode_nlm4_stat(xdr, result->status);
478 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
479 encode_cookie(&xdr, &result->cookie);
480 encode_nlm4_stat(&xdr, result->status);
481 return 0;
482} 471}
483 472
484/* 473/*
@@ -494,17 +483,14 @@ static int nlm4_xdr_enc_res(struct rpc_rqst *req, __be32 *p,
494 * nlm4_testrply test_stat; 483 * nlm4_testrply test_stat;
495 * }; 484 * };
496 */ 485 */
497static int nlm4_xdr_enc_testres(struct rpc_rqst *req, __be32 *p, 486static void nlm4_xdr_enc_testres(struct rpc_rqst *req,
498 const struct nlm_res *result) 487 struct xdr_stream *xdr,
488 const struct nlm_res *result)
499{ 489{
500 struct xdr_stream xdr; 490 encode_cookie(xdr, &result->cookie);
501 491 encode_nlm4_stat(xdr, result->status);
502 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
503 encode_cookie(&xdr, &result->cookie);
504 encode_nlm4_stat(&xdr, result->status);
505 if (result->status == nlm_lck_denied) 492 if (result->status == nlm_lck_denied)
506 encode_nlm4_holder(&xdr, result); 493 encode_nlm4_holder(xdr, result);
507 return 0;
508} 494}
509 495
510 496
@@ -588,7 +574,7 @@ out:
588#define PROC(proc, argtype, restype) \ 574#define PROC(proc, argtype, restype) \
589[NLMPROC_##proc] = { \ 575[NLMPROC_##proc] = { \
590 .p_proc = NLMPROC_##proc, \ 576 .p_proc = NLMPROC_##proc, \
591 .p_encode = (kxdrproc_t)nlm4_xdr_enc_##argtype, \ 577 .p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \
592 .p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \ 578 .p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \
593 .p_arglen = NLM4_##argtype##_sz, \ 579 .p_arglen = NLM4_##argtype##_sz, \
594 .p_replen = NLM4_##restype##_sz, \ 580 .p_replen = NLM4_##restype##_sz, \