diff mbox

lockd: added cleanup checks in exit_net hook

Message ID cbc8333b-95a5-0bb2-9ef8-645ba3bb6185@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vasily Averin Nov. 3, 2017, 4:32 p.m. UTC
Patch generates warnings if exit_net hook detects that 
structures initialized in init_net hook are still in use. 

[ 2355.129218] per-netns lockd_manager.list is not empty
[ 2355.130483] WARNING: CPU: 7 PID: 97 at fs/lockd/svc.c:682 lockd_exit_net+0x52/0x80 [lockd]
...
[ 2355.148073] per-netns grace_period_end dealyed work was not cancelled
[ 2355.149205] WARNING: CPU: 7 PID: 97 at fs/lockd/svc.c:686 lockd_exit_net+0x78/0x80 [lockd]

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/lockd/svc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox

Patch

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 809cbcc..119af0a 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -690,6 +690,14 @@  static int lockd_init_net(struct net *net)
 
 static void lockd_exit_net(struct net *net)
 {
+	struct lockd_net *ln = net_generic(net, lockd_net_id);
+
+	WARN(!list_empty(&ln->lockd_manager.list),
+		"per-netns lockd_manager.list is not empty\n");
+	WARN(!list_empty(&ln->nsm_handles),
+		"per-netns nsm_handles list is not empty\n");
+	WARN(delayed_work_pending(&ln->grace_period_end),
+		"per-netns grace_period_end dealyed work was not cancelled\n");
 }
 
 static struct pernet_operations lockd_net_ops = {