From: Adam Kupczyk Date: Fri, 10 Jun 2022 14:08:33 +0000 (+0000) Subject: crimson/alienstore: Add douts X-Git-Tag: v18.0.0~408^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf64155ae1b4bdb1a6368f76a46c4e9e4e12eccd;p=ceph.git crimson/alienstore: Add douts Add ability to tunnel douts from AlienStore(BlueStore) to seastar logger. Signed-off-by: Adam Kupczyk --- diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index df23ae7a60f1..1ee561e0911d 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -679,11 +679,16 @@ int CephContext::_do_command( CephContext::CephContext(uint32_t module_type_, enum code_environment_t code_env, int init_flags_) + :CephContext(module_type_, create_options{code_env, init_flags_, nullptr}) +{} + +CephContext::CephContext(uint32_t module_type_, + const create_options& options) : nref(1), - _conf{code_env == CODE_ENVIRONMENT_DAEMON}, + _conf{options.code_env == CODE_ENVIRONMENT_DAEMON}, _log(NULL), _module_type(module_type_), - _init_flags(init_flags_), + _init_flags(options.init_flags), _set_uid(0), _set_gid(0), _set_uid_string(), @@ -703,7 +708,11 @@ CephContext::CephContext(uint32_t module_type_, #endif crush_location(this) { - _log = new ceph::logging::Log(&_conf->subsys); + if (options.create_log) { + _log = options.create_log(&_conf->subsys); + } else { + _log = new ceph::logging::Log(&_conf->subsys); + } _log_obs = new LogObs(_log); _conf.add_observer(_log_obs); diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index dee5157ceee4..f1877647877a 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -62,6 +62,7 @@ namespace ceph { class HeartbeatMap; namespace logging { class Log; + class SubsystemMap; } } @@ -114,7 +115,13 @@ public: CephContext(uint32_t module_type_, enum code_environment_t code_env=CODE_ENVIRONMENT_UTILITY, int init_flags_ = 0); - + struct create_options { + enum code_environment_t code_env=CODE_ENVIRONMENT_UTILITY; + int init_flags = 0; + std::function create_log; + }; + CephContext(uint32_t module_type_, + const create_options& options); CephContext(const CephContext&) = delete; CephContext& operator =(const CephContext&) = delete; CephContext(CephContext&&) = delete; diff --git a/src/common/dout.h b/src/common/dout.h index a1375fbb9102..87ff79c3be0f 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -133,16 +133,6 @@ struct is_dynamic> : public std::true_type {}; "{}", _out.str().c_str()); \ } \ } while (0) -#elif defined(WITH_SEASTAR) && defined(WITH_ALIEN) -#define dout_impl(cct, sub, v) \ - do { \ - if (0) { \ - ceph::logging::MutableEntry _dout_e(v, sub); \ - std::ostream* _dout = &_dout_e.get_ostream(); - -#define dendl_impl std::flush; \ - } \ - } while (0) #else #define dout_impl(cct, sub, v) \ do { \ diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index 4508491407d9..fbaf1abd4cff 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -101,7 +101,6 @@ add_library(crimson-common STATIC ${PROJECT_SOURCE_DIR}/src/global/pidfile.cc ${PROJECT_SOURCE_DIR}/src/librbd/Features.cc ${PROJECT_SOURCE_DIR}/src/librbd/io/IoOperations.cc - ${PROJECT_SOURCE_DIR}/src/log/Log.cc ${PROJECT_SOURCE_DIR}/src/mgr/ServiceMap.cc ${PROJECT_SOURCE_DIR}/src/mds/inode_backtrace.cc ${PROJECT_SOURCE_DIR}/src/mds/mdstypes.cc diff --git a/src/crimson/os/alienstore/CMakeLists.txt b/src/crimson/os/alienstore/CMakeLists.txt index f006ba33a850..ded67fec1b46 100644 --- a/src/crimson/os/alienstore/CMakeLists.txt +++ b/src/crimson/os/alienstore/CMakeLists.txt @@ -7,6 +7,7 @@ set_target_properties(alien::cflags PROPERTIES set(crimson_alien_common_srcs ${PROJECT_SOURCE_DIR}/src/common/admin_socket.cc + ${PROJECT_SOURCE_DIR}/src/common/url_escape.cc ${PROJECT_SOURCE_DIR}/src/common/blkdev.cc ${PROJECT_SOURCE_DIR}/src/common/ceph_context.cc ${PROJECT_SOURCE_DIR}/src/common/ceph_crypto.cc @@ -25,6 +26,7 @@ set(crimson_alien_common_srcs ${PROJECT_SOURCE_DIR}/src/common/util.cc ${PROJECT_SOURCE_DIR}/src/crush/CrushLocation.cc ${PROJECT_SOURCE_DIR}/src/global/global_context.cc + ${PROJECT_SOURCE_DIR}/src/log/Log.cc $ $) if(WITH_CEPH_DEBUG_MUTEX) @@ -44,6 +46,7 @@ target_link_libraries(crimson-alien-common set(alien_store_srcs alien_store.cc thread_pool.cc + alien_log.cc ${PROJECT_SOURCE_DIR}/src/os/ObjectStore.cc ${PROJECT_SOURCE_DIR}/src/os/bluestore/Allocator.cc ${PROJECT_SOURCE_DIR}/src/os/bluestore/AvlAllocator.cc diff --git a/src/crimson/os/alienstore/alien_log.cc b/src/crimson/os/alienstore/alien_log.cc new file mode 100644 index 000000000000..b371af897a2f --- /dev/null +++ b/src/crimson/os/alienstore/alien_log.cc @@ -0,0 +1,33 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "alien_log.h" +#include "log/SubsystemMap.h" +#include +#include "crimson/common/log.h" + +namespace ceph::logging { +CnLog::CnLog(const SubsystemMap *s, seastar::alien::instance& inst, unsigned shard) + :Log(s) + ,inst(inst) + ,shard(shard) { +} + +CnLog::~CnLog() { +} + +void CnLog::_flush(EntryVector& q, bool crash) { + seastar::alien::submit_to(inst, shard, [&q] { + for (auto& it : q) { + crimson::get_logger(it.m_subsys).log( + crimson::to_log_level(it.m_prio), + "{}", + it.strv()); + } + return seastar::make_ready_future<>(); + }).wait(); + q.clear(); + return; +} + +} //namespace ceph::logging diff --git a/src/crimson/os/alienstore/alien_log.h b/src/crimson/os/alienstore/alien_log.h new file mode 100644 index 000000000000..0f966d9ab769 --- /dev/null +++ b/src/crimson/os/alienstore/alien_log.h @@ -0,0 +1,31 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef ALIEN_LOG_H +#define ALIEN_LOG_H + +#include "log/Log.h" + +namespace ceph { +namespace logging { +class SubsystemMap; +} +} + +namespace seastar::alien { + class instance; +} +namespace ceph::logging +{ +class CnLog : public ceph::logging::Log +{ + seastar::alien::instance& inst; + unsigned shard; + void _flush(EntryVector& q, bool crash) override; +public: + CnLog(const SubsystemMap *s, seastar::alien::instance& inst, unsigned shard); + ~CnLog() override; +}; +} + +#endif diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index da6fba75d14f..b3c2ec4a4316 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -3,6 +3,7 @@ #include "alien_collection.h" #include "alien_store.h" +#include "alien_log.h" #include #include @@ -74,15 +75,29 @@ AlienStore::AlienStore(const std::string& type, const std::string& path, const ConfigValues& values) : type(type), - path{path} + path{path}, + values(values) +{ +} + +AlienStore::~AlienStore() { - cct = std::make_unique(CEPH_ENTITY_TYPE_OSD); - g_ceph_context = cct.get(); - cct->_conf.set_config_values(values); } seastar::future<> AlienStore::start() { + cct = std::make_unique( + CEPH_ENTITY_TYPE_OSD, + CephContext::create_options { CODE_ENVIRONMENT_UTILITY, 0, + [](const ceph::logging::SubsystemMap* subsys_map) { + return new ceph::logging::CnLog(subsys_map, seastar::engine().alien(), seastar::this_shard_id()); + } + } + ); + g_ceph_context = cct.get(); + cct->_conf.set_config_values(values); + cct->_log->start(); + store = ObjectStore::create(cct.get(), type, path); if (!store) { ceph_abort_msgf("unsupported objectstore type: %s", type.c_str()); @@ -119,13 +134,14 @@ seastar::future<> AlienStore::stop() static_cast(ch.get())->collection.reset(); } store.reset(); + cct.reset(); + g_ceph_context = nullptr; + }).then([this] { return tp->stop(); }); } -AlienStore::~AlienStore() = default; - AlienStore::mount_ertr::future<> AlienStore::mount() { logger().debug("{}", __func__); diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index f6ba12d2c94c..d33941aee0c2 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -137,6 +137,7 @@ private: mutable std::unique_ptr tp; const std::string type; const std::string path; + const ConfigValues values; uint64_t used_bytes = 0; std::unique_ptr store; std::unique_ptr cct; diff --git a/src/log/Log.h b/src/log/Log.h index 0d83ff037f75..e7582dcb59ca 100644 --- a/src/log/Log.h +++ b/src/log/Log.h @@ -29,8 +29,10 @@ class SubsystemMap; class Log : private Thread { - using EntryRing = boost::circular_buffer; +protected: using EntryVector = std::vector; +private: + using EntryRing = boost::circular_buffer; static const std::size_t DEFAULT_MAX_NEW = 100; static const std::size_t DEFAULT_MAX_RECENT = 10000; @@ -81,9 +83,9 @@ class Log : private Thread void _log_safe_write(std::string_view sv); void _flush_logbuf(); - void _flush(EntryVector& q, bool crash); - void _log_message(std::string_view s, bool crash); +protected: + virtual void _flush(EntryVector& q, bool crash); public: using Thread::is_started;