Commit 7b719e2b authored by NeilBrown's avatar NeilBrown Committed by Chuck Lever

SUNRPC: change svc_recv() to return void.

svc_recv() currently returns a 0 on success or one of two errors:
 - -EAGAIN means no message was successfully received
 - -EINTR means the thread has been told to stop

Previously nfsd would stop as the result of a signal as well as
following kthread_stop().  In that case the difference was useful: EINTR
means stop unconditionally.  EAGAIN means stop if kthread_should_stop(),
continue otherwise.

Now threads only exit when kthread_should_stop() so we don't need the
distinction.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent f78116d3
...@@ -116,7 +116,6 @@ static void set_grace_period(struct net *net) ...@@ -116,7 +116,6 @@ static void set_grace_period(struct net *net)
static int static int
lockd(void *vrqstp) lockd(void *vrqstp)
{ {
int err = 0;
struct svc_rqst *rqstp = vrqstp; struct svc_rqst *rqstp = vrqstp;
struct net *net = &init_net; struct net *net = &init_net;
struct lockd_net *ln = net_generic(net, lockd_net_id); struct lockd_net *ln = net_generic(net, lockd_net_id);
...@@ -138,13 +137,7 @@ lockd(void *vrqstp) ...@@ -138,13 +137,7 @@ lockd(void *vrqstp)
timeout = nlmsvc_retry_blocked(); timeout = nlmsvc_retry_blocked();
/* svc_recv(rqstp, timeout);
* Find a socket with data available and call its
* recvfrom routine.
*/
err = svc_recv(rqstp, timeout);
if (err == -EAGAIN || err == -EINTR)
continue;
} }
if (nlmsvc_ops) if (nlmsvc_ops)
nlmsvc_invalidate_all(); nlmsvc_invalidate_all();
......
...@@ -74,19 +74,12 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net) ...@@ -74,19 +74,12 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net)
static int static int
nfs4_callback_svc(void *vrqstp) nfs4_callback_svc(void *vrqstp)
{ {
int err;
struct svc_rqst *rqstp = vrqstp; struct svc_rqst *rqstp = vrqstp;
set_freezable(); set_freezable();
while (!kthread_freezable_should_stop(NULL)) { while (!kthread_freezable_should_stop(NULL))
/* svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
* Listen for a request on the socket
*/
err = svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
if (err == -EAGAIN || err == -EINTR)
continue;
}
svc_exit_thread(rqstp); svc_exit_thread(rqstp);
return 0; return 0;
......
...@@ -939,7 +939,6 @@ nfsd(void *vrqstp) ...@@ -939,7 +939,6 @@ nfsd(void *vrqstp)
struct svc_xprt *perm_sock = list_entry(rqstp->rq_server->sv_permsocks.next, typeof(struct svc_xprt), xpt_list); struct svc_xprt *perm_sock = list_entry(rqstp->rq_server->sv_permsocks.next, typeof(struct svc_xprt), xpt_list);
struct net *net = perm_sock->xpt_net; struct net *net = perm_sock->xpt_net;
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int err;
/* At this point, the thread shares current->fs /* At this point, the thread shares current->fs
* with the init process. We need to create files with the * with the init process. We need to create files with the
...@@ -958,19 +957,11 @@ nfsd(void *vrqstp) ...@@ -958,19 +957,11 @@ nfsd(void *vrqstp)
/* /*
* The main request loop * The main request loop
*/ */
for (;;) { while (!kthread_should_stop()) {
/* Update sv_maxconn if it has changed */ /* Update sv_maxconn if it has changed */
rqstp->rq_server->sv_maxconn = nn->max_connections; rqstp->rq_server->sv_maxconn = nn->max_connections;
/* svc_recv(rqstp, 60*60*HZ);
* Find a socket with data available and call its
* recvfrom routine.
*/
while ((err = svc_recv(rqstp, 60*60*HZ)) == -EAGAIN)
;
if (err == -EINTR)
break;
validate_process_creds(); validate_process_creds();
} }
......
...@@ -57,7 +57,7 @@ static inline u32 svc_sock_final_rec(struct svc_sock *svsk) ...@@ -57,7 +57,7 @@ static inline u32 svc_sock_final_rec(struct svc_sock *svsk)
* Function prototypes. * Function prototypes.
*/ */
void svc_close_net(struct svc_serv *, struct net *); void svc_close_net(struct svc_serv *, struct net *);
int svc_recv(struct svc_rqst *, long); void svc_recv(struct svc_rqst *, long);
void svc_send(struct svc_rqst *rqstp); void svc_send(struct svc_rqst *rqstp);
void svc_drop(struct svc_rqst *); void svc_drop(struct svc_rqst *);
void svc_sock_update_bufs(struct svc_serv *serv); void svc_sock_update_bufs(struct svc_serv *serv);
......
...@@ -679,7 +679,7 @@ static void svc_check_conn_limits(struct svc_serv *serv) ...@@ -679,7 +679,7 @@ static void svc_check_conn_limits(struct svc_serv *serv)
} }
} }
static int svc_alloc_arg(struct svc_rqst *rqstp) static bool svc_alloc_arg(struct svc_rqst *rqstp)
{ {
struct svc_serv *serv = rqstp->rq_server; struct svc_serv *serv = rqstp->rq_server;
struct xdr_buf *arg = &rqstp->rq_arg; struct xdr_buf *arg = &rqstp->rq_arg;
...@@ -704,7 +704,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) ...@@ -704,7 +704,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
set_current_state(TASK_IDLE); set_current_state(TASK_IDLE);
if (kthread_should_stop()) { if (kthread_should_stop()) {
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
return -EINTR; return false;
} }
trace_svc_alloc_arg_err(pages, ret); trace_svc_alloc_arg_err(pages, ret);
memalloc_retry_wait(GFP_KERNEL); memalloc_retry_wait(GFP_KERNEL);
...@@ -723,7 +723,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) ...@@ -723,7 +723,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
arg->tail[0].iov_len = 0; arg->tail[0].iov_len = 0;
rqstp->rq_xid = xdr_zero; rqstp->rq_xid = xdr_zero;
return 0; return true;
} }
static bool static bool
...@@ -785,8 +785,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -785,8 +785,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
percpu_counter_inc(&pool->sp_threads_timedout); percpu_counter_inc(&pool->sp_threads_timedout);
if (kthread_should_stop()) if (kthread_should_stop())
return ERR_PTR(-EINTR); return NULL;
return ERR_PTR(-EAGAIN); return NULL;
out_found: out_found:
/* Normally we will wait up to 5 seconds for any required /* Normally we will wait up to 5 seconds for any required
* cache information to be provided. * cache information to be provided.
...@@ -868,32 +868,27 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) ...@@ -868,32 +868,27 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
* organised not to touch any cachelines in the shared svc_serv * organised not to touch any cachelines in the shared svc_serv
* structure, only cachelines in the local svc_pool. * structure, only cachelines in the local svc_pool.
*/ */
int svc_recv(struct svc_rqst *rqstp, long timeout) void svc_recv(struct svc_rqst *rqstp, long timeout)
{ {
struct svc_xprt *xprt = NULL; struct svc_xprt *xprt = NULL;
struct svc_serv *serv = rqstp->rq_server; struct svc_serv *serv = rqstp->rq_server;
int len, err; int len;
err = svc_alloc_arg(rqstp); if (!svc_alloc_arg(rqstp))
if (err)
goto out; goto out;
try_to_freeze(); try_to_freeze();
cond_resched(); cond_resched();
err = -EINTR;
if (kthread_should_stop()) if (kthread_should_stop())
goto out; goto out;
xprt = svc_get_next_xprt(rqstp, timeout); xprt = svc_get_next_xprt(rqstp, timeout);
if (IS_ERR(xprt)) { if (!xprt)
err = PTR_ERR(xprt);
goto out; goto out;
}
len = svc_handle_xprt(rqstp, xprt); len = svc_handle_xprt(rqstp, xprt);
/* No data, incomplete (TCP) read, or accept() */ /* No data, incomplete (TCP) read, or accept() */
err = -EAGAIN;
if (len <= 0) if (len <= 0)
goto out_release; goto out_release;
...@@ -907,12 +902,11 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) ...@@ -907,12 +902,11 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
serv->sv_stats->netcnt++; serv->sv_stats->netcnt++;
rqstp->rq_stime = ktime_get(); rqstp->rq_stime = ktime_get();
svc_process(rqstp); svc_process(rqstp);
return 0; out:
return;
out_release: out_release:
rqstp->rq_res.len = 0; rqstp->rq_res.len = 0;
svc_xprt_release(rqstp); svc_xprt_release(rqstp);
out:
return err;
} }
EXPORT_SYMBOL_GPL(svc_recv); EXPORT_SYMBOL_GPL(svc_recv);
......
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