From 8c8203db90b584420f221b6c50b63389d39c100e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 26 Jan 2019 12:00:04 +0100 Subject: [PATCH 1/2] core/mount: do not add Before=local-fs.target or remote-fs.target if nofail mount option is set Follow-up for d54bab90e64f70c1ecf9b0683a98adb8485ed09e. Fixes #11558. --- src/core/mount.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index 4c5a02948c..976af48ab0 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -426,6 +426,7 @@ static int mount_add_default_dependencies(Mount *m) { const char *after, *before; UnitDependencyMask mask; MountParameters *p; + bool nofail; int r; assert(m); @@ -444,6 +445,7 @@ static int mount_add_default_dependencies(Mount *m) { return 0; mask = m->from_fragment ? UNIT_DEPENDENCY_FILE : UNIT_DEPENDENCY_MOUNTINFO_DEFAULT; + nofail = m->from_fragment ? fstab_test_yes_no_option(m->parameters_fragment.options, "nofail\0" "fail\0") : false; if (mount_is_network(p)) { /* We order ourselves after network.target. This is @@ -474,9 +476,11 @@ static int mount_add_default_dependencies(Mount *m) { before = SPECIAL_LOCAL_FS_TARGET; } - r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true, mask); - if (r < 0) - return r; + if (!nofail) { + r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true, mask); + if (r < 0) + return r; + } r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, true, mask); if (r < 0) From 321cd1c17c511c771cab86d5244032b999aed261 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 26 Jan 2019 13:05:27 +0100 Subject: [PATCH 2/2] man: update DefaultDependency= in systemd.mount(5) Follow-up for d54bab90e64f70c1ecf9b0683a98adb8485ed09e and the previous commit. --- man/systemd.mount.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml index 6d8c873ca5..7355b135e9 100644 --- a/man/systemd.mount.xml +++ b/man/systemd.mount.xml @@ -131,11 +131,15 @@ umount.target in order to be stopped during shutdown. Mount units referring to local file systems automatically gain - an After= dependency on local-fs-pre.target. + an After= dependency on local-fs-pre.target, and a + Before= dependency on local-fs.target unless + mount option is set. Network mount units automatically acquire After= dependencies on remote-fs-pre.target, - network.target and network-online.target. Towards the latter a + network.target and network-online.target, and gain a + Before= dependency on remote-fs.target unless + mount option is set. Towards the latter a Wants= unit is added as well.