RB_NOSYNC -> no device_shutdown ?

John Baldwin jhb at freebsd.org
Tue Dec 20 14:52:48 UTC 2011


On Saturday, December 17, 2011 6:07:51 pm Andriy Gapon wrote:
> 
> I look at the following code:
> 
> static void
> module_init(void *arg)
> {
> 
>         sx_init(&modules_sx, "module subsystem sx lock");
>         TAILQ_INIT(&modules);
>         EVENTHANDLER_REGISTER(shutdown_final, module_shutdown, NULL,
>             SHUTDOWN_PRI_DEFAULT);
> }
> 
> SYSINIT(module, SI_SUB_KLD, SI_ORDER_FIRST, module_init, 0);
> 
> static void
> module_shutdown(void *arg1, int arg2)
> {
>         module_t mod;
> 
>         if (arg2 & RB_NOSYNC)
>                 return;
>         mtx_lock(&Giant);
>         MOD_SLOCK;
>         TAILQ_FOREACH_REVERSE(mod, &modules, modulelist, link)
>                 MOD_EVENT(mod, MOD_SHUTDOWN);
>         MOD_SUNLOCK;
>         mtx_unlock(&Giant);
> }
> 
> and wonder why RB_NOSYNC is overloaded to mean that no
> MOD_SHUTDOWN/device_shutdown cleanup should be done?

Presumably most device_shutdown handlers were used for syncing storage when 
the module stuff was first added.  I'm not sure how you would fix this now 
since you can't easily pass the 'arg2' flags down to each handler so that the 
appropriate ones could skip their shutdown actions.

-- 
John Baldwin


More information about the freebsd-hackers mailing list