Commit 1cad7ea6 authored by Ricardo Labiaga's avatar Ricardo Labiaga Committed by Benny Halevy

nfs41: Refactor svc_process()

net/sunrpc/svc.c:svc_process() is used by the NFSv4 callback service
to process RPC requests arriving over connections initiated by the
server.  NFSv4.1 supports callbacks over the backchannel on connections
initiated by the client.  This patch refactors svc_process() so that
common code can also be used by the backchannel.
Signed-off-by: default avatarRicardo Labiaga <ricardo.labiaga@netapp.com>
Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
parent 0d90ba1c
...@@ -970,20 +970,18 @@ svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) ...@@ -970,20 +970,18 @@ svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
} }
/* /*
* Process the RPC request. * Common routine for processing the RPC request.
*/ */
int static int
svc_process(struct svc_rqst *rqstp) svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
{ {
struct svc_program *progp; struct svc_program *progp;
struct svc_version *versp = NULL; /* compiler food */ struct svc_version *versp = NULL; /* compiler food */
struct svc_procedure *procp = NULL; struct svc_procedure *procp = NULL;
struct kvec * argv = &rqstp->rq_arg.head[0];
struct kvec * resv = &rqstp->rq_res.head[0];
struct svc_serv *serv = rqstp->rq_server; struct svc_serv *serv = rqstp->rq_server;
kxdrproc_t xdr; kxdrproc_t xdr;
__be32 *statp; __be32 *statp;
u32 dir, prog, vers, proc; u32 prog, vers, proc;
__be32 auth_stat, rpc_stat; __be32 auth_stat, rpc_stat;
int auth_res; int auth_res;
__be32 *reply_statp; __be32 *reply_statp;
...@@ -993,19 +991,6 @@ svc_process(struct svc_rqst *rqstp) ...@@ -993,19 +991,6 @@ svc_process(struct svc_rqst *rqstp)
if (argv->iov_len < 6*4) if (argv->iov_len < 6*4)
goto err_short_len; goto err_short_len;
/* setup response xdr_buf.
* Initially it has just one page
*/
rqstp->rq_resused = 1;
resv->iov_base = page_address(rqstp->rq_respages[0]);
resv->iov_len = 0;
rqstp->rq_res.pages = rqstp->rq_respages + 1;
rqstp->rq_res.len = 0;
rqstp->rq_res.page_base = 0;
rqstp->rq_res.page_len = 0;
rqstp->rq_res.buflen = PAGE_SIZE;
rqstp->rq_res.tail[0].iov_base = NULL;
rqstp->rq_res.tail[0].iov_len = 0;
/* Will be turned off only in gss privacy case: */ /* Will be turned off only in gss privacy case: */
rqstp->rq_splice_ok = 1; rqstp->rq_splice_ok = 1;
/* Will be turned off only when NFSv4 Sessions are used */ /* Will be turned off only when NFSv4 Sessions are used */
...@@ -1014,17 +999,13 @@ svc_process(struct svc_rqst *rqstp) ...@@ -1014,17 +999,13 @@ svc_process(struct svc_rqst *rqstp)
/* Setup reply header */ /* Setup reply header */
rqstp->rq_xprt->xpt_ops->xpo_prep_reply_hdr(rqstp); rqstp->rq_xprt->xpt_ops->xpo_prep_reply_hdr(rqstp);
rqstp->rq_xid = svc_getu32(argv);
svc_putu32(resv, rqstp->rq_xid); svc_putu32(resv, rqstp->rq_xid);
dir = svc_getnl(argv);
vers = svc_getnl(argv); vers = svc_getnl(argv);
/* First words of reply: */ /* First words of reply: */
svc_putnl(resv, 1); /* REPLY */ svc_putnl(resv, 1); /* REPLY */
if (dir != 0) /* direction != CALL */
goto err_bad_dir;
if (vers != 2) /* RPC version number */ if (vers != 2) /* RPC version number */
goto err_bad_rpc; goto err_bad_rpc;
...@@ -1147,7 +1128,7 @@ svc_process(struct svc_rqst *rqstp) ...@@ -1147,7 +1128,7 @@ svc_process(struct svc_rqst *rqstp)
sendit: sendit:
if (svc_authorise(rqstp)) if (svc_authorise(rqstp))
goto dropit; goto dropit;
return svc_send(rqstp); return 1; /* Caller can now send it */
dropit: dropit:
svc_authorise(rqstp); /* doesn't hurt to call this twice */ svc_authorise(rqstp); /* doesn't hurt to call this twice */
...@@ -1161,12 +1142,6 @@ svc_process(struct svc_rqst *rqstp) ...@@ -1161,12 +1142,6 @@ svc_process(struct svc_rqst *rqstp)
goto dropit; /* drop request */ goto dropit; /* drop request */
err_bad_dir:
svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
serv->sv_stats->rpcbadfmt++;
goto dropit; /* drop request */
err_bad_rpc: err_bad_rpc:
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putnl(resv, 1); /* REJECT */ svc_putnl(resv, 1); /* REJECT */
...@@ -1219,6 +1194,51 @@ svc_process(struct svc_rqst *rqstp) ...@@ -1219,6 +1194,51 @@ svc_process(struct svc_rqst *rqstp)
} }
EXPORT_SYMBOL_GPL(svc_process); EXPORT_SYMBOL_GPL(svc_process);
/*
* Process the RPC request.
*/
int
svc_process(struct svc_rqst *rqstp)
{
struct kvec *argv = &rqstp->rq_arg.head[0];
struct kvec *resv = &rqstp->rq_res.head[0];
struct svc_serv *serv = rqstp->rq_server;
u32 dir;
int error;
/*
* Setup response xdr_buf.
* Initially it has just one page
*/
rqstp->rq_resused = 1;
resv->iov_base = page_address(rqstp->rq_respages[0]);
resv->iov_len = 0;
rqstp->rq_res.pages = rqstp->rq_respages + 1;
rqstp->rq_res.len = 0;
rqstp->rq_res.page_base = 0;
rqstp->rq_res.page_len = 0;
rqstp->rq_res.buflen = PAGE_SIZE;
rqstp->rq_res.tail[0].iov_base = NULL;
rqstp->rq_res.tail[0].iov_len = 0;
rqstp->rq_xid = svc_getu32(argv);
dir = svc_getnl(argv);
if (dir != 0) {
/* direction != CALL */
svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
serv->sv_stats->rpcbadfmt++;
svc_drop(rqstp);
return 0;
}
error = svc_process_common(rqstp, argv, resv);
if (error <= 0)
return error;
return svc_send(rqstp);
}
/* /*
* Return (transport-specific) limit on the rpc payload. * Return (transport-specific) limit on the rpc payload.
*/ */
......
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