From 895691ec47cb027637dbdb4915c7b105c47ad99b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 13 Nov 2024 17:33:50 +0100 Subject: [PATCH] common/config: make `legacy_values` static This field is `const` and we need only one global instance, and not one copy per `md_config_t` instance. Signed-off-by: Max Kellermann --- src/common/config.cc | 28 ++++++++++++++-------------- src/common/config.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index 3a5ee91c3472c..7d6b1691915f7 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -68,6 +68,20 @@ const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config,/etc/ceph/$cluster.conf,$ #define _STR(x) #x #define STRINGIFY(x) _STR(x) +// Populate list of legacy_values according to the OPTION() definitions +// Note that this is just setting up our map of name->member ptr. The +// default values etc will get loaded in along with new-style data, +// as all loads write to both the values map, and the legacy +// members if present. +const std::map md_config_t::legacy_values = { +#define OPTION(name, type) \ + {STRINGIFY(name), &ConfigValues::name}, +#define SAFE_OPTION(name, type) OPTION(name, type) +#include "options/legacy_config_opts.h" +#undef OPTION +#undef SAFE_OPTION +}; + const char *ceph_conf_level_name(int level) { switch (level) { @@ -170,20 +184,6 @@ md_config_t::md_config_t(ConfigValues& values, schema.emplace(opt.name, opt); } - // Populate list of legacy_values according to the OPTION() definitions - // Note that this is just setting up our map of name->member ptr. The - // default values etc will get loaded in along with new-style data, - // as all loads write to both the values map, and the legacy - // members if present. - legacy_values = { -#define OPTION(name, type) \ - {STRINGIFY(name), &ConfigValues::name}, -#define SAFE_OPTION(name, type) OPTION(name, type) -#include "options/legacy_config_opts.h" -#undef OPTION -#undef SAFE_OPTION - }; - validate_schema(); // Validate default values from the schema diff --git a/src/common/config.h b/src/common/config.h index 3e7b51d987d25..9df11d52d8217 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -91,7 +91,7 @@ public: /* * Mapping from legacy config option names to class members */ - std::map legacy_values; + static const std::map legacy_values; /** * The configuration schema, in the form of Option objects describing -- 2.39.5