If path selector name unrecognised, attempt to load module with that name. --- diff/drivers/md/dm-path-selector.c 2004-09-28 18:06:33.000000000 +0100 +++ source/drivers/md/dm-path-selector.c 2004-09-28 18:06:20.000000000 +0100 @@ -25,38 +25,49 @@ static LIST_HEAD(_path_selectors); static DECLARE_RWSEM(_lock); -struct path_selector_type *__find_path_selector_type(const char *name) +struct ps_internal *__find_path_selector_type(const char *name) { struct ps_internal *psi; list_for_each_entry (psi, &_path_selectors, list) { if (!strcmp(name, psi->pst.name)) - return &psi->pst; + return psi; } return NULL; } -struct path_selector_type *dm_get_path_selector(const char *name) +static struct ps_internal *get_path_selector(const char *name) { - struct path_selector_type *pst; - - if (!name) - return NULL; + struct ps_internal *psi; down_read(&_lock); - pst = __find_path_selector_type(name); - if (pst) { - struct ps_internal *psi = pst_to_psi(pst); - - if ((psi->use == 0) && !try_module_get(pst->module)) + psi = __find_path_selector_type(name); + if (psi) { + if ((psi->use == 0) && !try_module_get(psi->pst.module)) psi = NULL; else psi->use++; } up_read(&_lock); - return pst; + return psi; +} + +struct path_selector_type *dm_get_path_selector(const char *name) +{ + struct ps_internal *psi; + + if (!name) + return NULL; + + psi = get_path_selector(name); + if (!psi) { + request_module("dm-%s", name); + psi = get_path_selector(name); + } + + return psi ? &psi->pst : NULL; } void dm_put_path_selector(struct path_selector_type *pst) @@ -64,11 +75,10 @@ struct ps_internal *psi; down_read(&_lock); - pst = __find_path_selector_type(pst->name); - if (!pst) + psi = __find_path_selector_type(pst->name); + if (!psi) return; - psi = pst_to_psi(pst); if (--psi->use == 0) module_put(psi->pst.module); @@ -115,13 +125,12 @@ struct ps_internal *psi; down_write(&_lock); - pst = __find_path_selector_type(pst->name); - if (!pst) { + psi = __find_path_selector_type(pst->name); + if (!psi) { up_write(&_lock); return -EINVAL; } - psi = pst_to_psi(pst); if (psi->use) { up_write(&_lock); return -ETXTBSY;