Skip to content

common/dout: move Log::submit_entry() call to extern function - #72655

Draft
MaxKellermann wants to merge 2 commits into
ceph:mainfrom
MaxKellermann:common_dout__uninline
Draft

MaxKellermann wants to merge 2 commits into
ceph:mainfrom
MaxKellermann:common_dout__uninline

Conversation

@MaxKellermann

Copy link
Copy Markdown
Member

This eliminates the header dependency on log/Log.h and instead needs only the lighter header log/Entry.h.

Another PR split from #60490

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

Signed-off-by: Max Kellermann <[email protected]>
This eliminates the header dependency on log/Log.h and instead needs
only the lighter header log/Entry.h.

Signed-off-by: Max Kellermann <[email protected]>
@MaxKellermann

Copy link
Copy Markdown
Member Author

The build breaks because the WITH_CRIMSON macro is missing in a lot of sources, and apparently this has been causing inconsistent Crimson builds forever.... I'll try to fix this general Crimson build issue.

@MaxKellermann

Copy link
Copy Markdown
Member Author

This starts to look like a desaster; when I build src/crimson/os/alienstore with -DWITH_CRIMSON=1, I get this error:

src/crimson/os/alienstore/alien_store.cc: In member function ‘virtual seastar::future<unsigned int> crimson::os::AlienStore::start()’:
src/crimson/os/alienstore/alien_store.cc:91:18: error: ‘create_options’ is not a member of ‘crimson::common::CephContext’
   91 |     CephContext::create_options { CODE_ENVIRONMENT_UTILITY, 0,
      |                  ^~~~~~~~~~~~~~

The CephContext class has a different API and ABI in Crimson builds, but some parts of the Crimson build use the non-Crimson ABI.

This is a horrible and fragile mess. Why has this never crashed?

@MaxKellermann

Copy link
Copy Markdown
Member Author
# Merge alienstore + alien-common into a single archive.  The common sources
# are compiled without WITH_CRIMSON and duplicate symbols in crimson-common.

@tchaikov, @ronen-fr, @Matan-B or anybody else - please explain - this sounds oh so messy and so wrong, I don't know where to start fixing this.

@tchaikov

tchaikov commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
# Merge alienstore + alien-common into a single archive.  The common sources
# are compiled without WITH_CRIMSON and duplicate symbols in crimson-common.

@tchaikov, @ronen-fr, @Matan-B or anybody else - please explain - this sounds oh so messy and so wrong, I don't know where to start fixing this.

@MaxKellermann i am trying to address it in #71760, well, partly.

@ronen-fr

Copy link
Copy Markdown
Contributor

@tchaikov, @ronen-fr, @Matan-B or anybody else - please explain - this sounds oh so messy and so wrong, I don't know where to start fixing this.

It is messy and terrible. That's (just the point about the two CephContex'es) what made the introduction of mold into a multi-days endevor. I am counting on Kefu to get it fixed someday...

@MaxKellermann

Copy link
Copy Markdown
Member Author

My problem with this mess is that I just can't understand why this complexity was ever introduced. Why did somebody decide it's a good idea to build the same source twice within a single Ceph binary, but with different ABIs, and then use linker trickery and hope all symbols get resolved to the proper ABI version...
The naive approach (build libceph-common and everything else just once, and everything consistently with the same flags) would have been much simpler ("KISS") and more robust, but somebody decided Ceph cannot be that simple. There must be a reason for that decision, and if only I knew, I could figure out a solution.
But I think it's like it always is, everywhere: there was never a reason, and all of this was a bad idea, just nobody stopped the guy who came up with it. Then we should burn it down and make it proper.

@tchaikov

tchaikov commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

@MaxKellermann Hi Max,

I agree it's a mess, and some of it is my fault. It did start from a real need, though.

crimson-osd runs two runtimes in one process. Crimson code runs on seastar's shared-nothing cores, so the shared sources are built with WITH_CRIMSON: ceph::mutex becomes a no-op dummy_mutex, config is a sharded seastar service, dout goes to the seastar logger, and CephContext is the slim crimson::common::CephContext. AlienStore (b155240) runs the classic BlueStore on plain POSIX threads, and BlueStore needs real mutexes and the classic CephContext with its log thread, Finisher, Timer, etc. So AlienStore::start() creates a classic CephContext, and crimson_alien_common_srcs builds those sources again without WITH_CRIMSON. I don't know of a way to get both from one build.

What keeps hurting is the classic CephContext. Whatever it pulls in has to be built into the alien copy too, and when crimson-common builds the same source, we get duplicate symbols:

  • CephContext, PerfCounters, the globals and the OpenSSL init were moved into separate namespaces (TOPNSPC) in a54d0a9.
  • When CephContext got a CryptoManager (a2ab16c), auth/Crypto.cc had to join the alien copy, so Matan put the crypto classes behind TOPNSPC as well (6b11538).
  • PluginRegistry, util.cc and debug_level_guard.cc slipped through. PluginRegistry isn't even the same class on both sides: its ceph::mutex is a 1-byte dummy in crimson and a std::mutex in the alien copy.

#71760 cleans up those leftovers and drops the --allow-multiple-definition hack, but I'm afraid the next thing added to CephContext will bring it back. I think the way out is to drop AlienStore once SeaStore can replace it, or until then keep its classic copy private, e.g. in a shared object with hidden visibility. I'd be glad to hear better ideas.

@MaxKellermann

Copy link
Copy Markdown
Member Author

Thanks for the explanaiton, @tchaikov. I understand your motivation, but I wouldn't have chosen that path. At most, this is a way to quickly assemble a PoC for Seastar integration, but I would never have merge such a thing into the main branch.
ABI compatbility across different released versions of a software is difficult enough already, but mixing ABIs in one process is something I would take extreme care to avoid. Even if it means some overhead - what you did with the mutex is premature optimization IMHO.
There are solutions to each of your points, but of course it's always a tradeoff. For example making logging pluggable (to have one single logging ABI) adds runtime overhead for virtual dispatch, but OTOH loggin is so expensive (C++ iostreams, oh noo!!), that the overhead for virtual dispatch is negligible.
What I would do here is get rid of all WITH_CRIMSON checks in libceph-common: remove all the unnecessary Crimson-specific optimizations, make logging (and other things) runtime-pluggable, and so on.
Some parts are more difficult than others; CephContext is a complex beast, sure, and decoupling it from stuff that's not available in Crimson builds requires some heavy thinking. Maybe CephContext should be split into multiple layers, and only the lowest layer (lowest base class) implemented for Crimson, and then functions should only take a reference to the lowest interface they need.
That's painful refactoring, but everything is better than this fragile chimera ABI.

@MaxKellermann
MaxKellermann marked this pull request as draft October 16, 2026 05:55
@MaxKellermann

Copy link
Copy Markdown
Member Author

Converted to draft; I will resume this effort once the Crimson mess has been cleaned up, but it's out of this PR's scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants