<div dir="ltr">Hi Lennart,<div><br></div><div>Yes, it makes sense to me. Thank you for your explanation.</div><div><br></div><div>However, I still have a question about it. If the general goal is to minimize synchronization points, why don't we convert more active targets into passive targets? For example: not all machines have swap, so can the swap.target be a passive target to avoid unnecessary sync point? I guess there must be a reason not to do so, but I don't know what it is.</div><div><br></div><div>John</div><div><br><div class="gmail_quote"><div dir="ltr">Lennart Poettering <<a href="mailto:lennart@poettering.net">lennart@poettering.net</a>> 於 2017年10月24日 週二 下午4:45寫道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mo, 16.10.17 15:15, 林自均 (<a href="mailto:johnlinp@gmail.com" target="_blank">johnlinp@gmail.com</a>) wrote:<br>
<br>
> Hi folks,<br>
><br>
> I am reading systemd documents, and I find passive target units a little<br>
> bit confusing.<br>
><br>
> Take "network.target" for example:<br>
><br>
> "systemd-networkd.service" specifies "Wants=network.target" and<br>
> "Before=network.target". That effectively makes starting<br>
> "systemd-networkd.service" brings up both "systemd-networkd.service" and<br>
> "network.target", and make sure that "network.target" is active after<br>
> "systemd-networkd.service" being active. It also implies that the shutdown<br>
> order is correct: "network.target" will be stopped before<br>
> "systemd-networkd.service".  Everything is fine.<br>
><br>
> What if we use an active target unit to achieve all this? Can we specify a<br>
> "WantedBy=network.target" in "systemd-network.target"? So that we can<br>
> enable "systemd-network.service" (which makes a symbolic link in the<br>
> "network.target.wants" directory) and start "network.target" to pull in<br>
> "systemd-networkd.service". That also makes sure "network.target" is active<br>
> after "systemd-networkd.service" because of the target unit default<br>
> dependencies. And shutdown order will be correct too.<br>
><br>
> The only difference I can tell is the units to start. With a passive<br>
> "network.target", we start "systemd-networkd.service". With an active<br>
> "network.target", we start "network.target".<br>
><br>
> Is there any benefits of passive target units over active target units?<br>
<br>
We generally try to minimize synchronization points. "network.target"<br>
is one, and we don't want it around if there's no reason to have<br>
it. The more synchronization points you have the more serial your boot<br>
becomes.<br>
<br>
The logic hence is: if there's not networking stack then there's no<br>
reason for services to synchronize before or after it, and thus it's<br>
the networking stack that pulls in network.target and not its<br>
consumer, if you so will.<br>
<br>
Does that make sense?<br>
<br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</blockquote></div></div></div>