target: Fix target_core_register_fabric() for built-in fabric modules

If we try to create a fabric directory in configfs for one of the
default hard-coded fabric modules (iscsi and loopback), and that
fabric is actually built into the kernel, then the operation will
spuriously fail because request_module() (for the code that's already
linked into the kernel) fails.

Fix this by running the autoprobing code only if an initial
target_core_get_fabric() fails.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
Roland Dreier 2014-11-14 12:54:36 -08:00 committed by Nicholas Bellinger
parent b1a5ad006b
commit e7b7af6e98

View File

@ -126,6 +126,12 @@ static struct config_group *target_core_register_fabric(
pr_debug("Target_Core_ConfigFS: REGISTER -> group: %p name:" pr_debug("Target_Core_ConfigFS: REGISTER -> group: %p name:"
" %s\n", group, name); " %s\n", group, name);
tf = target_core_get_fabric(name);
if (!tf) {
pr_err("target_core_register_fabric() trying autoload for %s\n",
name);
/* /*
* Below are some hardcoded request_module() calls to automatically * Below are some hardcoded request_module() calls to automatically
* local fabric modules when the following is called: * local fabric modules when the following is called:
@ -136,6 +142,7 @@ static struct config_group *target_core_register_fabric(
* registered, but simply provids auto loading logic for modules with * registered, but simply provids auto loading logic for modules with
* mkdir(2) system calls with known TCM fabric modules. * mkdir(2) system calls with known TCM fabric modules.
*/ */
if (!strncmp(name, "iscsi", 5)) { if (!strncmp(name, "iscsi", 5)) {
/* /*
* Automatically load the LIO Target fabric module when the * Automatically load the LIO Target fabric module when the
@ -165,6 +172,8 @@ static struct config_group *target_core_register_fabric(
} }
tf = target_core_get_fabric(name); tf = target_core_get_fabric(name);
}
if (!tf) { if (!tf) {
pr_err("target_core_get_fabric() failed for %s\n", pr_err("target_core_get_fabric() failed for %s\n",
name); name);