From: Kinglong Mee <kinglongmee@gmail.com>
To: Trond Myklebust <trond.myklebust@primarydata.com>,
linux-nfs@vger.kernel.org
Cc: Anna Schumaker <Anna.Schumaker@netapp.com>,
Kinglong Mee <kinglongmee@gmail.com>
Subject: Re: [PATCH v2 2/2] NFSv4.x/callback: make sure callback threads are interruptible
Date: Fri, 3 Mar 2017 21:35:45 +0800 [thread overview]
Message-ID: <63cf52a3-d2dc-baf2-8fcd-e49033a08eab@gmail.com> (raw)
In-Reply-To: <d8e459af-1efa-dae9-61b6-253e8945831f@gmail.com>
Ping ...
With the [1/2]??
thanks,
Kinglong Mee
On 1/19/2017 16:37, Kinglong Mee wrote:
>
>
> Commit bb6aeba736ba "NFSv4.x: Switch to using svc_set_num_threads()
> to manage the callback threads" change nfs start/stop threads
> through svc_set_num_threads().
>
> It destroy old threads by SIGINT signal, but our nfs4_callback_svc()
> isn't interruptible. So that, the callback threads will never be killed.
>
> # mount -t nfs -overs=4.2 nfstestnic:/ /mnt/
> # ps -ajx |grep NFS
> 2 5927 0 0 ? -1 S 0 0:00 [NFSv4 callback]
> # umount /mnt
> # ps -ajx |grep NFS
> 2 5927 0 0 ? -1 S 0 0:00 [NFSv4 callback]
> # mount -t nfs -overs=4.2 nfstestnic:/ /mnt/
> # umount /mnt
> # ps -ajx |grep NFS
> 2 5927 0 0 ? -1 S 0 0:00 [NFSv4 callback]
> 2 5963 0 0 ? -1 S 0 0:00 [NFSv4 callback]
>
> After one mount, there will be one callback thread left that cannot killed,
> the same time, nfs.ko will never be unplugged.
>
> v2, drop the wrong setting of rqstp->rq_server = NULL
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
> fs/nfs/callback.c | 39 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
> index 0a21150..2a0fffd 100644
> --- a/fs/nfs/callback.c
> +++ b/fs/nfs/callback.c
> @@ -73,6 +73,15 @@ nfs4_callback_svc(void *vrqstp)
> int err;
> struct svc_rqst *rqstp = vrqstp;
>
> + /*
> + * thread is spawned with all signals set to SIG_IGN, re-enable
> + * the ones that will bring down the thread
> + */
> + allow_signal(SIGKILL);
> + allow_signal(SIGHUP);
> + allow_signal(SIGINT);
> + allow_signal(SIGQUIT);
> +
> set_freezable();
>
> while (!kthread_should_stop()) {
> @@ -80,11 +89,18 @@ nfs4_callback_svc(void *vrqstp)
> * Listen for a request on the socket
> */
> err = svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
> - if (err == -EAGAIN || err == -EINTR)
> + if (err == -EAGAIN)
> continue;
> + else if (err == -EINTR)
> + break;
> svc_process(rqstp);
> }
> - return 0;
> +
> + flush_signals(current);
> +
> + /* Release the thread */
> + svc_exit_thread(rqstp);
> + module_put_and_exit(0);
> }
>
> #if defined(CONFIG_NFS_V4_1)
> @@ -100,6 +116,15 @@ nfs41_callback_svc(void *vrqstp)
> int error;
> DEFINE_WAIT(wq);
>
> + /*
> + * thread is spawned with all signals set to SIG_IGN, re-enable
> + * the ones that will bring down the thread
> + */
> + allow_signal(SIGKILL);
> + allow_signal(SIGHUP);
> + allow_signal(SIGINT);
> + allow_signal(SIGQUIT);
> +
> set_freezable();
>
> while (!kthread_should_stop()) {
> @@ -121,11 +146,17 @@ nfs41_callback_svc(void *vrqstp)
> } else {
> spin_unlock_bh(&serv->sv_cb_lock);
> schedule();
> + if (signalled())
> + break;
> finish_wait(&serv->sv_cb_waitq, &wq);
> }
> - flush_signals(current);
> }
> - return 0;
> +
> + flush_signals(current);
> +
> + /* Release the thread */
> + svc_exit_thread(rqstp);
> + module_put_and_exit(0);
> }
>
> static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
>
next prev parent reply other threads:[~2017-03-03 16:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 8:37 [PATCH v2 2/2] NFSv4.x/callback: make sure callback threads are interruptible Kinglong Mee
2017-03-03 13:35 ` Kinglong Mee [this message]
2017-04-24 12:19 ` Benjamin Coddington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63cf52a3-d2dc-baf2-8fcd-e49033a08eab@gmail.com \
--to=kinglongmee@gmail.com \
--cc=Anna.Schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).