<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 27, 2017 at 9:50 PM, Michael Chapman <span dir="ltr"><<a href="mailto:mike@very.puzzling.org" target="_blank">mike@very.puzzling.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 28 Apr 2017, Felipe Sateler wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On Thu, 27 Apr 2017 15:53:51 +1000, Michael Chapman wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hello all,<br>
<br>
At present, when systemd-fstab-generator creates an automount unit for<br>
an fstab entry, it applies the dependencies that would have been put<br>
into the mount unit into the automount unit instead.<br>
<br>
For a local filesystem, this automount unit would be<br>
Before=local-fs.target. For a network filesystem, it gets<br>
Before=remote-fs.target. If the mount is not noauto, it also gets a<br>
corresponding WantedBy= or RequiredBy= dependency.<br>
<br>
Would it make more sense for the automount unit to be ordered before<br>
(and,<br>
if not noauto, be pulled in by) local-fs.target, even for network<br>
filesystems?<br>
<br>
In a sense, the automount is a local filesystem, even though the thing<br>
that will eventually be mounted over the top of it isn't. Furthermore,<br>
this change would allow services that use automounted network filesystem<br>
to simply block until the filesystem has been mounted. Currently, for<br>
this to work correctly during boot, services need to be given explicit<br>
dependencies (e.g. After=remote-fs.target or RequiresMountsFor=...),<br>
since otherwise they may get started before the automount unit has<br>
started and thus be able to "see" the underlying filesystem.<br>
<br>
I'm trying to work out what might break with such a change. I suppose it<br>
is possible somebody has two automounted network filesystems nested<br>
within one another... the second automount would be dependent upon the<br>
first being mounted, but that mount won't happen until the network is<br>
brought up, which is after local-fs.target. This doesn't seem like a<br>
particularly likely configuration though.<br>
<br>
Is there any other reason this change wouldn't work?<br>
</blockquote>
<br>
<br>
I think the most likely failure point would be at shutdown:<br>
<br>
1. foo.mount is unmounted, but foo.automount is still alive.<br>
2. some.service is not Requires/After foo.mount<br>
3. some.service tries to access /foo<br>
4. systemd tries to activate foo.mount<br>
5. boom<br>
</blockquote>
<br>
Well, the shutdown target is started irrevocably, so I suspect instead of "boom" the service will just block until it's stopped by systemd.</blockquote><div><br></div><div>Well, I didn't test it, so "boom" was meant as "bad things happening" :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
But yeah, you do raise a good issue.<br>
<br>
This is all a bit annoying. I've got a bunch of services (across multiple servers), but I don't necessarily know up front which services will be requiring access to network filesystems. I would prefer not to have to configure them all with After=remote-fs.target "just in case". I was hoping that by using automounts this wouldn't be necessary, but the services can end up being started _before_ those automounts.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
In a sense, this is a bit of a regression from sysv initscripts, because a lot of initscripts were shipped with "Required-Start: $remotefs" just as a precautionary measure, but most vendor-provided systemd units do _not_ have After=remote-fs.target.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
So is there any other way I could achieve what I want, or am I forced to drop in After=remote-fs.target wherever it might possibly be necessary?<br>
</blockquote></div><div class="gmail_extra"><br></div><div><br></div><div>It is my impression that the best course is to have your services have RequiresMountsFor= the places they use. This way you ensure:</div><div><br></div><div>1. If mounts fail your service does not attempt to start.</div><div>2. Your service is stopped if the mount goes down.</div><div>3. Your service is started and stopped at the right time on boot/shutdown.</div><div class="gmail_extra"><br></div>It's a bit more annoying, yes, but more precise. Failing that, you can add After=remote-fs.target to all your services.<br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Saludos,<br>Felipe Sateler</div>
</div></div>