mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
Merge pull request #23957 from tchaikov/wip-crimson-logging
common,auth,crimson: add logging to crimson Reviewed-by: Josh Durgin <jdurgin@redhat.com> Reviewed-by: Liu-Chunmei <chunmei.liu@intel.com>
This commit is contained in:
commit
296f54d221
@ -307,6 +307,9 @@ if(WITH_SEASTAR)
|
||||
endif()
|
||||
endmacro ()
|
||||
add_subdirectory(seastar)
|
||||
# create the directory so cmake won't complain when looking at the imported
|
||||
# target: Seastar exports this directory created at build-time
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/seastar/gen")
|
||||
add_subdirectory(crimson)
|
||||
endif()
|
||||
|
||||
|
@ -36,8 +36,16 @@ AuthClientHandler::create(CephContext *cct, int proto,
|
||||
}
|
||||
|
||||
// explicitly instantiate only the classes we need
|
||||
#ifdef WITH_SEASTAR
|
||||
template AuthClientHandler*
|
||||
AuthClientHandler::create<ceph::LockPolicy::SINGLE>(
|
||||
CephContext *cct,
|
||||
int proto,
|
||||
RotatingKeyRing<ceph::LockPolicy::SINGLE> *rkeys);
|
||||
#else
|
||||
template AuthClientHandler*
|
||||
AuthClientHandler::create<ceph::LockPolicy::MUTEX>(
|
||||
CephContext *cct,
|
||||
int proto,
|
||||
RotatingKeyRing<ceph::LockPolicy::MUTEX> *rkeys);
|
||||
#endif
|
||||
|
@ -14,3 +14,10 @@ set(auth_srcs
|
||||
unknown/AuthUnknownAuthorizeHandler.cc)
|
||||
|
||||
add_library(common-auth-objs OBJECT ${auth_srcs})
|
||||
if(WITH_SEASTAR)
|
||||
add_library(crimson-auth OBJECT ${auth_srcs})
|
||||
target_compile_definitions(crimson-auth PRIVATE
|
||||
"WITH_SEASTAR=1")
|
||||
target_include_directories(crimson-auth PRIVATE
|
||||
$<TARGET_PROPERTY:Seastar::seastar,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
endif()
|
||||
|
@ -79,4 +79,8 @@ KeyRing *RotatingKeyRing<lp>::get_keyring()
|
||||
}
|
||||
|
||||
// explicitly instantiate only the classes we need
|
||||
#ifdef WITH_SEASTAR
|
||||
template class RotatingKeyRing<LockPolicy::SINGLE>;
|
||||
#else
|
||||
template class RotatingKeyRing<LockPolicy::MUTEX>;
|
||||
#endif
|
||||
|
@ -252,4 +252,8 @@ bool CephxClientHandler<lp>::need_tickets()
|
||||
}
|
||||
|
||||
// explicitly instantiate only the classes we need
|
||||
#ifdef WITH_SEASTAR
|
||||
template class CephxClientHandler<LockPolicy::SINGLE>;
|
||||
#else
|
||||
template class CephxClientHandler<LockPolicy::MUTEX>;
|
||||
#endif
|
||||
|
@ -44,6 +44,40 @@
|
||||
using ceph::bufferlist;
|
||||
using ceph::HeartbeatMap;
|
||||
|
||||
#ifdef WITH_SEASTAR
|
||||
CephContext::CephContext()
|
||||
: _conf{ceph::common::local_conf()},
|
||||
_crypto_random{std::make_unique<CryptoRandom>()}
|
||||
{}
|
||||
|
||||
// define the dtor in .cc as CryptoRandom is an incomplete type in the header
|
||||
CephContext::~CephContext()
|
||||
{}
|
||||
|
||||
CryptoRandom* CephContext::random() const
|
||||
{
|
||||
return _crypto_random.get();
|
||||
}
|
||||
|
||||
CephContext* CephContext::get()
|
||||
{
|
||||
++nref;
|
||||
return this;
|
||||
}
|
||||
|
||||
void CephContext::put()
|
||||
{
|
||||
if (--nref == 0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
PerfCountersCollection* CephContext::get_perfcounters_collection()
|
||||
{
|
||||
throw std::runtime_error("not yet implemented");
|
||||
}
|
||||
|
||||
#else // WITH_SEASTAR
|
||||
namespace {
|
||||
|
||||
class LockdepObs : public md_config_obs_t {
|
||||
@ -848,3 +882,4 @@ void CephContext::notify_post_fork()
|
||||
for (auto &&t : _fork_watchers)
|
||||
t->handle_post_fork();
|
||||
}
|
||||
#endif // WITH_SEASTAR
|
||||
|
@ -29,9 +29,13 @@
|
||||
|
||||
#include "common/cmdparse.h"
|
||||
#include "common/code_environment.h"
|
||||
#ifdef WITH_SEASTAR
|
||||
#include "crimson/common/config_proxy.h"
|
||||
#else
|
||||
#include "common/config_proxy.h"
|
||||
|
||||
#include "include/spinlock.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "crush/CrushLocation.h"
|
||||
|
||||
@ -52,6 +56,28 @@ namespace ceph {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_SEASTAR
|
||||
class CephContext {
|
||||
public:
|
||||
CephContext();
|
||||
CephContext(uint32_t,
|
||||
code_environment_t=CODE_ENVIRONMENT_UTILITY,
|
||||
int = 0)
|
||||
: CephContext{}
|
||||
{}
|
||||
~CephContext();
|
||||
|
||||
CryptoRandom* random() const;
|
||||
PerfCountersCollection* get_perfcounters_collection();
|
||||
ceph::common::ConfigProxy& _conf;
|
||||
|
||||
CephContext* get();
|
||||
void put();
|
||||
private:
|
||||
std::unique_ptr<CryptoRandom> _crypto_random;
|
||||
unsigned nref;
|
||||
};
|
||||
#else
|
||||
/* A CephContext represents the context held by a single library user.
|
||||
* There can be multiple CephContexts in the same process.
|
||||
*
|
||||
@ -244,6 +270,8 @@ private:
|
||||
friend class CephContextServiceThread;
|
||||
CephContextServiceThread *_service_thread;
|
||||
|
||||
using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
|
||||
|
||||
md_config_obs_t *_log_obs;
|
||||
|
||||
/* The admin socket associated with this context */
|
||||
@ -310,5 +338,6 @@ private:
|
||||
|
||||
friend class CephContextObs;
|
||||
};
|
||||
#endif // WITH_SEASTAR
|
||||
|
||||
#endif
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define _STR(x) #x
|
||||
#define STRINGIFY(x) _STR(x)
|
||||
|
||||
#ifndef WITH_SEASTAR
|
||||
CephContext *common_preinit(const CephInitParameters &iparams,
|
||||
enum code_environment_t code_env, int flags)
|
||||
{
|
||||
@ -71,6 +72,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
|
||||
|
||||
return cct;
|
||||
}
|
||||
#endif // #ifndef WITH_SEASTAR
|
||||
|
||||
void complain_about_parse_errors(CephContext *cct,
|
||||
std::deque<std::string> *parse_errors)
|
||||
@ -93,6 +95,8 @@ void complain_about_parse_errors(CephContext *cct,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WITH_SEASTAR
|
||||
|
||||
/* Please be sure that this can safely be called multiple times by the
|
||||
* same application. */
|
||||
void common_init_finish(CephContext *cct)
|
||||
@ -133,3 +137,5 @@ void common_init_finish(CephContext *cct)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifndef WITH_SEASTAR
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "common/code_environment.h"
|
||||
|
||||
class CephContext;
|
||||
class CephInitParameters;
|
||||
|
||||
enum common_init_flags_t {
|
||||
// Set up defaults that make sense for an unprivileged daemon
|
||||
@ -42,6 +41,9 @@ enum common_init_flags_t {
|
||||
CINIT_FLAG_NO_MON_CONFIG = 0x20,
|
||||
};
|
||||
|
||||
#ifndef WITH_SEASTAR
|
||||
class CephInitParameters;
|
||||
|
||||
/*
|
||||
* NOTE: If you are writing a Ceph daemon, ignore this function and call
|
||||
* global_init instead. It will call common_preinit for you.
|
||||
@ -61,11 +63,13 @@ enum common_init_flags_t {
|
||||
*/
|
||||
CephContext *common_preinit(const CephInitParameters &iparams,
|
||||
enum code_environment_t code_env, int flags);
|
||||
#endif // #ifndef WITH_SEASTAR
|
||||
|
||||
/* Print out some parse errors. */
|
||||
void complain_about_parse_errors(CephContext *cct,
|
||||
std::deque<std::string> *parse_errors);
|
||||
|
||||
#ifndef WITH_SEASTAR
|
||||
/* This function is called after you have done your last
|
||||
* fork. When you make this call, the system will initialize everything that
|
||||
* cannot be initialized before a fork.
|
||||
@ -79,5 +83,6 @@ void complain_about_parse_errors(CephContext *cct,
|
||||
* the Ceph libraries would be destroyed by a fork().
|
||||
*/
|
||||
void common_init_finish(CephContext *cct);
|
||||
#endif // #ifndef WITH_SEASTAR
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "log/SubsystemMap.h"
|
||||
#include "common/options.h"
|
||||
#include "common/subsys_types.h"
|
||||
#include "common/config_fwd.h"
|
||||
#include "common/config_tracker.h"
|
||||
#include "common/config_values.h"
|
||||
|
||||
|
@ -2,12 +2,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lock_policy.h"
|
||||
|
||||
namespace ceph {
|
||||
template<class ConfigProxy> class md_config_obs_impl;
|
||||
#ifdef WITH_SEASTAR
|
||||
namespace ceph::common {
|
||||
class ConfigProxy;
|
||||
}
|
||||
|
||||
struct md_config_t;
|
||||
using ConfigProxy = ceph::common::ConfigProxy;
|
||||
#else
|
||||
class ConfigProxy;
|
||||
using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
|
||||
#endif
|
||||
|
@ -44,4 +44,7 @@ public:
|
||||
const std::set<int>& changed) { }
|
||||
};
|
||||
}
|
||||
|
||||
using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
|
||||
|
||||
#endif
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <type_traits>
|
||||
#include "common/config.h"
|
||||
#include "common/config_fwd.h"
|
||||
#include "common/config_obs.h"
|
||||
#include "common/config_obs_mgr.h"
|
||||
#include "common/Mutex.h"
|
||||
@ -17,6 +16,7 @@ class ConfigProxy {
|
||||
* The current values of all settings described by the schema
|
||||
*/
|
||||
ConfigValues values;
|
||||
using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
|
||||
ObserverMgr<md_config_obs_t> obs_mgr;
|
||||
md_config_t config;
|
||||
/** A lock that protects the md_config_t internals. It is
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "common/config_fwd.h"
|
||||
#include "common/entity_name.h"
|
||||
#include "common/options.h"
|
||||
#include "log/SubsystemMap.h"
|
||||
|
@ -18,12 +18,19 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "include/assert.h"
|
||||
#ifdef WITH_SEASTAR
|
||||
#include <seastar/util/log.hh>
|
||||
#include "crimson/common/log.h"
|
||||
#include "crimson/common/config_proxy.h"
|
||||
#else
|
||||
#include "global/global_context.h"
|
||||
#include "common/ceph_context.h"
|
||||
#include "common/config.h"
|
||||
#include "common/likely.h"
|
||||
#include "common/Clock.h"
|
||||
#include "log/Log.h"
|
||||
#endif
|
||||
|
||||
extern void dout_emergency(const char * const str);
|
||||
extern void dout_emergency(const std::string &str);
|
||||
@ -110,6 +117,31 @@ struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
|
||||
// generic macros
|
||||
#define dout_prefix *_dout
|
||||
|
||||
#ifdef WITH_SEASTAR
|
||||
#define dout_impl(cct, sub, v) \
|
||||
do { \
|
||||
if (ceph::common::local_conf()->subsys.should_gather(sub, v)) { \
|
||||
seastar::logger& _logger = ceph::get_logger(sub); \
|
||||
const auto _lv = v; \
|
||||
std::ostringstream _out; \
|
||||
std::ostream* _dout = &_out;
|
||||
#define dendl_impl \
|
||||
""; \
|
||||
const std::string _s = _out.str(); \
|
||||
if (_lv < 0) { \
|
||||
_logger.error(_s.c_str()); \
|
||||
} else if (_lv < 1) { \
|
||||
_logger.warn(_s.c_str()); \
|
||||
} else if (_lv < 5) { \
|
||||
_logger.info(_s.c_str()); \
|
||||
} else if (_lv < 10) { \
|
||||
_logger.debug(_s.c_str()); \
|
||||
} else { \
|
||||
_logger.trace(_s.c_str()); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define dout_impl(cct, sub, v) \
|
||||
do { \
|
||||
const bool should_gather = [&](const auto cctX) { \
|
||||
@ -134,6 +166,12 @@ struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
|
||||
auto _dout_cct = cct; \
|
||||
std::ostream* _dout = &_dout_e->get_ostream();
|
||||
|
||||
#define dendl_impl std::flush; \
|
||||
_dout_cct->_log->submit_entry(_dout_e); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif // WITH_SEASTAR
|
||||
|
||||
#define lsubdout(cct, sub, v) dout_impl(cct, ceph_subsys_##sub, v) dout_prefix
|
||||
#define ldout(cct, v) dout_impl(cct, dout_subsys, v) dout_prefix
|
||||
#define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix
|
||||
@ -150,11 +188,6 @@ struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
|
||||
#define ldlog_p1(cct, sub, lvl) \
|
||||
(cct->_conf->subsys.should_gather((sub), (lvl)))
|
||||
|
||||
#define dendl_impl std::flush; \
|
||||
_dout_cct->_log->submit_entry(_dout_e); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define dendl dendl_impl
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,115 @@
|
||||
add_library(crimson::cflags INTERFACE IMPORTED)
|
||||
set_target_properties(crimson::cflags PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "WITH_SEASTAR=1"
|
||||
INTERFACE_LINK_LIBRARIES Seastar::seastar)
|
||||
|
||||
set(crimson_common_srcs
|
||||
common/config_proxy.cc
|
||||
common/assert.cc
|
||||
common/log.cc)
|
||||
|
||||
# the specialized version of ceph-common, where
|
||||
# - the logging is sent to Seastar backend
|
||||
# - and the template parameter of lock_policy is SINGLE
|
||||
add_library(crimson-common STATIC
|
||||
${PROJECT_SOURCE_DIR}/src/common/addr_parsing.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/admin_socket.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/admin_socket_client.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/armor.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/bit_str.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/bloom_filter.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_argparse.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_context.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_crypto.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_hash.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_time.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ceph_strings.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/cmdparse.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/common_init.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/code_environment.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/config.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/config_values.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/dout.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/entity_name.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/environment.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/errno.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/escape.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/hex.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/fs_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/histogram.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/hobject.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/hostname.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ipaddr.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/io_priority.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/lockdep.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/mutex_debug.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/mempool.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/options.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/perf_counters.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/perf_histogram.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/page.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/pipe.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/snap_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/safe_io.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/signal.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/str_list.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/str_map.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/strtol.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/reverse.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/utf8.c
|
||||
${PROJECT_SOURCE_DIR}/src/common/version.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/BackTrace.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/CachedPrebufferedStreambuf.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/ConfUtils.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/DecayCounter.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/HTMLFormatter.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/Formatter.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/Graylog.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/LogEntry.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/Mutex.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/RefCountedObj.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/SubProcess.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/TextTable.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/Thread.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/HeartbeatMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/common/PluginRegistry.cc
|
||||
${PROJECT_SOURCE_DIR}/src/librbd/Features.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
|
||||
${PROJECT_SOURCE_DIR}/src/mds/FSMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mds/FSMapUser.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mds/MDSMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/msg/msg_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/msg/Message.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mon/MonCap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/osd_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/ECMsgTypes.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/HitSet.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/OSDMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/PGPeeringEvent.cc
|
||||
${crimson_common_srcs}
|
||||
$<TARGET_OBJECTS:crimson-auth>
|
||||
$<TARGET_OBJECTS:common_buffer_obj>
|
||||
$<TARGET_OBJECTS:crimson-crush>
|
||||
$<TARGET_OBJECTS:global_common_objs>)
|
||||
|
||||
target_compile_definitions(crimson-common PRIVATE
|
||||
"CEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\""
|
||||
"CEPH_PKGLIBDIR=\"${CMAKE_INSTALL_FULL_PKGLIBDIR}\"")
|
||||
|
||||
target_link_libraries(crimson-common
|
||||
PUBLIC
|
||||
json_spirit
|
||||
PRIVATE
|
||||
crc32
|
||||
crimson::cflags
|
||||
Boost::iostreams
|
||||
Boost::random
|
||||
${NSS_LIBRARIES} ${NSPR_LIBRARIES} ${OPENSSL_LIBRARIES})
|
||||
|
||||
set(crimson_net_srcs
|
||||
net/Dispatcher.cc
|
||||
net/Errors.cc
|
||||
@ -6,11 +118,14 @@ set(crimson_net_srcs
|
||||
set(crimson_thread_srcs
|
||||
thread/ThreadPool.cc
|
||||
thread/Throttle.cc)
|
||||
set(crimson_common_srcs
|
||||
common/config_proxy.cc)
|
||||
add_library(crimson STATIC
|
||||
${crimson_common_srcs}
|
||||
${crimson_net_srcs}
|
||||
${crimson_thread_srcs}
|
||||
${CMAKE_SOURCE_DIR}/src/common/buffer_seastar.cc)
|
||||
target_link_libraries(crimson Seastar::seastar ceph-common)
|
||||
target_compile_options(crimson PRIVATE
|
||||
"-ftemplate-backtrace-limit=0")
|
||||
target_link_libraries(crimson
|
||||
PUBLIC
|
||||
crimson-common Seastar::seastar
|
||||
PRIVATE
|
||||
crimson::cflags)
|
||||
|
56
src/crimson/common/assert.cc
Normal file
56
src/crimson/common/assert.cc
Normal file
@ -0,0 +1,56 @@
|
||||
#include <cstdarg>
|
||||
|
||||
#include <seastar/util/backtrace.hh>
|
||||
#include <seastar/core/reactor.hh>
|
||||
|
||||
#include "include/assert.h"
|
||||
|
||||
#include "crimson/common/log.h"
|
||||
|
||||
namespace ceph {
|
||||
[[gnu::cold]] void __ceph_assert_fail(const ceph::assert_data &ctx)
|
||||
{
|
||||
__ceph_assert_fail(ctx.assertion, ctx.file, ctx.line, ctx.function);
|
||||
}
|
||||
|
||||
[[gnu::cold]] void __ceph_assert_fail(const char* assertion,
|
||||
const char* file, int line,
|
||||
const char* func)
|
||||
{
|
||||
seastar::logger& logger = ceph::get_logger(0);
|
||||
logger.error("{}:{} : In function '{}', ceph_assert(%s)\n"
|
||||
"{}",
|
||||
file, line, func, assertion,
|
||||
seastar::current_backtrace());
|
||||
abort();
|
||||
}
|
||||
[[gnu::cold]] void __ceph_assertf_fail(const char *assertion,
|
||||
const char *file, int line,
|
||||
const char *func, const char* msg,
|
||||
...)
|
||||
{
|
||||
char buf[8096];
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
std::vsnprintf(buf, sizeof(buf), msg, args);
|
||||
va_end(args);
|
||||
|
||||
seastar::logger& logger = ceph::get_logger(0);
|
||||
logger.error("{}:{} : In function '{}', ceph_assert(%s)\n"
|
||||
"{}",
|
||||
file, line, func, assertion,
|
||||
seastar::current_backtrace());
|
||||
abort();
|
||||
}
|
||||
|
||||
[[gnu::cold]] void __ceph_abort(const char* file, int line,
|
||||
const char* func, const std::string& msg)
|
||||
{
|
||||
seastar::logger& logger = ceph::get_logger(0);
|
||||
logger.error("{}:{} : In function '{}', abort(%s)\n"
|
||||
"{}",
|
||||
file, line, func, msg,
|
||||
seastar::current_backtrace());
|
||||
abort();
|
||||
}
|
||||
}
|
@ -111,6 +111,21 @@ public:
|
||||
return get_config().template get_val<T>(*values, key);
|
||||
}
|
||||
|
||||
int get_all_sections(std::vector<std::string>& sections) const {
|
||||
return get_config().get_all_sections(sections);
|
||||
}
|
||||
|
||||
int get_val_from_conf_file(const std::vector<std::string>& sections,
|
||||
const std::string& key, std::string& out,
|
||||
bool expand_meta) const {
|
||||
return get_config().get_val_from_conf_file(*values, sections, key,
|
||||
out, expand_meta);
|
||||
}
|
||||
|
||||
unsigned get_osd_pool_default_min_size() const {
|
||||
return get_config().get_osd_pool_default_min_size(*values);
|
||||
}
|
||||
|
||||
seastar::future<> set_mon_vals(const std::map<std::string,std::string>& kv) {
|
||||
return do_change([kv, this](ConfigValues& values) {
|
||||
get_config().set_mon_vals(nullptr, values, obs_mgr, kv, nullptr);
|
||||
|
18
src/crimson/common/log.cc
Normal file
18
src/crimson/common/log.cc
Normal file
@ -0,0 +1,18 @@
|
||||
#include "log.h"
|
||||
|
||||
static std::array<seastar::logger, ceph_subsys_get_num()> loggers{
|
||||
#define SUBSYS(name, log_level, gather_level) \
|
||||
seastar::logger(#name),
|
||||
#define DEFAULT_SUBSYS(log_level, gather_level) \
|
||||
seastar::logger("none"),
|
||||
#include "common/subsys.h"
|
||||
#undef SUBSYS
|
||||
#undef DEFAULT_SUBSYS
|
||||
};
|
||||
|
||||
namespace ceph {
|
||||
seastar::logger& get_logger(int subsys) {
|
||||
assert(subsys < ceph_subsys_max);
|
||||
return loggers[subsys];
|
||||
}
|
||||
}
|
6
src/crimson/common/log.h
Normal file
6
src/crimson/common/log.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include <seastar/util/log.hh>
|
||||
#include "common/subsys_types.h"
|
||||
|
||||
namespace ceph {
|
||||
seastar::logger& get_logger(int subsys);
|
||||
}
|
@ -27,6 +27,8 @@
|
||||
#include "auth/AuthSessionHandler.h"
|
||||
#include "msg/Message.h"
|
||||
|
||||
#include "crimson/common/log.h"
|
||||
|
||||
using namespace ceph::net;
|
||||
|
||||
template <typename T>
|
||||
@ -34,6 +36,12 @@ seastar::net::packet make_static_packet(const T& value) {
|
||||
return { reinterpret_cast<const char*>(&value), sizeof(value) };
|
||||
}
|
||||
|
||||
namespace {
|
||||
seastar::logger& logger() {
|
||||
return ceph::get_logger(ceph_subsys_ms);
|
||||
}
|
||||
}
|
||||
|
||||
SocketConnection::SocketConnection(Messenger *messenger,
|
||||
const entity_addr_t& my_addr,
|
||||
const entity_addr_t& peer_addr,
|
||||
@ -663,6 +671,7 @@ seastar::future<> SocketConnection::handle_connect_reply(msgr_tag_t tag)
|
||||
return fault();
|
||||
case CEPH_MSGR_TAG_BADAUTHORIZER:
|
||||
if (h.got_bad_auth) {
|
||||
logger().error("{} got bad authorizer", __func__);
|
||||
throw std::system_error(make_error_code(error::negotiation_failure));
|
||||
}
|
||||
h.got_bad_auth = true;
|
||||
@ -724,6 +733,7 @@ seastar::future<> SocketConnection::handle_connect_reply(msgr_tag_t tag)
|
||||
return seastar::now();
|
||||
} else {
|
||||
// unknown tag
|
||||
logger().error("{} got unknown tag", __func__, int(tag));
|
||||
throw std::system_error(make_error_code(error::negotiation_failure));
|
||||
}
|
||||
}
|
||||
@ -789,6 +799,7 @@ seastar::future<> SocketConnection::connect(entity_type_t peer_type,
|
||||
if (h.authorizer) {
|
||||
auto reply = bl.cbegin();
|
||||
if (!h.authorizer->verify_reply(reply)) {
|
||||
logger().error("{} authorizer failed to verify reply", __func__);
|
||||
throw std::system_error(make_error_code(error::negotiation_failure));
|
||||
}
|
||||
}
|
||||
|
@ -9,3 +9,11 @@ set(crush_srcs
|
||||
CrushLocation.cc)
|
||||
|
||||
add_library(crush_objs OBJECT ${crush_srcs})
|
||||
|
||||
if(WITH_SEASTAR)
|
||||
add_library(crimson-crush OBJECT ${crush_srcs})
|
||||
target_compile_definitions(crimson-crush PRIVATE
|
||||
"WITH_SEASTAR=1")
|
||||
target_include_directories(crimson-crush PRIVATE
|
||||
$<TARGET_PROPERTY:Seastar::seastar,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
endif()
|
||||
|
@ -20,7 +20,11 @@
|
||||
*/
|
||||
CephContext *g_ceph_context = NULL;
|
||||
ConfigProxy& g_conf() {
|
||||
#ifdef WITH_SEASTAR
|
||||
return ceph::common::local_conf();
|
||||
#else
|
||||
return g_ceph_context->_conf;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *g_assert_file = 0;
|
||||
|
@ -16,7 +16,11 @@
|
||||
#include "FSMap.h"
|
||||
|
||||
#include <sstream>
|
||||
#ifdef WITH_SEASTAR
|
||||
#include "crimson/common/config_proxy.h"
|
||||
#else
|
||||
#include "common/config_proxy.h"
|
||||
#endif
|
||||
#include "global/global_context.h"
|
||||
#include "mon/health_check.h"
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "common/Clock.h"
|
||||
#include "mds/MDSMap.h"
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#include "include/CompatSet.h"
|
||||
#include "include/ceph_features.h"
|
||||
#include "common/Formatter.h"
|
||||
|
@ -15,11 +15,15 @@
|
||||
#ifndef CEPH_MONMAP_H
|
||||
#define CEPH_MONMAP_H
|
||||
|
||||
#include "include/err.h"
|
||||
|
||||
#include "msg/Message.h"
|
||||
#include "common/config_fwd.h"
|
||||
|
||||
#include "include/err.h"
|
||||
#include "include/types.h"
|
||||
|
||||
#include "mon/mon_types.h"
|
||||
#include "msg/Message.h"
|
||||
|
||||
|
||||
namespace ceph {
|
||||
class Formatter;
|
||||
|
Loading…
Reference in New Issue
Block a user