[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#333052: Bug#333522: possible problem cause: wait4(-1)



On Thu, 2005-10-27 at 10:10 +0200, Marco d'Itri wrote:
> And then it fails for ehci-hcd too (which is not loaded at all).
> Rusty, do you have other ideas for debugging?

I have reread the bug reports, and meditated on this issue some more.
This is a possibility I was aware of when I changed to code to drop the
module_mutex before calling mod->init(), years ago.  Sorry it took so
long.

Module A depends on Module B.  Module B is already being loaded, and
doing its init call (slowly).  "modprobe A" sees B in the kernel and
calls insmod on B, but the kernel won't let A use B because it's not
ready.

There are two possible fixes:
(1) Queue in the kernel when a module isn't ready to be used
(non-trivial),
(2) modprobe can lock modules we depend on before checking whether
they're in the kernel.

The latter is the simplest option.  Please try this patch (it will be in
the next release, too).  If it seems to work, please ack.

Rusty.

--- modprobe.c.orig	2005-10-28 17:10:42.000000000 +1000
+++ modprobe.c	2005-10-28 17:23:32.000000000 +1000
@@ -814,20 +814,21 @@
 		       strip_vermagic, strip_modversion, cmdline_opts);
 	}
 
+	/* Lock before we look, in case it's initializing. */
+	fd = lock_file(mod->filename);
+	if (fd < 0) {
+		error("Could not open '%s': %s\n",
+		      mod->filename, strerror(errno));
+		goto out_optstring;
+	}
+
 	/* Don't do ANYTHING if already in kernel. */
 	if (!ignore_proc
 	    && module_in_kernel(newname ?: mod->modname, NULL) == 1) {
 		if (first_time)
 			error("Module %s already in kernel.\n",
 			      newname ?: mod->modname);
-		goto out_optstring;
-	}
-
-	fd = lock_file(mod->filename);
-	if (fd < 0) {
-		error("Could not open '%s': %s\n",
-		      mod->filename, strerror(errno));
-		goto out_optstring;
+		goto out_unlock;
 	}
 
 	command = find_command(mod->modname, commands);

-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman




Reply to: