From patchwork Mon Jan 4 03:15:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 7944951 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EEACBEEE5 for ; Mon, 4 Jan 2016 03:15:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6524020377 for ; Mon, 4 Jan 2016 03:15:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6837120373 for ; Mon, 4 Jan 2016 03:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752185AbcADDPf (ORCPT ); Sun, 3 Jan 2016 22:15:35 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33383 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974AbcADDPf (ORCPT ); Sun, 3 Jan 2016 22:15:35 -0500 Received: by mail-pf0-f182.google.com with SMTP id q63so158755852pfb.0 for ; Sun, 03 Jan 2016 19:15:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=h9/n7i7A8oDx0q29qxeCTtoLNUaS41H7yQTFybDzpzU=; b=EM5rqwaUIF5hrKooLmvvrfKKFj/TgqwW8wAJ7XvskfGpqDex5w+mBt2h3KZN08rb62 N7jTtXfyOx3Wc15tMRiwitupS+XgJ34W63zNui+Jpla0L+HahN8adYrhJnP/iinLDQWp rjsL8iwvatQYh2sLsXe+3qUB2+fxjg0qMCLFezHt0xDUzNAhCXOLf1/38M7F6AZSPZeH Y7HglH1kn3YKbWpbd1AKhKZBqCOpUNFEonQNsRak9A87767k519UZ+Eqrt5lYPUe8Ue+ gFU+cu6V7wppaHzOXlJ6D2Xp8axWOYq3TtGYq07wzl/IidOojIlNQsVQVh9aa8Xk12N0 Y75w== X-Received: by 10.98.86.195 with SMTP id h64mr124581172pfj.96.1451877334914; Sun, 03 Jan 2016 19:15:34 -0800 (PST) Received: from [192.168.22.11] ([204.45.182.86]) by smtp.googlemail.com with ESMTPSA id w26sm116974957pfi.78.2016.01.03.19.15.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 03 Jan 2016 19:15:34 -0800 (PST) From: Kinglong Mee Subject: [PATCH] nfsd: Fix nfsd leaks sunrpc module references To: linux-nfs@vger.kernel.org, "J. Bruce Fields" References: <20150911104517.GA4947@stefanha-thinkpad.home> Cc: Stefan Hajnoczi , kinglongmee@gmail.com, skinsbursky@parallels.com, Trond Myklebust Message-ID: <5689E3C9.1010708@gmail.com> Date: Mon, 4 Jan 2016 11:15:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Thunderbird/43.0 MIME-Version: 1.0 In-Reply-To: <20150911104517.GA4947@stefanha-thinkpad.home> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Kinglong Mee Tested-by: Stefan Hajnoczi --- 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);