Skip to content

Commit 7b719e2

Browse files
neilbrownchucklever
authored andcommitted
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: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent f78116d commit 7b719e2

File tree

5 files changed

+17
-46
lines changed

5 files changed

+17
-46
lines changed

fs/lockd/svc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ static void set_grace_period(struct net *net)
116116
static int
117117
lockd(void *vrqstp)
118118
{
119-
int err = 0;
120119
struct svc_rqst *rqstp = vrqstp;
121120
struct net *net = &init_net;
122121
struct lockd_net *ln = net_generic(net, lockd_net_id);
@@ -138,13 +137,7 @@ lockd(void *vrqstp)
138137

139138
timeout = nlmsvc_retry_blocked();
140139

141-
/*
142-
* Find a socket with data available and call its
143-
* recvfrom routine.
144-
*/
145-
err = svc_recv(rqstp, timeout);
146-
if (err == -EAGAIN || err == -EINTR)
147-
continue;
140+
svc_recv(rqstp, timeout);
148141
}
149142
if (nlmsvc_ops)
150143
nlmsvc_invalidate_all();

fs/nfs/callback.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,12 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net)
7474
static int
7575
nfs4_callback_svc(void *vrqstp)
7676
{
77-
int err;
7877
struct svc_rqst *rqstp = vrqstp;
7978

8079
set_freezable();
8180

82-
while (!kthread_freezable_should_stop(NULL)) {
83-
/*
84-
* Listen for a request on the socket
85-
*/
86-
err = svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
87-
if (err == -EAGAIN || err == -EINTR)
88-
continue;
89-
}
81+
while (!kthread_freezable_should_stop(NULL))
82+
svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
9083

9184
svc_exit_thread(rqstp);
9285
return 0;

fs/nfsd/nfssvc.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ nfsd(void *vrqstp)
939939
struct svc_xprt *perm_sock = list_entry(rqstp->rq_server->sv_permsocks.next, typeof(struct svc_xprt), xpt_list);
940940
struct net *net = perm_sock->xpt_net;
941941
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
942-
int err;
943942

944943
/* At this point, the thread shares current->fs
945944
* with the init process. We need to create files with the
@@ -958,19 +957,11 @@ nfsd(void *vrqstp)
958957
/*
959958
* The main request loop
960959
*/
961-
for (;;) {
960+
while (!kthread_should_stop()) {
962961
/* Update sv_maxconn if it has changed */
963962
rqstp->rq_server->sv_maxconn = nn->max_connections;
964963

965-
/*
966-
* Find a socket with data available and call its
967-
* recvfrom routine.
968-
*/
969-
while ((err = svc_recv(rqstp, 60*60*HZ)) == -EAGAIN)
970-
;
971-
if (err == -EINTR)
972-
break;
973-
964+
svc_recv(rqstp, 60*60*HZ);
974965
validate_process_creds();
975966
}
976967

include/linux/sunrpc/svcsock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline u32 svc_sock_final_rec(struct svc_sock *svsk)
5757
* Function prototypes.
5858
*/
5959
void svc_close_net(struct svc_serv *, struct net *);
60-
int svc_recv(struct svc_rqst *, long);
60+
void svc_recv(struct svc_rqst *, long);
6161
void svc_send(struct svc_rqst *rqstp);
6262
void svc_drop(struct svc_rqst *);
6363
void svc_sock_update_bufs(struct svc_serv *serv);

net/sunrpc/svc_xprt.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static void svc_check_conn_limits(struct svc_serv *serv)
679679
}
680680
}
681681

682-
static int svc_alloc_arg(struct svc_rqst *rqstp)
682+
static bool svc_alloc_arg(struct svc_rqst *rqstp)
683683
{
684684
struct svc_serv *serv = rqstp->rq_server;
685685
struct xdr_buf *arg = &rqstp->rq_arg;
@@ -704,7 +704,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
704704
set_current_state(TASK_IDLE);
705705
if (kthread_should_stop()) {
706706
set_current_state(TASK_RUNNING);
707-
return -EINTR;
707+
return false;
708708
}
709709
trace_svc_alloc_arg_err(pages, ret);
710710
memalloc_retry_wait(GFP_KERNEL);
@@ -723,7 +723,7 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
723723
arg->tail[0].iov_len = 0;
724724

725725
rqstp->rq_xid = xdr_zero;
726-
return 0;
726+
return true;
727727
}
728728

729729
static bool
@@ -785,8 +785,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
785785
percpu_counter_inc(&pool->sp_threads_timedout);
786786

787787
if (kthread_should_stop())
788-
return ERR_PTR(-EINTR);
789-
return ERR_PTR(-EAGAIN);
788+
return NULL;
789+
return NULL;
790790
out_found:
791791
/* Normally we will wait up to 5 seconds for any required
792792
* cache information to be provided.
@@ -868,32 +868,27 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
868868
* organised not to touch any cachelines in the shared svc_serv
869869
* structure, only cachelines in the local svc_pool.
870870
*/
871-
int svc_recv(struct svc_rqst *rqstp, long timeout)
871+
void svc_recv(struct svc_rqst *rqstp, long timeout)
872872
{
873873
struct svc_xprt *xprt = NULL;
874874
struct svc_serv *serv = rqstp->rq_server;
875-
int len, err;
875+
int len;
876876

877-
err = svc_alloc_arg(rqstp);
878-
if (err)
877+
if (!svc_alloc_arg(rqstp))
879878
goto out;
880879

881880
try_to_freeze();
882881
cond_resched();
883-
err = -EINTR;
884882
if (kthread_should_stop())
885883
goto out;
886884

887885
xprt = svc_get_next_xprt(rqstp, timeout);
888-
if (IS_ERR(xprt)) {
889-
err = PTR_ERR(xprt);
886+
if (!xprt)
890887
goto out;
891-
}
892888

893889
len = svc_handle_xprt(rqstp, xprt);
894890

895891
/* No data, incomplete (TCP) read, or accept() */
896-
err = -EAGAIN;
897892
if (len <= 0)
898893
goto out_release;
899894

@@ -907,12 +902,11 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
907902
serv->sv_stats->netcnt++;
908903
rqstp->rq_stime = ktime_get();
909904
svc_process(rqstp);
910-
return 0;
905+
out:
906+
return;
911907
out_release:
912908
rqstp->rq_res.len = 0;
913909
svc_xprt_release(rqstp);
914-
out:
915-
return err;
916910
}
917911
EXPORT_SYMBOL_GPL(svc_recv);
918912

0 commit comments

Comments
 (0)