Subject: VFS LKMs & pool_init() panic
To: None <tech-kern@netbsd.org>
From: Jaromir Dolecek <dolecek@ics.muni.cz>
List: tech-kern
Date: 03/11/2000 17:10:00
Hi,
I've had occasional panics (kernel traps) when I've loaded and
unloaded a msdosfs LKM several times.

I've finally nailed the problem down to these few lines in pool_init()
(527+):

	/* Insert into the list of all pools. */
	simple_lock(&pool_head_slock);
	TAILQ_INSERT_TAIL(&pool_head, pp, pr_poollist);
	simple_unlock(&pool_head_slock);

After I changed msdosfs's lkminit_vfs.c to call pool_destroy() on
it's pool before the fs is detached, everything is fine and I had
no more panics from that point on.

The problem here is that a LKM is unloaded, it doesn't have a chance
to free it's resources. Besides wasting memory on every load/unload,
this may leave dangling pointers in the list of pools or whatever.

Solutions would be to add a new VFS routine, say vfs_done,
which would be called from vfs_detach() - so that each
filesystem would have a chance to clean up whatever it needs,
before it's unloaded.

Opinions ? Anyone has any strong argument against it ?
The change would be pretty streightforward. I'd like to
implement it very soon (definitely before 1.5), as this would
break LKM binary compatibility again.

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
@@@@  Wanna a real operating system ? Go and get NetBSD, damn!  @@@@