X Tutup
Skip to content

Commit 2ec15c4

Browse files
committed
mount: default startup dependencies and default network ones are orthogonal
Regardless of whether a mount is setup in initrd or int the main system, the network default dependencies _netdev should still be honored. IOW if a mount unit use the following options "x-initrd.mount,_netdev", it should be ordered against initrd-fs.target, network.target, network-online.target. /dev/vdb1 /mnt ext4 x-initrd.mount,_netdev defaults 0 0 Before this patch: Before=umount.target initrd-fs.target After=system.slice sysroot.mount dev-vdb1.device -.mount systemd-journald.socket blockdev@dev-vdb1.target After this patch: Before=initrd-fs.target umount.target After=network-online.target -.mount blockdev@dev-vdb1.target dev-vdb1.device sysroot.mount system.slice network.target systemd-journald.socket
1 parent 61154cf commit 2ec15c4

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/core/mount.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -450,29 +450,9 @@ static int mount_add_default_ordering_dependencies(
450450
before = isempty(e) ? SPECIAL_INITRD_ROOT_FS_TARGET : SPECIAL_INITRD_FS_TARGET;
451451

452452
} else if (mount_is_network(p)) {
453-
/* We order ourselves after network.target. This is
454-
* primarily useful at shutdown: services that take
455-
* down the network should order themselves before
456-
* network.target, so that they are shut down only
457-
* after this mount unit is stopped. */
458-
459-
r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_NETWORK_TARGET, true, mask);
460-
if (r < 0)
461-
return r;
462-
463-
/* We pull in network-online.target, and order
464-
* ourselves after it. This is useful at start-up to
465-
* actively pull in tools that want to be started
466-
* before we start mounting network file systems, and
467-
* whose purpose it is to delay this until the network
468-
* is "up". */
469-
470-
r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, SPECIAL_NETWORK_ONLINE_TARGET, true, mask);
471-
if (r < 0)
472-
return r;
473-
474453
after = SPECIAL_REMOTE_FS_PRE_TARGET;
475454
before = SPECIAL_REMOTE_FS_TARGET;
455+
476456
} else {
477457
after = SPECIAL_LOCAL_FS_PRE_TARGET;
478458
before = SPECIAL_LOCAL_FS_TARGET;
@@ -521,6 +501,26 @@ static int mount_add_default_dependencies(Mount *m) {
521501
if (r < 0)
522502
return r;
523503

504+
if (mount_is_network(p)) {
505+
/* We order ourselves after network.target. This is primarily useful at shutdown:
506+
* services that take down the network should order themselves before
507+
* network.target, so that they are shut down only after this mount unit is
508+
* stopped. */
509+
510+
r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_NETWORK_TARGET, true, mask);
511+
if (r < 0)
512+
return r;
513+
514+
/* We pull in network-online.target, and order ourselves after it. This is useful
515+
* at start-up to actively pull in tools that want to be started before we start
516+
* mounting network file systems, and whose purpose it is to delay this until the
517+
* network is "up". */
518+
519+
r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, SPECIAL_NETWORK_ONLINE_TARGET, true, mask);
520+
if (r < 0)
521+
return r;
522+
}
523+
524524
/* If this is a tmpfs mount then we have to unmount it before we try to deactivate swaps */
525525
if (streq_ptr(p->fstype, "tmpfs")) {
526526
r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET, true, mask);

0 commit comments

Comments
 (0)
X Tutup