File 0001-systemd-mount-set-device-timeout-from-the-kernel-com.patch of Package systemd.1472
From a7ef787c33aa8d12852a176cdeb1ecdb39cf56fe Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 12 Feb 2015 14:00:06 +0100
Subject: [PATCH] systemd-mount: set device timeout from the kernel commandline
On some systems device probing can take longer than the predefined
device timeout. This patch adds a kernel commandline option
'mount.timeout' and 'rd.timeout' for allowing to modify the
default device timeout.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
man/kernel-command-line.xml | 11 +++++++++++
man/systemd-fstab-generator.xml | 16 ++++++++++++++++
src/core/mount.c | 38 +++++++++++++++++++++++++++++++++-----
3 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index afcff7c..3d64490 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -292,6 +292,17 @@
</varlistentry>
<varlistentry>
+ <term><varname>mount.timeout=</varname></term>
+ <term><varname>rd.timeout=</varname></term>
+
+ <listitem>
+ <para>Configures the device timeout
+ logic at boot. For details, see
+ <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>modules-load=</varname></term>
<term><varname>rd.modules-load=</varname></term>
diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml
index e3cf5d2..6710354 100644
--- a/man/systemd-fstab-generator.xml
+++ b/man/systemd-fstab-generator.xml
@@ -106,6 +106,22 @@
honored by both the main system and
the initrd. </para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>mount.timeout=</varname></term>
+ <term><varname>rd.timeout=</varname></term>
+
+ <listitem><para>Specifies the device
+ timeout in seconds. It will only be
+ applied if no device-specific timeout
+ settings in
+ <filename>/etc/fstab</filename> are configured.
+ <varname>rd.timeout</varname> is
+ honoured only by initial RAMD disk
+ (initrd) while
+ <varname>mount.timeout=</varname> is
+ honored by both the main system and
+ the initrd. </para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
diff --git a/src/core/mount.c b/src/core/mount.c
index 709b043..b25e51c 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -440,7 +440,7 @@ static int mount_fix_timeouts(Mount *m) {
Unit *other;
Iterator i;
usec_t u;
- char *t;
+ char *t = NULL;
int r;
assert(m);
@@ -458,12 +458,40 @@ static int mount_fix_timeouts(Mount *m) {
timeout += 31;
else if ((timeout = mount_test_option(p->options, "x-systemd.device-timeout")))
timeout += 25;
- else
- return 0;
- t = strndup(timeout, strcspn(timeout, ",;" WHITESPACE));
+ if (timeout) {
+ t = strndup(timeout, strcspn(timeout, ",;" WHITESPACE));
+ if (!t)
+ return -ENOMEM;
+ } else {
+ _cleanup_free_ char *line = NULL;
+ char *w, *state;
+ size_t l;
+
+ r = proc_cmdline(&line);
+ if (r > 0) {
+ /*
+ * Allow to override the device timeout from the
+ * kernel commandline, allowing later entries
+ * to override earlier ones.
+ */
+ FOREACH_WORD_QUOTED(w, l, line, state) {
+ if (startswith(w, "mount.timeout=")) {
+ if (t)
+ free(t);
+ t = strdup(w + 14);
+ } else if (startswith(w, "rd.timeout=")) {
+ if (in_initrd()) {
+ if (t)
+ free(t);
+ t = strdup(w + 11);
+ }
+ }
+ }
+ }
+ }
if (!t)
- return -ENOMEM;
+ return 0;
r = parse_sec(t, &u);
free(t);
--
1.8.5.2