}
static int mount_add_device_dependencies(Mount *m) {
+ UnitDependencyMask mask;
MountParameters *p;
UnitDependency dep;
int r;
* suddenly. */
dep = mount_is_bound_to_device(m) ? UNIT_BINDS_TO : UNIT_REQUIRES;
- r = unit_add_node_dependency(UNIT(m), p->what, dep, UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ /* We always use 'what' from /proc/self/mountinfo if mounted */
+ mask = m->from_proc_self_mountinfo ? UNIT_DEPENDENCY_MOUNTINFO : UNIT_DEPENDENCY_MOUNT_FILE;
+
+ r = unit_add_node_dependency(UNIT(m), p->what, dep, mask);
if (r < 0)
return r;
if (r > 0)
log_unit_trace(UNIT(m), "Added %s dependency on %s", unit_dependency_to_string(dep), p->what);
if (mount_propagate_stop(m)) {
- r = unit_add_node_dependency(UNIT(m), p->what, UNIT_STOP_PROPAGATED_FROM, UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_node_dependency(UNIT(m), p->what, UNIT_STOP_PROPAGATED_FROM, mask);
if (r < 0)
return r;
if (r > 0)
unit_dependency_to_string(UNIT_STOP_PROPAGATED_FROM), p->what);
}
- r = unit_add_blockdev_dependency(UNIT(m), p->what, UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_blockdev_dependency(UNIT(m), p->what, mask);
if (r > 0)
log_unit_trace(UNIT(m), "Added %s dependency on %s", unit_dependency_to_string(UNIT_AFTER), p->what);
return false;
}
-static int mount_add_default_ordering_dependencies(
- Mount *m,
- MountParameters *p) {
-
+static int mount_add_default_ordering_dependencies(Mount *m, MountParameters *p, UnitDependencyMask mask) {
const char *after, *before, *e;
int r;
}
if (!mount_is_nofail(m)) {
- r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, /* add_reference= */ true, mask);
if (r < 0)
return r;
}
if (after) {
- r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, /* add_reference= */ true, mask);
if (r < 0)
return r;
}
- return unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS,
- SPECIAL_UMOUNT_TARGET, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ return unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET,
+ /* add_reference= */ true, mask);
}
static int mount_add_default_dependencies(Mount *m) {
+ UnitDependencyMask mask;
MountParameters *p;
int r;
if (!p)
return 0;
- r = mount_add_default_ordering_dependencies(m, p);
+ mask = m->from_proc_self_mountinfo ? UNIT_DEPENDENCY_MOUNTINFO : UNIT_DEPENDENCY_MOUNT_FILE;
+
+ r = mount_add_default_ordering_dependencies(m, p, mask);
if (r < 0)
return r;
* network.target, so that they are shut down only after this mount unit is
* stopped. */
- r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_NETWORK_TARGET, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_NETWORK_TARGET,
+ /* add_reference= */ true, mask);
if (r < 0)
return r;
* mounting network file systems, and whose purpose it is to delay this until the
* network is "up". */
- r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER,
- SPECIAL_NETWORK_ONLINE_TARGET, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, SPECIAL_NETWORK_ONLINE_TARGET,
+ /* add_reference= */ true, mask);
if (r < 0)
return r;
}
/* If this is a tmpfs mount then we have to unmount it before we try to deactivate swaps */
if (streq_ptr(p->fstype, "tmpfs")) {
- r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET, true,
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET,
+ /* add_reference= */ true, mask);
if (r < 0)
return r;
}
/* We may be called due to this mount appearing in /proc/self/mountinfo, hence we clear all existing
* dependencies that were initialized from the unit file but whose final value really depends on the
* content of /proc/self/mountinfo. Some (such as m->where) might have become stale now. */
- unit_remove_dependencies(UNIT(m), UNIT_DEPENDENCY_MOUNTINFO_OR_FILE);
+ unit_remove_dependencies(UNIT(m), UNIT_DEPENDENCY_MOUNTINFO | UNIT_DEPENDENCY_MOUNT_FILE);
if (!m->where)
return 0;
/* A dependency created because of some unit's RequiresMountsFor= setting */
UNIT_DEPENDENCY_PATH = 1 << 4,
- /* A dependency created because of data read from /proc/self/mountinfo, but fallback to unit configuration
- * sources */
- UNIT_DEPENDENCY_MOUNTINFO_OR_FILE = 1 << 5,
+ /* A dependency initially configured from the mount unit file however the dependency will be updated
+ * from /proc/self/mountinfo as soon as the kernel will make the entry for that mount available in
+ * the /proc file */
+ UNIT_DEPENDENCY_MOUNT_FILE = 1 << 5,
+
+ /* A dependency created or updated because of data read from /proc/self/mountinfo */
+ UNIT_DEPENDENCY_MOUNTINFO = 1 << 6,
/* A dependency created because of data read from /proc/swaps and no other configuration source */
- UNIT_DEPENDENCY_PROC_SWAP = 1 << 6,
+ UNIT_DEPENDENCY_PROC_SWAP = 1 << 7,
/* A dependency for units in slices assigned by directly setting Slice= */
- UNIT_DEPENDENCY_SLICE_PROPERTY = 1 << 7,
+ UNIT_DEPENDENCY_SLICE_PROPERTY = 1 << 8,
- _UNIT_DEPENDENCY_MASK_FULL = (1 << 8) - 1,
+ _UNIT_DEPENDENCY_MASK_FULL = (1 << 9) - 1,
} UnitDependencyMask;
/* The Unit's dependencies[] hashmaps use this structure as value. It has the same size as a void pointer, and thus can