From 5a612f958906fc8cea28a225ab4ba1de6853a9b3 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 10 Jun 2011 11:07:45 -0700 Subject: [PATCH] Create de-globalized versions of the dout macro The de-globalized versions are available in dout.h Versions relying on globals continue to be available in debug.h Split md_config_obs_t off into common/config_obs.h. This will make it possible for DoutStreambuf.h to include just that structure, without pulling in all of config.h. Signed-off-by: Colin McCabe --- src/common/DoutStreambuf.h | 2 +- src/common/Thread.h | 3 + src/common/ceph_context.cc | 1 - src/common/ceph_context.h | 1 - src/common/config.h | 17 ++---- src/common/config_obs.h | 31 +++++++++++ src/common/debug.h | 89 +++--------------------------- src/common/dout.h | 106 ++++++++++++++++++++++++++++++++++++ src/mds/Locker.cc | 4 +- src/mds/MDBalancer.cc | 2 +- src/mds/MDCache.cc | 4 +- src/mds/MDLog.cc | 2 +- src/mds/Migrator.cc | 2 +- src/mds/journal.cc | 5 +- src/mds/snap.cc | 5 +- src/mon/AuthMonitor.cc | 4 +- src/mon/Elector.cc | 4 +- src/mon/LogMonitor.cc | 4 +- src/mon/MDSMonitor.cc | 4 +- src/mon/Monitor.cc | 4 +- src/mon/MonitorStore.cc | 4 +- src/mon/MonmapMonitor.cc | 4 +- src/mon/OSDMonitor.cc | 4 +- src/mon/PGMonitor.cc | 4 +- src/mon/Paxos.cc | 5 +- src/mon/PaxosService.cc | 4 +- src/msg/SimpleMessenger.cc | 10 ++-- src/msg/SimpleMessenger.h | 2 +- src/objclass/class_debug.cc | 2 +- src/os/FileStore.cc | 1 + src/osd/OSD.cc | 6 +- src/osd/OSDCaps.cc | 2 +- src/osd/PG.cc | 4 +- src/osd/ReplicatedPG.cc | 4 +- 34 files changed, 206 insertions(+), 144 deletions(-) create mode 100644 src/common/config_obs.h create mode 100644 src/common/dout.h diff --git a/src/common/DoutStreambuf.h b/src/common/DoutStreambuf.h index 472dfefbe1ac9..52279edf6aa64 100644 --- a/src/common/DoutStreambuf.h +++ b/src/common/DoutStreambuf.h @@ -20,7 +20,7 @@ #ifndef CEPH_DOUT_STREAMBUF_H #define CEPH_DOUT_STREAMBUF_H -#include "common/config.h" +#include "common/config_obs.h" #include #include diff --git a/src/common/Thread.h b/src/common/Thread.h index 2262568700750..2c5b061464a87 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -19,9 +19,12 @@ #include "common/code_environment.h" #include "common/signal.h" +#include #include #include #include +#include +#include // for PAGE_MASK class Thread { private: diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 275110e9d0366..7ab89b4e8dee5 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -27,7 +27,6 @@ // These variables are here temporarily to make the transition easier. CephContext g_ceph_context __attribute__((init_priority(103))) (0); md_config_t *g_conf(g_ceph_context._conf); -std::ostream *_dout(&g_ceph_context._dout); DoutStreambuf ::traits_type> *_doss(g_ceph_context._doss); class CephContextServiceThread : public Thread diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index 6974cc8ac814d..840b8c506e229 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -80,7 +80,6 @@ private: /* Globals (FIXME: remove) */ extern CephContext g_ceph_context; extern md_config_t *g_conf; -extern std::ostream *_dout; extern DoutStreambuf ::traits_type> *_doss; diff --git a/src/common/config.h b/src/common/config.h index 1a389d9807d4d..19180ad8ccbcf 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -23,8 +23,9 @@ extern struct ceph_file_layout g_default_file_layout; #include "common/ConfUtils.h" #include "common/entity_name.h" -#include "common/Mutex.h" -#include "include/assert.h" +#include "common/Mutex.h" // TODO: remove +#include "include/assert.h" // TODO: remove +#include "common/config_obs.h" #include "msg/msg_types.h" #define OSD_REP_PRIMARY 0 @@ -32,7 +33,6 @@ extern struct ceph_file_layout g_default_file_layout; #define OSD_REP_CHAIN 2 class config_option; -class md_config_obs_t; extern const char *CEPH_CONF_FILE_DEFAULT; @@ -529,15 +529,6 @@ struct config_option { const void *conf_ptr(const md_config_t *conf) const; }; -class md_config_obs_t { -public: - virtual ~md_config_obs_t(); // we won't actually use this, but it's safest - // when you have virtual functions - virtual const char** get_tracked_conf_keys() const = 0; - virtual void handle_conf_change(const md_config_t *conf, - const std::set &changed) = 0; -}; - -#include "common/debug.h" +#include "common/debug.h" // TODO: remove #endif diff --git a/src/common/config_obs.h b/src/common/config_obs.h new file mode 100644 index 0000000000000..904ebe339c1a5 --- /dev/null +++ b/src/common/config_obs.h @@ -0,0 +1,31 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_CONFIG_OBS_H +#define CEPH_CONFIG_OBS_H + +#include +#include + +class md_config_t; + +class md_config_obs_t { +public: + virtual ~md_config_obs_t(); + virtual const char** get_tracked_conf_keys() const = 0; + virtual void handle_conf_change(const struct md_config_t *conf, + const std::set &changed) = 0; +}; + +#endif diff --git a/src/common/debug.h b/src/common/debug.h index 7aaa7665ddf19..1cf31d0c469fd 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -3,8 +3,7 @@ /* * Ceph - scalable distributed file system * - * Copyright (C) 2004-2010 Sage Weil - * Copyright (C) 2010 Dreamhost + * Copyright (C) 2004-2011 New Dream Network * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,89 +15,19 @@ #ifndef CEPH_DEBUG_H #define CEPH_DEBUG_H -#include "common/ceph_context.h" -#include "common/likely.h" -#include "common/config.h" // need for g_conf -#include "include/assert.h" +#include "common/dout.h" -#include -#include -#include - -extern void dout_emergency(const char * const str); - -extern void dout_emergency(const std::string &str); - -class DoutLocker -{ -public: - DoutLocker(pthread_mutex_t *lock_) - : lock(lock_) - { - pthread_mutex_lock(lock); - } - DoutLocker() - : lock(NULL) - { - } - ~DoutLocker() { - if (lock) - pthread_mutex_unlock(lock); - } - pthread_mutex_t *lock; -}; - -static inline void _dout_begin_line(signed int prio) { - // Put priority information into dout - std::streambuf *doss = (std::streambuf*)_doss; - doss->sputc(prio + 12); - - // Some information that goes in every dout message - *_dout << std::hex << pthread_self() << std::dec << " "; -} - -// intentionally conflict with endl -class _bad_endl_use_dendl_t { public: _bad_endl_use_dendl_t(int) {} }; -static const _bad_endl_use_dendl_t endl = 0; -inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) { - assert(0 && "you are using the wrong endl.. use std::endl or dendl"); - return out; -} - -// generic macros -#define debug_DOUT_SUBSYS debug -#define dout_prefix *_dout -#define DOUT_CONDVAR(x) g_conf->debug_ ## x -#define XDOUT_CONDVAR(x) DOUT_CONDVAR(x) -#define DOUT_COND(l) l <= XDOUT_CONDVAR(DOUT_SUBSYS) - -// The array declaration will trigger a compiler error if 'l' is -// out of range -#define dout_impl(v) \ - if (0) {\ - char __array[((v >= -1) && (v <= 200)) ? 0 : -1] __attribute__((unused)); \ - }\ - DoutLocker __dout_locker; \ - g_ceph_context.dout_lock(&__dout_locker); \ - _dout_begin_line(v); \ - -#define dout(v) \ - do { if (DOUT_COND(v)) {\ - dout_impl(v) \ - dout_prefix +/* Global version of the stuff in common/dout.h + */ -#define pdout(v, p) \ - do { if ((v) <= (p)) {\ - dout_impl(v) \ - *_dout +#define dout(v) ldout((&g_ceph_context), v) -#define generic_dout(v) \ - pdout(v, g_conf->debug) +#define pdout(v, p) lpdout((&g_ceph_context), v, p) -#define dendl std::endl; } } while (0) +#define generic_dout(v) lgeneric_dout((&g_ceph_context), v) -#define derr dout(-1) +#define derr lderr((&g_ceph_context)) -#define generic_derr generic_dout(-1) +#define generic_derr lgeneric_derr((&g_ceph_context)) #endif diff --git a/src/common/dout.h b/src/common/dout.h new file mode 100644 index 0000000000000..4b3e0e2d2bbe6 --- /dev/null +++ b/src/common/dout.h @@ -0,0 +1,106 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2010 Sage Weil + * Copyright (C) 2010 Dreamhost + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_DOUT_H +#define CEPH_DOUT_H + +#include "common/ceph_context.h" +#include "common/DoutStreambuf.h" +#include "common/likely.h" +#include "common/config.h" // need for g_conf +#include "include/assert.h" + +#include +#include +#include + +extern void dout_emergency(const char * const str); + +extern void dout_emergency(const std::string &str); + +class DoutLocker +{ +public: + DoutLocker(pthread_mutex_t *lock_) + : lock(lock_) + { + pthread_mutex_lock(lock); + } + DoutLocker() + : lock(NULL) + { + } + ~DoutLocker() { + if (lock) + pthread_mutex_unlock(lock); + } + pthread_mutex_t *lock; +}; + +static inline void _dout_begin_line(CephContext *cct, signed int prio) { + // Put priority information into dout + cct->_doss->sputc(prio + 12); + + // Some information that goes in every dout message + cct->_dout << std::hex << pthread_self() << std::dec << " "; +} + +// intentionally conflict with endl +class _bad_endl_use_dendl_t { public: _bad_endl_use_dendl_t(int) {} }; +static const _bad_endl_use_dendl_t endl = 0; +inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) { + assert(0 && "you are using the wrong endl.. use std::endl or dendl"); + return out; +} + +// generic macros +#define debug_DOUT_SUBSYS debug +#define dout_prefix *_dout +#define DOUT_CONDVAR(cct, x) cct->_conf->debug_ ## x +#define XDOUT_CONDVAR(cct, x) DOUT_CONDVAR(cct, x) +#define DOUT_COND(cct, l) l <= XDOUT_CONDVAR(cct, DOUT_SUBSYS) + +// The array declaration will trigger a compiler error if 'l' is +// out of range +#define dout_impl(cct, v) \ + if (0) {\ + char __array[((v >= -1) && (v <= 200)) ? 0 : -1] __attribute__((unused)); \ + }\ + DoutLocker __dout_locker; \ + cct->dout_lock(&__dout_locker); \ + _dout_begin_line(cct, v); \ + +#define ldout(cct, v) \ + do { if (DOUT_COND(cct, v)) {\ + dout_impl(cct, v) \ + std::ostream* _dout = &(cct->_dout); \ + dout_prefix + +#define lpdout(cct, v, p) \ + do { if ((v) <= (p)) {\ + dout_impl(cct, v) \ + std::ostream* _dout = &(cct->_dout); \ + *_dout + +#define lgeneric_dout(cct, v) \ + lpdout(cct, v, cct->_conf->debug) + +#define lderr(cct) ldout(cct, -1) + +#define lgeneric_derr(cct) lgeneric_dout(cct, -1) + +#define dendl std::endl; } } while (0) + +#endif diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index a87edb10563ff..b6cce0a4a9fc2 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -57,8 +57,8 @@ #define DOUT_SUBSYS mds #undef dout_prefix -#define dout_prefix _prefix(mds) -static ostream& _prefix(MDS *mds) { +#define dout_prefix _prefix(_dout, mds) +static ostream& _prefix(std::ostream *_dout, MDS *mds) { return *_dout << "mds" << mds->get_nodeid() << ".locker "; } diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index db4a07f19f806..8ef0569c26c8c 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -37,7 +37,7 @@ using std::vector; #define DOUT_SUBSYS mds #undef DOUT_COND -#define DOUT_COND(l) l<=g_conf->debug_mds || l <= g_conf->debug_mds_balancer +#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_balancer #undef dout_prefix #define dout_prefix *_dout << "mds" << mds->get_nodeid() << ".bal " diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index d7a929d1c6d03..64b80ff274ba6 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -97,8 +97,8 @@ extern struct ceph_file_layout g_default_file_layout; #define DOUT_SUBSYS mds #undef dout_prefix -#define dout_prefix _prefix(mds) -static ostream& _prefix(MDS *mds) { +#define dout_prefix _prefix(_dout, mds) +static ostream& _prefix(std::ostream *_dout, MDS *mds) { return *_dout << "mds" << mds->get_nodeid() << ".cache "; } diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index dcc9c0450aa12..400dc097a7013 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -29,7 +29,7 @@ #define DOUT_SUBSYS mds #undef DOUT_COND -#define DOUT_COND(l) l<=g_conf->debug_mds || l <= g_conf->debug_mds_log +#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_log #undef dout_prefix #define dout_prefix *_dout << "mds" << mds->get_nodeid() << ".log " diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 68f9cd71acbd9..50a25cc7ea734 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -78,7 +78,7 @@ #define DOUT_SUBSYS mds #undef DOUT_COND -#define DOUT_COND(l) l <= g_conf->debug_mds || l <= g_conf->debug_mds_migrator +#define DOUT_COND(cct, l) l <= cct->_conf->debug_mds || l <= cct->_conf->debug_mds_migrator #undef dout_prefix #define dout_prefix *_dout << "mds" << mds->get_nodeid() << ".migrator " diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 681482ce8dccb..b24e1619f89bb 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -55,7 +55,8 @@ #define DOUT_SUBSYS mds #undef DOUT_COND -#define DOUT_COND(l) l<=g_conf->debug_mds || l <= g_conf->debug_mds_log || l <= g_conf->debug_mds_log_expire +#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_log \ + || l <= cct->_conf->debug_mds_log_expire #undef dout_prefix #define dout_prefix *_dout << "mds" << mds->get_nodeid() << ".journal " @@ -293,7 +294,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) #undef DOUT_COND -#define DOUT_COND(l) l<=g_conf->debug_mds || l <= g_conf->debug_mds_log +#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_log // ----------------------- diff --git a/src/mds/snap.cc b/src/mds/snap.cc index cfa2af5f18cfe..026fcd3e8f18a 100644 --- a/src/mds/snap.cc +++ b/src/mds/snap.cc @@ -24,8 +24,9 @@ #define DOUT_SUBSYS mds #undef dout_prefix -#define dout_prefix _prefix(mdcache->mds->get_nodeid(), inode, srnode.seq, this) -static ostream& _prefix(int whoami, CInode *inode, uint64_t seq, SnapRealm *realm) { +#define dout_prefix _prefix(_dout, mdcache->mds->get_nodeid(), inode, srnode.seq, this) +static ostream& _prefix(std::ostream *_dout, int whoami, CInode *inode, + uint64_t seq, SnapRealm *realm) { return *_dout << " mds" << whoami << ".cache.snaprealm(" << inode->ino() << " seq " << seq << " " << realm << ") "; diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 2b5f70a3f73cc..4cfc0769a233e 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -36,8 +36,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, paxos->get_version()) -static ostream& _prefix(Monitor *mon, version_t v) { +#define dout_prefix _prefix(_dout, mon, paxos->get_version()) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".auth v" << v << " "; diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 19845c0a77c9a..d8515eb76f635 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -24,8 +24,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, epoch) -static ostream& _prefix(Monitor *mon, epoch_t epoch) { +#define dout_prefix _prefix(_dout, mon, epoch) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, epoch_t epoch) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".elector(" << epoch << ") "; diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 8732f57c29c76..a72d1d74280d7 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -31,8 +31,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, paxos->get_version()) -static ostream& _prefix(Monitor *mon, version_t v) { +#define dout_prefix _prefix(_dout, mon, paxos->get_version()) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".log v" << v << " "; diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 9733d20830597..95079725062bf 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -35,8 +35,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, mdsmap) -static ostream& _prefix(Monitor *mon, MDSMap& mdsmap) { +#define dout_prefix _prefix(_dout, mon, mdsmap) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, MDSMap& mdsmap) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".mds e" << mdsmap.get_epoch() << " "; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 75fd0506d321d..c5fdf422282f7 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -65,8 +65,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(this) -static ostream& _prefix(Monitor *mon) { +#define dout_prefix _prefix(_dout, this) +static ostream& _prefix(std::ostream *_dout, Monitor *mon) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)" : diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 95983dc3bd2ec..fedb10d9e9e47 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -24,8 +24,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(dir) -static ostream& _prefix(const string& dir) { +#define dout_prefix _prefix(_dout, dir) +static ostream& _prefix(std::ostream *_dout, const string& dir) { return *_dout << "store(" << dir << ") "; } diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 496e6071fde4c..d7b9c0ecc880d 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -27,8 +27,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon) -static ostream& _prefix(Monitor *mon) { +#define dout_prefix _prefix(_dout, mon) +static ostream& _prefix(std::ostream *_dout, Monitor *mon) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".monmap v" << mon->monmap->epoch << " "; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index de4771b8be16d..693d36ccb1cb1 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -41,8 +41,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, osdmap) -static ostream& _prefix(Monitor *mon, OSDMap& osdmap) { +#define dout_prefix _prefix(_dout, mon, osdmap) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".osd e" << osdmap.get_epoch() << " "; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 6d854a4ee4591..b9b464e09025f 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -40,8 +40,8 @@ #define DOUT_SUBSYS mon #undef dout_prefix -#define dout_prefix _prefix(mon, pg_map) -static ostream& _prefix(Monitor *mon, PGMap& pg_map) { +#define dout_prefix _prefix(_dout, mon, pg_map) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, PGMap& pg_map) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".pg v" << pg_map.version << " "; diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index d44a70e64f80e..4afc0a86a92d3 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -23,8 +23,9 @@ #define DOUT_SUBSYS paxos #undef dout_prefix -#define dout_prefix _prefix(mon, mon->name, mon->rank, machine_name, state, last_committed) -static ostream& _prefix(Monitor *mon, const string& name, int rank, const char *machine_name, int state, version_t last_committed) { +#define dout_prefix _prefix(_dout, mon, mon->name, mon->rank, machine_name, state, last_committed) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, const string& name, int rank, + const char *machine_name, int state, version_t last_committed) { return *_dout << "mon." << name << "@" << rank << (mon->is_starting() ? (const char*)"(starting)" : diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 451e18d5e2035..11e6b3838db9c 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -22,8 +22,8 @@ #define DOUT_SUBSYS paxos #undef dout_prefix -#define dout_prefix _prefix(mon, paxos, paxos->machine_id) -static ostream& _prefix(Monitor *mon, Paxos *paxos, int machine_id) { +#define dout_prefix _prefix(_dout, mon, paxos, paxos->machine_id) +static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, int machine_id) { return *_dout << "mon." << mon->name << "@" << mon->rank << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)"))) << ".paxosservice(" << get_paxos_name(machine_id) << ") "; diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index 4e13093d33db3..99f300a642bda 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -41,8 +41,8 @@ #define DOUT_SUBSYS ms #undef dout_prefix -#define dout_prefix _prefix(messenger) -static ostream& _prefix(SimpleMessenger *messenger) { +#define dout_prefix _prefix(_dout, messenger) +static ostream& _prefix(std::ostream *_dout, SimpleMessenger *messenger) { return *_dout << "-- " << messenger->ms_addr << " "; } @@ -488,8 +488,8 @@ entity_addr_t SimpleMessenger::get_myaddr() */ #undef dout_prefix -#define dout_prefix _pipe_prefix() -ostream& SimpleMessenger::Pipe::_pipe_prefix() { +#define dout_prefix _pipe_prefix(_dout) +ostream& SimpleMessenger::Pipe::_pipe_prefix(std::ostream *_dout) { return *_dout << "-- " << messenger->ms_addr << " >> " << peer_addr << " pipe(" << this << " sd=" << sd << " pgs=" << peer_global_seq @@ -2242,7 +2242,7 @@ int SimpleMessenger::Pipe::write_message(Message *m) * SimpleMessenger */ #undef dout_prefix -#define dout_prefix _prefix(this) +#define dout_prefix _prefix(_dout, this) void SimpleMessenger::dispatch_throttle_release(uint64_t msize) { diff --git a/src/msg/SimpleMessenger.h b/src/msg/SimpleMessenger.h index 10f70792b9523..e5f4fdfbb83cd 100644 --- a/src/msg/SimpleMessenger.h +++ b/src/msg/SimpleMessenger.h @@ -115,7 +115,7 @@ private: class Pipe : public RefCountedObject { public: SimpleMessenger *messenger; - ostream& _pipe_prefix(); + ostream& _pipe_prefix(std::ostream *_dout); enum { STATE_ACCEPTING, diff --git a/src/objclass/class_debug.cc b/src/objclass/class_debug.cc index 3041f55c7bf20..85c809f910a7d 100644 --- a/src/objclass/class_debug.cc +++ b/src/objclass/class_debug.cc @@ -19,7 +19,7 @@ int cls_log(const char *format, ...) va_end(ap); #define MAX_SIZE 8196 if ((n > -1 && n < size) || size > MAX_SIZE) { - *_dout << buf << std::endl; + derr << buf << dendl; return n; } size *= 2; diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 407edc50f40c7..0d65fe9a6ecf8 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -25,6 +25,7 @@ #include "include/color.h" #include "common/Timer.h" +#include "common/debug.h" #include "common/errno.h" #include "common/run_cmd.h" #include "common/safe_io.h" diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 731d2f7fd51e3..e44641313e181 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -102,8 +102,8 @@ #undef dout_prefix #define dout_prefix _prefix(*_dout, whoami, osdmap) -static ostream& _prefix(ostream& out, int whoami, OSDMap *osdmap) { - return out << "osd" << whoami << " " << (osdmap ? osdmap->get_epoch():0) << " "; +static ostream& _prefix(std::ostream* _dout, int whoami, OSDMap *osdmap) { + return *_dout << "osd" << whoami << " " << (osdmap ? osdmap->get_epoch():0) << " "; } const coll_t coll_t::META_COLL("meta"); @@ -393,7 +393,7 @@ int OSD::peek_meta(const std::string &dev, std::string& magic, } #undef dout_prefix -#define dout_prefix _prefix(*_dout, whoami, osdmap) +#define dout_prefix _prefix(_dout, whoami, osdmap) // cons/des diff --git a/src/osd/OSDCaps.cc b/src/osd/OSDCaps.cc index fbeb33f10c9b7..c3f0a40f3d8b6 100644 --- a/src/osd/OSDCaps.cc +++ b/src/osd/OSDCaps.cc @@ -142,7 +142,7 @@ bool OSDCaps::parse(bufferlist::iterator& iter) #define ASSERT_STATE(x) \ do { \ if (!(x)) { \ - *_dout << "error parsing caps at pos=" << pos << " (" #x ")" << std::endl; \ + derr << "error parsing caps at pos=" << pos << " (" #x ")" << dendl; \ } \ } while (0) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 58cbc7f45e3dc..643002f962409 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -34,8 +34,8 @@ #define DOUT_SUBSYS osd #undef dout_prefix -#define dout_prefix _prefix(this) -static ostream& _prefix(const PG *pg) { +#define dout_prefix _prefix(_dout, this) +static ostream& _prefix(std::ostream *_dout, const PG *pg) { return *_dout << pg->gen_prefix(); } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 0c2715da7345c..3e6ccb7a17580 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -41,8 +41,8 @@ #define DOUT_SUBSYS osd #define DOUT_PREFIX_ARGS this, osd->whoami, osd->osdmap #undef dout_prefix -#define dout_prefix _prefix(this, osd->whoami, osd->osdmap) -static ostream& _prefix(PG *pg, int whoami, OSDMap *osdmap) { +#define dout_prefix _prefix(_dout, this, osd->whoami, osd->osdmap) +static ostream& _prefix(std::ostream *_dout, PG *pg, int whoami, OSDMap *osdmap) { return *_dout << "osd" << whoami << " " << (osdmap ? osdmap->get_epoch():0) << " " << *pg << " "; } -- 2.39.5