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
This commit is contained in:
@@ -486,16 +486,16 @@ bool socket_address_is_netlink(const SocketAddress *a, const char *s) {
|
||||
return socket_address_equal(a, &b);
|
||||
}
|
||||
|
||||
bool socket_address_needs_mount(const SocketAddress *a, const char *prefix) {
|
||||
const char* socket_address_get_path(const SocketAddress *a) {
|
||||
assert(a);
|
||||
|
||||
if (socket_address_family(a) != AF_UNIX)
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
if (a->sockaddr.un.sun_path[0] == 0)
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
return path_startswith(a->sockaddr.un.sun_path, prefix);
|
||||
return a->sockaddr.un.sun_path;
|
||||
}
|
||||
|
||||
bool socket_ipv6_is_supported(void) {
|
||||
|
||||
@@ -92,7 +92,7 @@ int make_socket_fd(const char* address, int flags);
|
||||
|
||||
bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) _pure_;
|
||||
|
||||
bool socket_address_needs_mount(const SocketAddress *a, const char *prefix);
|
||||
const char* socket_address_get_path(const SocketAddress *a);
|
||||
|
||||
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
|
||||
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
|
||||
|
||||
Reference in New Issue
Block a user