Hi Ingo

On Sat, Feb 18, 2012 at 9:51 PM, Ingo Saitz <i...@stud.uni-hannover.de> wrote:
> Moin
>
> I just got bitten by that bug today, too.
>
> On Tue, Feb 14, 2012 at 05:05:27PM -0200, Lucas De Marchi wrote:
>> I bet you have these rules in your config:
>>
>> install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe
>> --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; }
> ...
>
>> Marco, why are you shipping this with alsa? This creates dependency
>> loops, relying on modules being inserted to be able to break the
>> loops. It seems very fragile. What are you trying to accomplish with
>> that config?
>
> These are indeed useful, as it pulls in additional modules that give you
> the full functionality of the sound system. The problem seems to be that
> --ignore-install seems to get ignored by kmod version 5 resulting in
> endless recursive loops trying to insert these modules.

It's not ignoring install commands: --ignore-install doesn't apply for
dependencies and from the description and the name of the modules what
seems to be occurring is that a module has snd as a dependency, which
is triggering the snd install command over and over again.

I prepared the patch attached... I couldn't test it (I don't have an
environment ready for this right now), but I think it fixes the issue.
Marco, I'm assuming you already backported the patch "libkmod-module:
probe: fix infinite loop with softdeps", right?

Could you check if this works for you?

>
> But since 3.12 module-init-tools (and kmod, too) supports the softdep
> keyword in modprobe.d/. After changing the above rules to use "softdep"
> instead of "install", the bug was gone.
>
> For example the rule qouted above using softdep should read:
>
> softdep snd post: snd-ioctl32 snd-seq
>
> I think this change could be done now in unstable, since "softdep" is already
> supported by the module-init-tools in stable.

Yeah, you should definitely be using softdeps for this, but we still
need to support ugly old use cases.


Regards,
Lucas De Marchi
From 30549a8a2a57c9266fbe2adda9f831a2ff76a1bf Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demar...@profusion.mobi>
Date: Sun, 19 Feb 2012 04:20:30 -0200
Subject: [PATCH] libkmod-module: probe: check if module exists for install
 cmds

Mimic what module-init-tools was doing before running install commands:
check if a module with the same name is already loaded in kerne, and if
it is, bail out.

This fixes the issue with some install commands used in Debian with
alsa-base package:

install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; }
install snd_rawmidi /sbin/modprobe --ignore-install snd-rawmidi && { /sbin/modprobe --quiet snd-seq-midi ; : ; }
install snd_emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && { /sbin/modprobe --quiet snd-emu10k1-synth ; : ; }
install snd_pcm modprobe --ignore-install snd-pcm $CMDLINE_OPTS && { modprobe --quiet snd-pcm-oss ; : ; }
install snd_mixer modprobe --ignore-install snd-mixer $CMDLINE_OPTS && { modprobe --quiet snd-mixer-oss ; : ; }
install snd_seq modprobe --ignore-install snd-seq $CMDLINE_OPTS && { modprobe --quiet snd-seq-midi ; modprobe --quiet snd-seq-oss ; : ; }
---
 libkmod/libkmod-module.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 637b792..69f1265 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -1192,7 +1192,17 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 		struct kmod_module *m = l->data;
 		const char *moptions = kmod_module_get_options(m);
 		const char *cmd = kmod_module_get_install_commands(m);
-		char *options = module_options_concat(moptions,
+		char *options;
+
+		if (!(flags & KMOD_PROBE_IGNORE_LOADED)
+						&& module_is_inkernel(m)) {
+			DBG(mod->ctx, "Ignoring module '%s': already loaded\n",
+								m->name);
+			err = -EEXIST;
+			goto finish_module;
+		}
+
+		options = module_options_concat(moptions,
 					m == mod ? extra_options : NULL);
 
 		if (cmd != NULL && !m->ignorecmd) {
@@ -1203,13 +1213,6 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 				err = module_do_install_commands(m, options,
 									&cb);
 		} else {
-			if (!(flags & KMOD_PROBE_IGNORE_LOADED)
-						&& module_is_inkernel(m)) {
-				DBG(mod->ctx, "Ignoring module '%s': "
-						"already loaded\n", m->name);
-				err = -EEXIST;
-				goto finish_module;
-			}
 			if (print_action != NULL)
 				print_action(m, false, options ?: "");
 
@@ -1218,9 +1221,9 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 								options);
 		}
 
-finish_module:
 		free(options);
 
+finish_module:
 		/*
 		 * Treat "already loaded" error. If we were told to stop on
 		 * already loaded and the module being loaded is not a softdep
-- 
1.7.9.1

Reply via email to