mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
SUNRPC: move all of xprt handling into svc_xprt_handle()
svc_xprt_handle() does lots of things itself, but leaves some to the caller - svc_recv(). This isn't elegant. Move that code out of svc_recv() into svc_xprt_handle() Move the calls to svc_xprt_release() from svc_send() and svc_drop() (the two possible final steps in svc_process()) and from svc_recv() (in the case where svc_process() wasn't called) into svc_xprt_handle(). Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
@@ -785,7 +785,7 @@ static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt
|
|||||||
svc_xprt_received(newxpt);
|
svc_xprt_received(newxpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
|
static void svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
|
||||||
{
|
{
|
||||||
struct svc_serv *serv = rqstp->rq_server;
|
struct svc_serv *serv = rqstp->rq_server;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@@ -826,11 +826,26 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
|
|||||||
len = xprt->xpt_ops->xpo_recvfrom(rqstp);
|
len = xprt->xpt_ops->xpo_recvfrom(rqstp);
|
||||||
rqstp->rq_reserved = serv->sv_max_mesg;
|
rqstp->rq_reserved = serv->sv_max_mesg;
|
||||||
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
|
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
|
||||||
|
if (len <= 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
trace_svc_xdr_recvfrom(&rqstp->rq_arg);
|
||||||
|
|
||||||
|
clear_bit(XPT_OLD, &xprt->xpt_flags);
|
||||||
|
|
||||||
|
rqstp->rq_chandle.defer = svc_defer;
|
||||||
|
|
||||||
|
if (serv->sv_stats)
|
||||||
|
serv->sv_stats->netcnt++;
|
||||||
|
percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived);
|
||||||
|
rqstp->rq_stime = ktime_get();
|
||||||
|
svc_process(rqstp);
|
||||||
} else
|
} else
|
||||||
svc_xprt_received(xprt);
|
svc_xprt_received(xprt);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return len;
|
rqstp->rq_res.len = 0;
|
||||||
|
svc_xprt_release(rqstp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -844,11 +859,9 @@ out:
|
|||||||
void svc_recv(struct svc_rqst *rqstp)
|
void svc_recv(struct svc_rqst *rqstp)
|
||||||
{
|
{
|
||||||
struct svc_xprt *xprt = NULL;
|
struct svc_xprt *xprt = NULL;
|
||||||
struct svc_serv *serv = rqstp->rq_server;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!svc_alloc_arg(rqstp))
|
if (!svc_alloc_arg(rqstp))
|
||||||
goto out;
|
return;
|
||||||
|
|
||||||
try_to_freeze();
|
try_to_freeze();
|
||||||
cond_resched();
|
cond_resched();
|
||||||
@@ -856,31 +869,9 @@ void svc_recv(struct svc_rqst *rqstp)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
xprt = svc_get_next_xprt(rqstp);
|
xprt = svc_get_next_xprt(rqstp);
|
||||||
if (!xprt)
|
if (xprt)
|
||||||
goto out;
|
svc_handle_xprt(rqstp, xprt);
|
||||||
|
|
||||||
len = svc_handle_xprt(rqstp, xprt);
|
|
||||||
|
|
||||||
/* No data, incomplete (TCP) read, or accept() */
|
|
||||||
if (len <= 0)
|
|
||||||
goto out_release;
|
|
||||||
|
|
||||||
trace_svc_xdr_recvfrom(&rqstp->rq_arg);
|
|
||||||
|
|
||||||
clear_bit(XPT_OLD, &xprt->xpt_flags);
|
|
||||||
|
|
||||||
rqstp->rq_chandle.defer = svc_defer;
|
|
||||||
|
|
||||||
if (serv->sv_stats)
|
|
||||||
serv->sv_stats->netcnt++;
|
|
||||||
percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived);
|
|
||||||
rqstp->rq_stime = ktime_get();
|
|
||||||
svc_process(rqstp);
|
|
||||||
out:
|
out:
|
||||||
return;
|
|
||||||
out_release:
|
|
||||||
rqstp->rq_res.len = 0;
|
|
||||||
svc_xprt_release(rqstp);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(svc_recv);
|
EXPORT_SYMBOL_GPL(svc_recv);
|
||||||
|
|
||||||
@@ -890,7 +881,6 @@ EXPORT_SYMBOL_GPL(svc_recv);
|
|||||||
void svc_drop(struct svc_rqst *rqstp)
|
void svc_drop(struct svc_rqst *rqstp)
|
||||||
{
|
{
|
||||||
trace_svc_drop(rqstp);
|
trace_svc_drop(rqstp);
|
||||||
svc_xprt_release(rqstp);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(svc_drop);
|
EXPORT_SYMBOL_GPL(svc_drop);
|
||||||
|
|
||||||
@@ -906,8 +896,6 @@ void svc_send(struct svc_rqst *rqstp)
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
xprt = rqstp->rq_xprt;
|
xprt = rqstp->rq_xprt;
|
||||||
if (!xprt)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* calculate over-all length */
|
/* calculate over-all length */
|
||||||
xb = &rqstp->rq_res;
|
xb = &rqstp->rq_res;
|
||||||
@@ -920,7 +908,6 @@ void svc_send(struct svc_rqst *rqstp)
|
|||||||
status = xprt->xpt_ops->xpo_sendto(rqstp);
|
status = xprt->xpt_ops->xpo_sendto(rqstp);
|
||||||
|
|
||||||
trace_svc_send(rqstp, status);
|
trace_svc_send(rqstp, status);
|
||||||
svc_xprt_release(rqstp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user