]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: make `legacy_values` static 61025/head
authorMax Kellermann <max.kellermann@ionos.com>
Wed, 13 Nov 2024 16:33:50 +0000 (17:33 +0100)
committerMax Kellermann <max.kellermann@ionos.com>
Tue, 10 Dec 2024 19:16:46 +0000 (20:16 +0100)
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 <max.kellermann@ionos.com>
src/common/config.cc
src/common/config.h

index 3a5ee91c3472c76316de6e6e0f62e68072e75d0a..7d6b1691915f78659f44fe350a3491aebe51939f 100644 (file)
@@ -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<std::string_view, md_config_t::member_ptr_t> 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
index 3e7b51d987d259ef2a5d2c091c37e706950c0978..9df11d52d8217ff5ccccab82c2a22b5933b51ef7 100644 (file)
@@ -91,7 +91,7 @@ public:
   /*
    * Mapping from legacy config option names to class members
    */
-  std::map<std::string_view, member_ptr_t> legacy_values;
+  static const std::map<std::string_view, member_ptr_t> legacy_values;
 
   /**
    * The configuration schema, in the form of Option objects describing