summaryrefslogtreecommitdiff
path: root/src/core/manager.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-09-26 20:14:24 +0200
committerLennart Poettering <lennart@poettering.net>2013-09-26 20:20:30 +0200
commita57f7e2c828b852eb32fd810dcea041bb2975501 (patch)
tree9d088f212995c20b3ba2d2574ca8027fad25a51b /src/core/manager.h
parent6270c1bd8f83e9985458c63688f452be7626766f (diff)
core: rework how we match mount units against each other
Previously to automatically create dependencies between mount units we matched every mount unit agains all others resulting in O(n^2) complexity. On setups with large amounts of mount units this might make things slow. This change replaces the matching code to use a hashtable that is keyed by a path prefix, and points to a set of units that require that path to be around. When a new mount unit is installed it is hence sufficient to simply look up this set of units via its own file system paths to know which units to order after itself. This patch also changes all unit types to only create automatic mount dependencies via the RequiresMountsFor= logic, and this is exposed to the outside to make things more transparent. With this change we still have some O(n) complexities in place when handling mounts, but that's currently unavoidable due to kernel APIs, and still substantially better than O(n^2) as before. https://bugs.freedesktop.org/show_bug.cgi?id=69740
Diffstat (limited to 'src/core/manager.h')
-rw-r--r--src/core/manager.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/manager.h b/src/core/manager.h
index 3969553e3..a3049b5e5 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -103,9 +103,6 @@ struct Manager {
* type we maintain a per type linked list */
LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]);
- /* To optimize iteration of units that have requires_mounts_for set */
- LIST_HEAD(Unit, has_requires_mounts_for);
-
/* Units that need to be loaded */
LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */
@@ -251,6 +248,11 @@ struct Manager {
char *switch_root;
char *switch_root_init;
+
+ /* This maps all possible path prefixes to the units needing
+ * them. It's a hashmap with a path string as key and a Set as
+ * value where Unit objects are contained. */
+ Hashmap *units_requiring_mounts_for;
};
int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **m);
@@ -263,6 +265,8 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds);
Job *manager_get_job(Manager *m, uint32_t id);
Unit *manager_get_unit(Manager *m, const char *name);
+int manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found);
+
int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j);
int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret);
@@ -316,4 +320,6 @@ void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, bool b);
void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_attr_(4,5);
+Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
+
void watch_init(Watch *w);