Hmm, this can't happen now. The try_module_get() will fail if the module
is going away and so qdisc_create won't create a new qdisc.
> BTW, Rusty, a question... I do not understand, what is purpose of this
> "new" module stuff at all?
The idea is to use try_module_get() before using any interface
registered by the module. Every module has a state associated to it: if
the module has been loaded but it is still in its init section its
state will be MODULE_STATE_COMING (and try_module_get() will fail);
if the module is in process of being unloaded its state will be
MODULE_STATE_LIVE (and try_module_get() will fail); otherwise the state
will be MODULE_STATE_LIVE (and try_module_get() will success).
If we use try_module_get() before using the module and module_put() when
we are done everything will work:
int create_foo(foo **new) {
if (try_module_get(foo->owner) == 0)
/* Module is being unloaded, it's not safe to use it */
return -ENOSYS;
*new = foo->new_foo();
}
void destroy_foo(foo *foo) {
foo->finalize();
module_put(foo->owner);
}
This is what I've done for the packet scheduler: try_module_get() is
called *before* cloning the qdisc and if it fails the qdisc won't be
cloned. module_put() is called in qdisc_destroy(), after ->destroy(),
when we are sure that nobody will ever use a reference to the qdisc.
Luca
-- Reply-To: kronos@kronoz.cjb.net Home: http://kronoz.cjb.net Non capisco tutta questa eccitazione per il Multitasking: io sono anni che leggo in bagno. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/