Skip to content

Commit 9ca6705

Browse files
bcodding-rhchucklever
authored andcommitted
SUNRPC: Fix a server shutdown leak
Fix a race where kthread_stop() may prevent the threadfn from ever getting called. If that happens the svc_rqst will not be cleaned up. Fixes: ed6473d ("NFSv4: Fix callback server shutdown") Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent fd9a2e1 commit 9ca6705

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/sunrpc/svc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
798798
static int
799799
svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
800800
{
801+
struct svc_rqst *rqstp;
801802
struct task_struct *task;
802803
unsigned int state = serv->sv_nrthreads-1;
803804

@@ -806,7 +807,10 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
806807
task = choose_victim(serv, pool, &state);
807808
if (task == NULL)
808809
break;
809-
kthread_stop(task);
810+
rqstp = kthread_data(task);
811+
/* Did we lose a race to svo_function threadfn? */
812+
if (kthread_stop(task) == -EINTR)
813+
svc_exit_thread(rqstp);
810814
nrservs++;
811815
} while (nrservs < 0);
812816
return 0;

0 commit comments

Comments
 (0)