]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix ASAN ODR violations in denc-mod-osd 68084/head
authorKefu Chai <k.chai@proxmox.com>
Wed, 25 Feb 2026 07:55:25 +0000 (15:55 +0800)
committerKefu Chai <k.chai@proxmox.com>
Sun, 29 Mar 2026 05:40:40 +0000 (13:40 +0800)
When building ceph-dencoder with ASAN (-DWITH_ASAN=ON), loading
denc-mod-osd.so triggered ODR (One Definition Rule) violations because
several static class members were defined both in libceph-common.so and
denc-mod-osd.so.

Fix each case appropriately:

- pg_pool_t::APPLICATION_NAME_{CEPHFS,RBD,RGW}: used across many
  translation units; convert to inline static constexpr in the header
  and remove the out-of-line definitions from osd_types.cc.

- ObjectCleanRegions::max_num_intervals: used in osd_types.cc and
  OSD.cc; convert to inline static in the header and remove the
  out-of-line definition from osd_types.cc.

- SnapMapper::{MAPPING_PREFIX,OBJECT_PREFIX,PURGED_SNAP_PREFIX}: only
  used within SnapMapper.cc; remove from the class entirely and move
  to file-local static constants in SnapMapper.cc.

- SnapMapper::{LEGACY_MAPPING_PREFIX,PURGED_SNAP_EPOCH_PREFIX}: never
  used anywhere; remove the dead declarations from SnapMapper.h.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/osd/SnapMapper.cc
src/osd/SnapMapper.h
src/osd/osd_types.cc
src/osd/osd_types.h

index df2da64b3e499830d3d4dfc1c4d49d2544ce53a8..6496b05d04f0cf1553ea59d1b6b958930f042931 100644 (file)
@@ -42,11 +42,9 @@ using ceph::timespan_str;
 using result_t = Scrub::SnapMapReaderI::result_t;
 using code_t = Scrub::SnapMapReaderI::result_t::code_t;
 
-
-const string SnapMapper::MAPPING_PREFIX = "SNA_";
-const string SnapMapper::OBJECT_PREFIX = "OBJ_";
-
-const char *SnapMapper::PURGED_SNAP_PREFIX = "PSN_";
+static const std::string MAPPING_PREFIX = "SNA_";
+static const std::string OBJECT_PREFIX = "OBJ_";
+static const char *PURGED_SNAP_PREFIX = "PSN_";
 
 /*
 
index c7cab0c344012aeca396b3e6eb6cd9f8f46ee903..f3d4f58ec5734706420bbf522f2987a572b610d6 100644 (file)
@@ -181,12 +181,6 @@ public:
     }
   };
 
-  static const std::string LEGACY_MAPPING_PREFIX;
-  static const std::string MAPPING_PREFIX;
-  static const std::string OBJECT_PREFIX;
-  static const char *PURGED_SNAP_EPOCH_PREFIX;
-  static const char *PURGED_SNAP_PREFIX;
-
 #ifndef WITH_CRIMSON
   struct Scrubber {
     CephContext *cct;
index 7c7e87b654924984586a6cd710c49f2bd6097822..21baa09aaef8f16a0acd8cbbd1822c44194fc0c5 100644 (file)
@@ -1584,10 +1584,6 @@ ostream& operator<<(ostream& out, const pool_opts_t& opts)
 
 // -- pg_pool_t --
 
-const char *pg_pool_t::APPLICATION_NAME_CEPHFS("cephfs");
-const char *pg_pool_t::APPLICATION_NAME_RBD("rbd");
-const char *pg_pool_t::APPLICATION_NAME_RGW("rgw");
-
 void pg_pool_t::dump(Formatter *f) const
 {
   f->dump_stream("create_time") << get_create_time();
@@ -4875,8 +4871,6 @@ void ObjectModDesc::decode(ceph::buffer::list::const_iterator &_bl)
   DECODE_FINISH(_bl);
 }
 
-std::atomic<uint32_t> ObjectCleanRegions::max_num_intervals = {10};
-
 void ObjectCleanRegions::set_max_num_intervals(uint32_t num)
 {
   max_num_intervals = num;
index 5377ffac182e052ef4e851037b9e77d260a226f3..f876dc20ee6254a3325bb2d4a584de8af65566fb 100644 (file)
@@ -1278,9 +1278,9 @@ class OSDMap;
  * pg_pool
  */
 struct pg_pool_t {
-  static const char *APPLICATION_NAME_CEPHFS;
-  static const char *APPLICATION_NAME_RBD;
-  static const char *APPLICATION_NAME_RGW;
+  inline static constexpr const char *APPLICATION_NAME_CEPHFS = "cephfs";
+  inline static constexpr const char *APPLICATION_NAME_RBD = "rbd";
+  inline static constexpr const char *APPLICATION_NAME_RGW = "rgw";
 
   enum {
     TYPE_REPLICATED = 1,     // replication
@@ -4270,7 +4270,7 @@ private:
   bool new_object;
   bool clean_omap;
   interval_set<uint64_t> clean_offsets;
-  static std::atomic<uint32_t> max_num_intervals;
+  inline static std::atomic<uint32_t> max_num_intervals{10};
 
   /**
    * trim the number of intervals if clean_offsets.num_intervals()