summaryrefslogtreecommitdiff
path: root/fs/lockd
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 17:59:18 +0300
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 20:37:25 +0300
commit9f06c719f474be7003763284a990bed6377bb0d4 (patch)
tree409ebc3505f943bfdb933ab0acd76ffb5347b372 /fs/lockd
parent1ac7c23e4af5e83525137661595000099f1ce94f (diff)
downloadlinux-9f06c719f474be7003763284a990bed6377bb0d4.tar.xz
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')
-rw-r--r--fs/lockd/clnt4xdr.c92
-rw-r--r--fs/lockd/clntxdr.c92
-rw-r--r--fs/lockd/mon.c26
3 files changed, 87 insertions, 123 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,
* struct nlm4_lock alock;
* };
*/
-static int nlm4_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm4_xdr_enc_testargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm4_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm4_lock(xdr, lock);
}
/*
@@ -408,20 +406,18 @@ static int nlm4_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p,
* int state;
* };
*/
-static int nlm4_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, args->block);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm4_lock(&xdr, lock);
- encode_bool(&xdr, args->reclaim);
- encode_int32(&xdr, args->state);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, args->block);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm4_lock(xdr, lock);
+ encode_bool(xdr, args->reclaim);
+ encode_int32(xdr, args->state);
}
/*
@@ -432,18 +428,16 @@ static int nlm4_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p,
* struct nlm4_lock alock;
* };
*/
-static int nlm4_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, args->block);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm4_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, args->block);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm4_lock(xdr, lock);
}
/*
@@ -452,16 +446,14 @@ static int nlm4_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p,
* struct nlm4_lock alock;
* };
*/
-static int nlm4_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm4_xdr_enc_unlockargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_nlm4_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_nlm4_lock(xdr, lock);
}
/*
@@ -470,15 +462,12 @@ static int nlm4_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p,
* nlm4_stat stat;
* };
*/
-static int nlm4_xdr_enc_res(struct rpc_rqst *req, __be32 *p,
- const struct nlm_res *result)
+static void nlm4_xdr_enc_res(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_res *result)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &result->cookie);
- encode_nlm4_stat(&xdr, result->status);
- return 0;
+ encode_cookie(xdr, &result->cookie);
+ encode_nlm4_stat(xdr, result->status);
}
/*
@@ -494,17 +483,14 @@ static int nlm4_xdr_enc_res(struct rpc_rqst *req, __be32 *p,
* nlm4_testrply test_stat;
* };
*/
-static int nlm4_xdr_enc_testres(struct rpc_rqst *req, __be32 *p,
- const struct nlm_res *result)
+static void nlm4_xdr_enc_testres(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_res *result)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &result->cookie);
- encode_nlm4_stat(&xdr, result->status);
+ encode_cookie(xdr, &result->cookie);
+ encode_nlm4_stat(xdr, result->status);
if (result->status == nlm_lck_denied)
- encode_nlm4_holder(&xdr, result);
- return 0;
+ encode_nlm4_holder(xdr, result);
}
@@ -588,7 +574,7 @@ out:
#define PROC(proc, argtype, restype) \
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
- .p_encode = (kxdrproc_t)nlm4_xdr_enc_##argtype, \
+ .p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm4_xdr_dec_##restype, \
.p_arglen = NLM4_##argtype##_sz, \
.p_replen = NLM4_##restype##_sz, \
diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c
index 0472f2aff509..c6fda8fb1c5b 100644
--- a/fs/lockd/clntxdr.c
+++ b/fs/lockd/clntxdr.c
@@ -378,17 +378,15 @@ static void encode_nlm_lock(struct xdr_stream *xdr,
* struct nlm_lock alock;
* };
*/
-static int nlm_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm_xdr_enc_testargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm_lock(xdr, lock);
}
/*
@@ -401,20 +399,18 @@ static int nlm_xdr_enc_testargs(struct rpc_rqst *req, __be32 *p,
* int state;
* };
*/
-static int nlm_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm_xdr_enc_lockargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, args->block);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm_lock(&xdr, lock);
- encode_bool(&xdr, args->reclaim);
- encode_int32(&xdr, args->state);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, args->block);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm_lock(xdr, lock);
+ encode_bool(xdr, args->reclaim);
+ encode_int32(xdr, args->state);
}
/*
@@ -425,18 +421,16 @@ static int nlm_xdr_enc_lockargs(struct rpc_rqst *req, __be32 *p,
* struct nlm_lock alock;
* };
*/
-static int nlm_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm_xdr_enc_cancargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_bool(&xdr, args->block);
- encode_bool(&xdr, lock->fl.fl_type == F_WRLCK);
- encode_nlm_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_bool(xdr, args->block);
+ encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
+ encode_nlm_lock(xdr, lock);
}
/*
@@ -445,16 +439,14 @@ static int nlm_xdr_enc_cancargs(struct rpc_rqst *req, __be32 *p,
* struct nlm_lock alock;
* };
*/
-static int nlm_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p,
- const struct nlm_args *args)
+static void nlm_xdr_enc_unlockargs(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_args *args)
{
const struct nlm_lock *lock = &args->lock;
- struct xdr_stream xdr;
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &args->cookie);
- encode_nlm_lock(&xdr, lock);
- return 0;
+ encode_cookie(xdr, &args->cookie);
+ encode_nlm_lock(xdr, lock);
}
/*
@@ -463,15 +455,12 @@ static int nlm_xdr_enc_unlockargs(struct rpc_rqst *req, __be32 *p,
* nlm_stat stat;
* };
*/
-static int nlm_xdr_enc_res(struct rpc_rqst *req, __be32 *p,
- const struct nlm_res *result)
+static void nlm_xdr_enc_res(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_res *result)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &result->cookie);
- encode_nlm_stat(&xdr, result->status);
- return 0;
+ encode_cookie(xdr, &result->cookie);
+ encode_nlm_stat(xdr, result->status);
}
/*
@@ -494,16 +483,13 @@ static void encode_nlm_testrply(struct xdr_stream *xdr,
encode_nlm_holder(xdr, result);
}
-static int nlm_xdr_enc_testres(struct rpc_rqst *req, __be32 *p,
- const struct nlm_res *result)
+static void nlm_xdr_enc_testres(struct rpc_rqst *req,
+ struct xdr_stream *xdr,
+ const struct nlm_res *result)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_cookie(&xdr, &result->cookie);
- encode_nlm_stat(&xdr, result->status);
- encode_nlm_testrply(&xdr, result);
- return 0;
+ encode_cookie(xdr, &result->cookie);
+ encode_nlm_stat(xdr, result->status);
+ encode_nlm_testrply(xdr, result);
}
@@ -586,7 +572,7 @@ out:
#define PROC(proc, argtype, restype) \
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
- .p_encode = (kxdrproc_t)nlm_xdr_enc_##argtype, \
+ .p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \
.p_decode = (kxdrproc_t)nlm_xdr_dec_##restype, \
.p_arglen = NLM_##argtype##_sz, \
.p_replen = NLM_##restype##_sz, \
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index d812818d0258..baa77bc9d825 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -459,25 +459,17 @@ static void encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp)
xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE);
}
-static int xdr_enc_mon(struct rpc_rqst *req, __be32 *p,
- const struct nsm_args *argp)
+static void nsm_xdr_enc_mon(struct rpc_rqst *req, struct xdr_stream *xdr,
+ const struct nsm_args *argp)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_mon_id(&xdr, argp);
- encode_priv(&xdr, argp);
- return 0;
+ encode_mon_id(xdr, argp);
+ encode_priv(xdr, argp);
}
-static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p,
- const struct nsm_args *argp)
+static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr,
+ const struct nsm_args *argp)
{
- struct xdr_stream xdr;
-
- xdr_init_encode(&xdr, &req->rq_snd_buf, p);
- encode_mon_id(&xdr, argp);
- return 0;
+ encode_mon_id(xdr, argp);
}
static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p,
@@ -524,7 +516,7 @@ static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p,
static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_MON] = {
.p_proc = NSMPROC_MON,
- .p_encode = (kxdrproc_t)xdr_enc_mon,
+ .p_encode = (kxdreproc_t)nsm_xdr_enc_mon,
.p_decode = (kxdrproc_t)xdr_dec_stat_res,
.p_arglen = SM_mon_sz,
.p_replen = SM_monres_sz,
@@ -533,7 +525,7 @@ static struct rpc_procinfo nsm_procedures[] = {
},
[NSMPROC_UNMON] = {
.p_proc = NSMPROC_UNMON,
- .p_encode = (kxdrproc_t)xdr_enc_unmon,
+ .p_encode = (kxdreproc_t)nsm_xdr_enc_unmon,
.p_decode = (kxdrproc_t)xdr_dec_stat,
.p_arglen = SM_mon_id_sz,
.p_replen = SM_unmonres_sz,