Commit d8558f99 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Trond Myklebust

sunrpc: drop BKL around wrap and unwrap

We don't need the BKL when wrapping and unwrapping; and experiments by Avishay
Traeger have found that permitting multiple encryption and decryption
operations to proceed in parallel can provide significant performance
improvements.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Cc: Avishay Traeger <atraeger@cs.sunysb.edu>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 137d6aca
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/smp_lock.h>
#ifdef RPC_DEBUG #ifdef RPC_DEBUG
# define RPCDBG_FACILITY RPCDBG_AUTH # define RPCDBG_FACILITY RPCDBG_AUTH
...@@ -475,13 +476,17 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, ...@@ -475,13 +476,17 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp,
__be32 *data, void *obj) __be32 *data, void *obj)
{ {
struct rpc_cred *cred = task->tk_msg.rpc_cred; struct rpc_cred *cred = task->tk_msg.rpc_cred;
int ret;
dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", dprintk("RPC: %5u using %s cred %p to wrap rpc data\n",
task->tk_pid, cred->cr_ops->cr_name, cred); task->tk_pid, cred->cr_ops->cr_name, cred);
if (cred->cr_ops->crwrap_req) if (cred->cr_ops->crwrap_req)
return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj);
/* By default, we encode the arguments normally. */ /* By default, we encode the arguments normally. */
return encode(rqstp, data, obj); lock_kernel();
ret = encode(rqstp, data, obj);
unlock_kernel();
return ret;
} }
int int
...@@ -489,6 +494,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, ...@@ -489,6 +494,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
__be32 *data, void *obj) __be32 *data, void *obj)
{ {
struct rpc_cred *cred = task->tk_msg.rpc_cred; struct rpc_cred *cred = task->tk_msg.rpc_cred;
int ret;
dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n",
task->tk_pid, cred->cr_ops->cr_name, cred); task->tk_pid, cred->cr_ops->cr_name, cred);
...@@ -496,7 +502,10 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, ...@@ -496,7 +502,10 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
return cred->cr_ops->crunwrap_resp(task, decode, rqstp, return cred->cr_ops->crunwrap_resp(task, decode, rqstp,
data, obj); data, obj);
/* By default, we decode the arguments normally. */ /* By default, we decode the arguments normally. */
return decode(rqstp, data, obj); lock_kernel();
ret = decode(rqstp, data, obj);
unlock_kernel();
return ret;
} }
int int
......
...@@ -999,7 +999,9 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, ...@@ -999,7 +999,9 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base;
*p++ = htonl(rqstp->rq_seqno); *p++ = htonl(rqstp->rq_seqno);
lock_kernel();
status = encode(rqstp, p, obj); status = encode(rqstp, p, obj);
unlock_kernel();
if (status) if (status)
return status; return status;
...@@ -1093,7 +1095,9 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, ...@@ -1093,7 +1095,9 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base;
*p++ = htonl(rqstp->rq_seqno); *p++ = htonl(rqstp->rq_seqno);
lock_kernel();
status = encode(rqstp, p, obj); status = encode(rqstp, p, obj);
unlock_kernel();
if (status) if (status)
return status; return status;
...@@ -1152,12 +1156,16 @@ gss_wrap_req(struct rpc_task *task, ...@@ -1152,12 +1156,16 @@ gss_wrap_req(struct rpc_task *task,
/* The spec seems a little ambiguous here, but I think that not /* The spec seems a little ambiguous here, but I think that not
* wrapping context destruction requests makes the most sense. * wrapping context destruction requests makes the most sense.
*/ */
lock_kernel();
status = encode(rqstp, p, obj); status = encode(rqstp, p, obj);
unlock_kernel();
goto out; goto out;
} }
switch (gss_cred->gc_service) { switch (gss_cred->gc_service) {
case RPC_GSS_SVC_NONE: case RPC_GSS_SVC_NONE:
lock_kernel();
status = encode(rqstp, p, obj); status = encode(rqstp, p, obj);
unlock_kernel();
break; break;
case RPC_GSS_SVC_INTEGRITY: case RPC_GSS_SVC_INTEGRITY:
status = gss_wrap_req_integ(cred, ctx, encode, status = gss_wrap_req_integ(cred, ctx, encode,
...@@ -1273,7 +1281,9 @@ gss_unwrap_resp(struct rpc_task *task, ...@@ -1273,7 +1281,9 @@ gss_unwrap_resp(struct rpc_task *task,
cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp)
+ (savedlen - head->iov_len); + (savedlen - head->iov_len);
out_decode: out_decode:
lock_kernel();
status = decode(rqstp, p, obj); status = decode(rqstp, p, obj);
unlock_kernel();
out: out:
gss_put_ctx(ctx); gss_put_ctx(ctx);
dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid, dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid,
......
...@@ -904,10 +904,8 @@ call_encode(struct rpc_task *task) ...@@ -904,10 +904,8 @@ call_encode(struct rpc_task *task)
if (encode == NULL) if (encode == NULL)
return; return;
lock_kernel();
task->tk_status = rpcauth_wrap_req(task, encode, req, p, task->tk_status = rpcauth_wrap_req(task, encode, req, p,
task->tk_msg.rpc_argp); task->tk_msg.rpc_argp);
unlock_kernel();
if (task->tk_status == -ENOMEM) { if (task->tk_status == -ENOMEM) {
/* XXX: Is this sane? */ /* XXX: Is this sane? */
rpc_delay(task, 3*HZ); rpc_delay(task, 3*HZ);
...@@ -1238,10 +1236,8 @@ call_decode(struct rpc_task *task) ...@@ -1238,10 +1236,8 @@ call_decode(struct rpc_task *task)
task->tk_action = rpc_exit_task; task->tk_action = rpc_exit_task;
if (decode) { if (decode) {
lock_kernel();
task->tk_status = rpcauth_unwrap_resp(task, decode, req, p, task->tk_status = rpcauth_unwrap_resp(task, decode, req, p,
task->tk_msg.rpc_resp); task->tk_msg.rpc_resp);
unlock_kernel();
} }
dprintk("RPC: %5u call_decode result %d\n", task->tk_pid, dprintk("RPC: %5u call_decode result %d\n", task->tk_pid,
task->tk_status); task->tk_status);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment