code in GEOM thread could not use vnode API (Was: alq_open_flags() panics in _mtx_lock_flags())

Kostik Belousov kostikbel at gmail.com
Mon Oct 3 16:20:53 UTC 2011


On Mon, Oct 03, 2011 at 04:18:59PM +0400, Lev Serebryakov wrote:
> Hello, Lawrence.
> You wrote 3 октября 2011 г., 13:57:04:
> 
> > I know nothing about VFS, but wonder if it's something to do with the
> > credentials you pass in?
>   They looks Ok. Not NULL, at least :) I'm passing
>  "curtrhead->td_ucred".
> 
> > Lev, are you able to share your code with us?
>   Yes, of course. Minimal code, which trigger this error, attached.
>  Build, load module and PANIC!
> 
>   This is geom_zero module, which try to create ALQ with name
>   "/var/log/zero.alq.log" on it load (not creation! So, you don't need
>   even create such GEOM!). Please note, that "init" callback of GEOM
>   class is called in g_event GEOM thread.
> 
>    Code is for 9.0/10.0
> 
>   My code is rewritten with usage of working thread already, and it
> works without any panic. But worker thread looks like overkill for
> simple case "write 24 bytes record to ALQ for each BIO" to me.
> 
>   So I could prove, that this code PANIC because alq_open_flags() is
>  called from one of three GEOM threads.
Look at the body of e.g. g_io_schedule_down(), the
		THREAD_NO_SLEEPING();
call right before the call to geom start method.

Basically, you cannot use any kernel subsystem in the context of
the up/down threads that could sleep. This includes VFS, VM and
everything that is layered on top of it.

The decision is deliberate. Up and down shall only schedule the processing,
or perform the fast processing.

BTW, it must be obvious that trying to perform any VFS operation from geom
up or down causes deadlock.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20111003/8d445def/attachment.pgp


More information about the freebsd-fs mailing list