Add ability to tunnel douts from AlienStore(BlueStore) to seastar logger.
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
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(),
#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);
class HeartbeatMap;
namespace logging {
class Log;
+ class SubsystemMap;
}
}
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;
"{}", _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 { \
${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
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
${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)
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
--- /dev/null
+// -*- 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
--- /dev/null
+// -*- 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
#include "alien_collection.h"
#include "alien_store.h"
+#include "alien_log.h"
#include <map>
#include <string_view>
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());
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__);
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;
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;
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;