From 95b09c530e12cf7a26fcdcd83dab485ccc13e92a Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 9 Jun 2020 09:55:24 +0900 Subject: Revert: Rework unit loading to take into account all aliases Revert below patches due to increasing unit loading time (UnitsLoadFinishTimestamp - UnitsLoadStartTimestamp) Refer: https://github.com/systemd/systemd/pull/13119/commits - test-unit-file: allow printing of information about specific units - pid1: drop unit caches only based on mtime - analyze: add "unit-files" to dump the unit fragment map - core: restore initialization of u->source_mtime - pid1: use a cache for all unit aliases - shared/unit-file: add a function to validate unit alias symlinks - TEST-15-DROPIN: add test for details of unit aliasing Change-Id: I1bff89f5851544cda7522bd3ceb398499dac57d4 --- src/analyze/analyze.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'src/analyze') diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 991e61de7e..19c4ce9cd9 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1546,53 +1546,6 @@ static int get_or_set_log_target(int argc, char *argv[], void *userdata) { return (argc == 1) ? get_log_target(argc, argv, userdata) : set_log_target(argc, argv, userdata); } -static bool strv_fnmatch_strv_or_empty(char* const* patterns, char **strv, int flags) { - char **s; - STRV_FOREACH(s, strv) - if (strv_fnmatch_or_empty(patterns, *s, flags)) - return true; - - return false; -} - -static int do_unit_files(int argc, char *argv[], void *userdata) { - _cleanup_(lookup_paths_free) LookupPaths lp = {}; - _cleanup_hashmap_free_ Hashmap *unit_ids = NULL; - _cleanup_hashmap_free_ Hashmap *unit_names = NULL; - char **patterns = strv_skip(argv, 1); - Iterator i; - const char *k, *dst; - char **v; - int r; - - r = lookup_paths_init(&lp, arg_scope, 0, NULL); - if (r < 0) - return log_error_errno(r, "lookup_paths_init() failed: %m"); - - r = unit_file_build_name_map(&lp, NULL, &unit_ids, &unit_names, NULL); - if (r < 0) - return log_error_errno(r, "unit_file_build_name_map() failed: %m"); - - HASHMAP_FOREACH_KEY(dst, k, unit_ids, i) { - if (!strv_fnmatch_or_empty(patterns, k, FNM_NOESCAPE) && - !strv_fnmatch_or_empty(patterns, dst, FNM_NOESCAPE)) - continue; - - printf("ids: %s → %s\n", k, dst); - } - - HASHMAP_FOREACH_KEY(v, k, unit_names, i) { - if (!strv_fnmatch_or_empty(patterns, k, FNM_NOESCAPE) && - !strv_fnmatch_strv_or_empty(patterns, v, FNM_NOESCAPE)) - continue; - - _cleanup_free_ char *j = strv_join(v, ", "); - printf("aliases: %s ← %s\n", k, j); - } - - return 0; -} - static int dump_unit_paths(int argc, char *argv[], void *userdata) { _cleanup_(lookup_paths_free) LookupPaths paths = {}; int r; @@ -2250,7 +2203,6 @@ static int help(int argc, char *argv[], void *userdata) { " dot [UNIT...] Output dependency graph in %s format\n" " dump Output state serialization of service manager\n" " cat-config Show configuration file and drop-ins\n" - " unit-files List files and symlinks for units\n" " unit-paths List load directories for units\n" " exit-status [STATUS...] List exit status definitions\n" " syscall-filter [NAME...] Print list of syscalls in seccomp filter\n" @@ -2486,7 +2438,6 @@ static int run(int argc, char *argv[]) { { "service-watchdogs", VERB_ANY, 2, 0, service_watchdogs }, { "dump", VERB_ANY, 1, 0, dump }, { "cat-config", 2, VERB_ANY, 0, cat_config }, - { "unit-files", VERB_ANY, VERB_ANY, 0, do_unit_files }, { "unit-paths", 1, 1, 0, dump_unit_paths }, { "exit-status", VERB_ANY, VERB_ANY, 0, dump_exit_status }, { "syscall-filter", VERB_ANY, VERB_ANY, 0, dump_syscall_filters }, -- cgit v1.2.3