8382f77
From d332ff69803046e66fc8ee37b16c3643c5ddce1a Mon Sep 17 00:00:00 2001
efcd02b
From: Cong Wang <xiyou.wangcong@gmail.com>
efcd02b
Date: Sat, 16 Aug 2014 12:36:46 -0700
efcd02b
Subject: [PATCH] nfs: fix kernel warning when removing proc entry
efcd02b
efcd02b
I saw the following kernel warning:
efcd02b
efcd02b
[ 1852.321222] ------------[ cut here ]------------
efcd02b
[ 1852.326527] WARNING: CPU: 0 PID: 118 at fs/proc/generic.c:521 remove_proc_entry+0x154/0x16b()
efcd02b
[ 1852.335630] remove_proc_entry: removing non-empty directory 'fs/nfsfs', leaking at least 'volumes'
efcd02b
[ 1852.344084] CPU: 0 PID: 118 Comm: kworker/u8:2 Not tainted 3.16.0+ #540
efcd02b
[ 1852.350036] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
efcd02b
[ 1852.354992] Workqueue: netns cleanup_net
efcd02b
[ 1852.358701]  0000000000000000 ffff880116f2fbd0 ffffffff819c03e9 ffff880116f2fc18
efcd02b
[ 1852.366474]  ffff880116f2fc08 ffffffff810744ee ffffffff811e0e6e ffff8800d4e96238
efcd02b
[ 1852.373507]  ffffffff81dbe665 ffff8800d46a5948 0000000000000005 ffff880116f2fc68
efcd02b
[ 1852.380224] Call Trace:
efcd02b
[ 1852.381976]  [<ffffffff819c03e9>] dump_stack+0x4d/0x66
efcd02b
[ 1852.385495]  [<ffffffff810744ee>] warn_slowpath_common+0x7a/0x93
efcd02b
[ 1852.389869]  [<ffffffff811e0e6e>] ? remove_proc_entry+0x154/0x16b
efcd02b
[ 1852.393987]  [<ffffffff8107457b>] warn_slowpath_fmt+0x4c/0x4e
efcd02b
[ 1852.397999]  [<ffffffff811e0e6e>] remove_proc_entry+0x154/0x16b
efcd02b
[ 1852.402034]  [<ffffffff8129c73d>] nfs_fs_proc_net_exit+0x53/0x56
efcd02b
[ 1852.406136]  [<ffffffff812a103b>] nfs_net_exit+0x12/0x1d
efcd02b
[ 1852.409774]  [<ffffffff81785bc9>] ops_exit_list+0x44/0x55
efcd02b
[ 1852.413529]  [<ffffffff81786389>] cleanup_net+0xee/0x182
efcd02b
[ 1852.417198]  [<ffffffff81088c9e>] process_one_work+0x209/0x40d
efcd02b
[ 1852.502320]  [<ffffffff81088bf7>] ? process_one_work+0x162/0x40d
efcd02b
[ 1852.587629]  [<ffffffff810890c1>] worker_thread+0x1f0/0x2c7
efcd02b
[ 1852.673291]  [<ffffffff81088ed1>] ? process_scheduled_works+0x2f/0x2f
efcd02b
[ 1852.759470]  [<ffffffff8108e079>] kthread+0xc9/0xd1
efcd02b
[ 1852.843099]  [<ffffffff8109427f>] ? finish_task_switch+0x3a/0xce
efcd02b
[ 1852.926518]  [<ffffffff8108dfb0>] ? __kthread_parkme+0x61/0x61
efcd02b
[ 1853.008565]  [<ffffffff819cbeac>] ret_from_fork+0x7c/0xb0
efcd02b
[ 1853.076477]  [<ffffffff8108dfb0>] ? __kthread_parkme+0x61/0x61
efcd02b
[ 1853.140653] ---[ end trace 69c4c6617f78e32d ]---
efcd02b
efcd02b
It looks wrong that we add "/proc/net/nfsfs" in nfs_fs_proc_net_init()
efcd02b
while remove "/proc/fs/nfsfs" in nfs_fs_proc_net_exit().
efcd02b
efcd02b
Bugzilla: 1132368
efcd02b
Upstream-status: Sent for 3.17-rcX
efcd02b
efcd02b
Fixes: commit 65b38851a17 (NFS: Fix /proc/fs/nfsfs/servers and /proc/fs/nfsfs/volumes)
efcd02b
Cc: Eric W. Biederman <ebiederm@xmission.com>
efcd02b
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
efcd02b
Cc: Dan Aloni <dan@kernelim.com>
efcd02b
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
efcd02b
---
efcd02b
 fs/nfs/client.c | 4 ++--
efcd02b
 1 file changed, 2 insertions(+), 2 deletions(-)
efcd02b
efcd02b
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
efcd02b
index 1c5ff6d58385..c117b96c7da9 100644
efcd02b
--- a/fs/nfs/client.c
efcd02b
+++ b/fs/nfs/client.c
efcd02b
@@ -1418,7 +1418,7 @@ int nfs_fs_proc_net_init(struct net *net)
efcd02b
 error_2:
efcd02b
 	remove_proc_entry("servers", nn->proc_nfsfs);
efcd02b
 error_1:
efcd02b
-	remove_proc_entry("fs/nfsfs", NULL);
efcd02b
+	remove_proc_entry("nfsfs", net->proc_net);
efcd02b
 error_0:
efcd02b
 	return -ENOMEM;
efcd02b
 }
efcd02b
@@ -1429,7 +1429,7 @@ void nfs_fs_proc_net_exit(struct net *net)
efcd02b
 
efcd02b
 	remove_proc_entry("volumes", nn->proc_nfsfs);
efcd02b
 	remove_proc_entry("servers", nn->proc_nfsfs);
efcd02b
-	remove_proc_entry("fs/nfsfs", NULL);
efcd02b
+	remove_proc_entry("nfsfs", net->proc_net);
efcd02b
 }
efcd02b
 
efcd02b
 /*
efcd02b
-- 
efcd02b
1.9.3
efcd02b