diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2007-07-11 18:39:02 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-19 15:21:39 -0400 |
commit | be879c4e249a8875d7129f3b0c1bb62584dafbd8 (patch) | |
tree | 6d6d774ac4dd24ff280e83e1d6a65be29a6dc6f8 | |
parent | e3a535e1739a9da3cc316ccdfe5cd4bf84d745ac (diff) |
SUNRPC: move bkl locking and xdr proc invocation into a common helper
Since every invocation of xdr encode or decode functions takes the BKL now,
there's a lot of redundant lock_kernel/unlock_kernel pairs that we can pull
out into a common function.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | include/linux/sunrpc/xdr.h | 16 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 13 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 21 |
3 files changed, 23 insertions, 27 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 9e340fa23c06..c6b53d181bfa 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/uio.h> | 12 | #include <linux/uio.h> |
13 | #include <asm/byteorder.h> | 13 | #include <asm/byteorder.h> |
14 | #include <linux/scatterlist.h> | 14 | #include <linux/scatterlist.h> |
15 | #include <linux/smp_lock.h> | ||
15 | 16 | ||
16 | /* | 17 | /* |
17 | * Buffer adjustment | 18 | * Buffer adjustment |
@@ -36,6 +37,21 @@ struct xdr_netobj { | |||
36 | typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj); | 37 | typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj); |
37 | 38 | ||
38 | /* | 39 | /* |
40 | * We're still requiring the BKL in the xdr code until it's been | ||
41 | * more carefully audited, at which point this wrapper will become | ||
42 | * unnecessary. | ||
43 | */ | ||
44 | static inline int rpc_call_xdrproc(kxdrproc_t xdrproc, void *rqstp, __be32 *data, void *obj) | ||
45 | { | ||
46 | int ret; | ||
47 | |||
48 | lock_kernel(); | ||
49 | ret = xdrproc(rqstp, data, obj); | ||
50 | unlock_kernel(); | ||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | /* | ||
39 | * Basic structure for transmission/reception of a client XDR message. | 55 | * Basic structure for transmission/reception of a client XDR message. |
40 | * Features a header (for a linear buffer containing RPC headers | 56 | * Features a header (for a linear buffer containing RPC headers |
41 | * and the data payload for short messages), and then an array of | 57 | * and the data payload for short messages), and then an array of |
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 29a8ecc60928..1ea27559b1de 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/sunrpc/clnt.h> | 14 | #include <linux/sunrpc/clnt.h> |
15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
16 | #include <linux/smp_lock.h> | ||
17 | 16 | ||
18 | #ifdef RPC_DEBUG | 17 | #ifdef RPC_DEBUG |
19 | # define RPCDBG_FACILITY RPCDBG_AUTH | 18 | # define RPCDBG_FACILITY RPCDBG_AUTH |
@@ -476,17 +475,13 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, | |||
476 | __be32 *data, void *obj) | 475 | __be32 *data, void *obj) |
477 | { | 476 | { |
478 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 477 | struct rpc_cred *cred = task->tk_msg.rpc_cred; |
479 | int ret; | ||
480 | 478 | ||
481 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", | 479 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", |
482 | task->tk_pid, cred->cr_ops->cr_name, cred); | 480 | task->tk_pid, cred->cr_ops->cr_name, cred); |
483 | if (cred->cr_ops->crwrap_req) | 481 | if (cred->cr_ops->crwrap_req) |
484 | return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); | 482 | return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); |
485 | /* By default, we encode the arguments normally. */ | 483 | /* By default, we encode the arguments normally. */ |
486 | lock_kernel(); | 484 | return rpc_call_xdrproc(encode, rqstp, data, obj); |
487 | ret = encode(rqstp, data, obj); | ||
488 | unlock_kernel(); | ||
489 | return ret; | ||
490 | } | 485 | } |
491 | 486 | ||
492 | int | 487 | int |
@@ -494,7 +489,6 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | |||
494 | __be32 *data, void *obj) | 489 | __be32 *data, void *obj) |
495 | { | 490 | { |
496 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 491 | struct rpc_cred *cred = task->tk_msg.rpc_cred; |
497 | int ret; | ||
498 | 492 | ||
499 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", | 493 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", |
500 | task->tk_pid, cred->cr_ops->cr_name, cred); | 494 | task->tk_pid, cred->cr_ops->cr_name, cred); |
@@ -502,10 +496,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | |||
502 | return cred->cr_ops->crunwrap_resp(task, decode, rqstp, | 496 | return cred->cr_ops->crunwrap_resp(task, decode, rqstp, |
503 | data, obj); | 497 | data, obj); |
504 | /* By default, we decode the arguments normally. */ | 498 | /* By default, we decode the arguments normally. */ |
505 | lock_kernel(); | 499 | return rpc_call_xdrproc(decode, rqstp, data, obj); |
506 | ret = decode(rqstp, data, obj); | ||
507 | unlock_kernel(); | ||
508 | return ret; | ||
509 | } | 500 | } |
510 | 501 | ||
511 | int | 502 | int |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index abfda33bac64..4bbc59cc237c 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <linux/types.h> | 43 | #include <linux/types.h> |
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/sched.h> | 45 | #include <linux/sched.h> |
46 | #include <linux/smp_lock.h> | ||
47 | #include <linux/pagemap.h> | 46 | #include <linux/pagemap.h> |
48 | #include <linux/sunrpc/clnt.h> | 47 | #include <linux/sunrpc/clnt.h> |
49 | #include <linux/sunrpc/auth.h> | 48 | #include <linux/sunrpc/auth.h> |
@@ -1000,9 +999,7 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |||
1000 | offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | 999 | offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; |
1001 | *p++ = htonl(rqstp->rq_seqno); | 1000 | *p++ = htonl(rqstp->rq_seqno); |
1002 | 1001 | ||
1003 | lock_kernel(); | 1002 | status = rpc_call_xdrproc(encode, rqstp, p, obj); |
1004 | status = encode(rqstp, p, obj); | ||
1005 | unlock_kernel(); | ||
1006 | if (status) | 1003 | if (status) |
1007 | return status; | 1004 | return status; |
1008 | 1005 | ||
@@ -1096,9 +1093,7 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |||
1096 | offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | 1093 | offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; |
1097 | *p++ = htonl(rqstp->rq_seqno); | 1094 | *p++ = htonl(rqstp->rq_seqno); |
1098 | 1095 | ||
1099 | lock_kernel(); | 1096 | status = rpc_call_xdrproc(encode, rqstp, p, obj); |
1100 | status = encode(rqstp, p, obj); | ||
1101 | unlock_kernel(); | ||
1102 | if (status) | 1097 | if (status) |
1103 | return status; | 1098 | return status; |
1104 | 1099 | ||
@@ -1157,16 +1152,12 @@ gss_wrap_req(struct rpc_task *task, | |||
1157 | /* The spec seems a little ambiguous here, but I think that not | 1152 | /* The spec seems a little ambiguous here, but I think that not |
1158 | * wrapping context destruction requests makes the most sense. | 1153 | * wrapping context destruction requests makes the most sense. |
1159 | */ | 1154 | */ |
1160 | lock_kernel(); | 1155 | status = rpc_call_xdrproc(encode, rqstp, p, obj); |
1161 | status = encode(rqstp, p, obj); | ||
1162 | unlock_kernel(); | ||
1163 | goto out; | 1156 | goto out; |
1164 | } | 1157 | } |
1165 | switch (gss_cred->gc_service) { | 1158 | switch (gss_cred->gc_service) { |
1166 | case RPC_GSS_SVC_NONE: | 1159 | case RPC_GSS_SVC_NONE: |
1167 | lock_kernel(); | 1160 | status = rpc_call_xdrproc(encode, rqstp, p, obj); |
1168 | status = encode(rqstp, p, obj); | ||
1169 | unlock_kernel(); | ||
1170 | break; | 1161 | break; |
1171 | case RPC_GSS_SVC_INTEGRITY: | 1162 | case RPC_GSS_SVC_INTEGRITY: |
1172 | status = gss_wrap_req_integ(cred, ctx, encode, | 1163 | status = gss_wrap_req_integ(cred, ctx, encode, |
@@ -1282,9 +1273,7 @@ gss_unwrap_resp(struct rpc_task *task, | |||
1282 | cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) | 1273 | cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) |
1283 | + (savedlen - head->iov_len); | 1274 | + (savedlen - head->iov_len); |
1284 | out_decode: | 1275 | out_decode: |
1285 | lock_kernel(); | 1276 | status = rpc_call_xdrproc(decode, rqstp, p, obj); |
1286 | status = decode(rqstp, p, obj); | ||
1287 | unlock_kernel(); | ||
1288 | out: | 1277 | out: |
1289 | gss_put_ctx(ctx); | 1278 | gss_put_ctx(ctx); |
1290 | dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid, | 1279 | dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid, |