]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/alienstore: Add douts 46618/head
authorAdam Kupczyk <akupczyk@redhat.com>
Fri, 10 Jun 2022 14:08:33 +0000 (14:08 +0000)
committerAdam Kupczyk <akupczyk@redhat.com>
Fri, 10 Jun 2022 14:08:33 +0000 (14:08 +0000)
Add ability to tunnel douts from AlienStore(BlueStore) to seastar logger.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/common/ceph_context.cc
src/common/ceph_context.h
src/common/dout.h
src/crimson/CMakeLists.txt
src/crimson/os/alienstore/CMakeLists.txt
src/crimson/os/alienstore/alien_log.cc [new file with mode: 0644]
src/crimson/os/alienstore/alien_log.h [new file with mode: 0644]
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h
src/log/Log.h

index df23ae7a60f1842ef03bbcba828bfeb3c0b59c61..1ee561e0911d12ad70d7ba8e72b6ef8c89faf21d 100644 (file)
@@ -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);
index dee5157ceee4b6b4df578b02d029cc88b773c107..f1877647877ab590e063ab588ae8aae984ab18e6 100644 (file)
@@ -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<ceph::logging::Log* (const ceph::logging::SubsystemMap *)> create_log;
+  };
+  CephContext(uint32_t module_type_,
+             const create_options& options);
   CephContext(const CephContext&) = delete;
   CephContext& operator =(const CephContext&) = delete;
   CephContext(CephContext&&) = delete;
index a1375fbb91026877578cd5ebaebe5993b07f9104..87ff79c3be0f0bec5888605e6279e0e2fea7a7b4 100644 (file)
@@ -133,16 +133,6 @@ struct is_dynamic<dynamic_marker_t<T>> : 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 {                                                                 \
index 4508491407d91c90bce4a57a884a1c43557a1d7a..fbaf1abd4cfff6ed1322dab28ff2d76f43aec2f0 100644 (file)
@@ -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
index f006ba33a850ce9aa8687dfe4aa881db1f6e9a3a..ded67fec1b46042af5d0b43cc15bc00bc342c65d 100644 (file)
@@ -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
   $<TARGET_OBJECTS:compressor_objs>
   $<TARGET_OBJECTS:common_prioritycache_obj>)
 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 (file)
index 0000000..b371af8
--- /dev/null
@@ -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 <seastar/core/alien.hh>
+#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 (file)
index 0000000..0f966d9
--- /dev/null
@@ -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
index da6fba75d14f996fbf260cf6b69fcf16546672fe..b3c2ec4a431600c09e0f7d743842f590c624d350 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "alien_collection.h"
 #include "alien_store.h"
+#include "alien_log.h"
 
 #include <map>
 #include <string_view>
@@ -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<CephContext>(CEPH_ENTITY_TYPE_OSD);
-  g_ceph_context = cct.get();
-  cct->_conf.set_config_values(values);
 }
 
 seastar::future<> AlienStore::start()
 {
+  cct = std::make_unique<CephContext>(
+    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<AlienCollection*>(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__);
index f6ba12d2c94c58f52ccf9a8467bfb5f46d76db2f..d33941aee0c2f69500cd6e54750f3d149b482581 100644 (file)
@@ -137,6 +137,7 @@ private:
   mutable std::unique_ptr<crimson::os::ThreadPool> tp;
   const std::string type;
   const std::string path;
+  const ConfigValues values;
   uint64_t used_bytes = 0;
   std::unique_ptr<ObjectStore> store;
   std::unique_ptr<CephContext> cct;
index 0d83ff037f75ccbdcfe6074eab89cc6b567bcbae..e7582dcb59caa864c4cbd9c214adcb8c62349a7e 100644 (file)
@@ -29,8 +29,10 @@ class SubsystemMap;
 
 class Log : private Thread
 {
-  using EntryRing = boost::circular_buffer<ConcreteEntry>;
+protected:
   using EntryVector = std::vector<ConcreteEntry>;
+private:
+  using EntryRing = boost::circular_buffer<ConcreteEntry>;
 
   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;