From: Kinglong Mee <kinglongmee@gmail.com>
To: linux-nfs@vger.kernel.org, "J. Bruce Fields" <bfields@fieldses.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
kinglongmee@gmail.com, skinsbursky@parallels.com,
Trond Myklebust <trond.myklebust@primarydata.com>
Subject: [PATCH] nfsd: Fix nfsd leaks sunrpc module references
Date: Mon, 4 Jan 2016 11:15:21 +0800 [thread overview]
Message-ID: <5689E3C9.1010708@gmail.com> (raw)
In-Reply-To: <20150911104517.GA4947@stefanha-thinkpad.home>
Stefan Hajnoczi reports,
nfsd leaks 3 references to the sunrpc module here:
# echo -n "asdf 1234" >/proc/fs/nfsd/portlist
bash: echo: write error: Protocol not supported
Now stop nfsd and try unloading the kernel modules:
# systemctl stop nfs-server
# systemctl stop nfs
# systemctl stop proc-fs-nfsd.mount
# systemctl stop var-lib-nfs-rpc_pipefs.mount
# rmmod nfsd
# rmmod nfs_acl
# rmmod lockd
# rmmod auth_rpcgss
# rmmod sunrpc
rmmod: ERROR: Module sunrpc is in use
# lsmod | grep rpc
sunrpc 315392 3
It is caused by nfsd don't cleanup rpcb program for nfsd
when destroying svc service after creating xprt fail.
Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/nfsd/nfssvc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index ad4e237..543de5f 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -314,14 +314,13 @@ static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
* write_ports can create the server without actually starting
* any threads--if we get shut down before any threads are
* started, then nfsd_last_thread will be run before any of this
- * other initialization has been done.
+ * other initialization has been done except the rpcb information.
*/
+ svc_rpcb_cleanup(serv, net);
if (!nn->nfsd_net_up)
return;
- nfsd_shutdown_net(net);
-
- svc_rpcb_cleanup(serv, net);
+ nfsd_shutdown_net(net);
printk(KERN_WARNING "nfsd: last server has exited, flushing export "
"cache\n");
nfsd_export_flush(net);
--
2.5.0
next prev parent reply other threads:[~2016-01-04 3:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-11 10:45 nfsd leaks 3 sunrpc module references Stefan Hajnoczi
2016-01-04 3:15 ` Kinglong Mee [this message]
2016-01-04 9:03 ` [PATCH] nfsd: Fix nfsd leaks " Stefan Hajnoczi
2016-01-04 22:39 ` J. Bruce Fields
2016-01-05 0:49 ` Kinglong Mee
2016-01-05 22:44 ` J. Bruce Fields
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=5689E3C9.1010708@gmail.com \
--to=kinglongmee@gmail.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=skinsbursky@parallels.com \
--cc=stefanha@redhat.com \
--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).