#ifndef CEPH_DOUT_STREAMBUF_H
#define CEPH_DOUT_STREAMBUF_H
-#include "common/config.h"
+#include "common/config_obs.h"
#include <iosfwd>
#include <pthread.h>
#include "common/code_environment.h"
#include "common/signal.h"
+#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
+#include <stdlib.h>
+#include <sys/user.h> // for PAGE_MASK
class Thread {
private:
// 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 <char, std::basic_string<char>::traits_type> *_doss(g_ceph_context._doss);
class CephContextServiceThread : public Thread
/* Globals (FIXME: remove) */
extern CephContext g_ceph_context;
extern md_config_t *g_conf;
-extern std::ostream *_dout;
extern DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
#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
#define OSD_REP_CHAIN 2
class config_option;
-class md_config_obs_t;
extern const char *CEPH_CONF_FILE_DEFAULT;
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 <std::string> &changed) = 0;
-};
-
-#include "common/debug.h"
+#include "common/debug.h" // TODO: remove
#endif
--- /dev/null
+// -*- 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 <sage@newdream.net>
+ *
+ * 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 <set>
+#include <string>
+
+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 <std::string> &changed) = 0;
+};
+
+#endif
/*
* Ceph - scalable distributed file system
*
- * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
- * 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
#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 <iostream>
-#include <pthread.h>
-#include <streambuf>
-
-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
--- /dev/null
+// -*- 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 <sage@newdream.net>
+ * 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 <iostream>
+#include <pthread.h>
+#include <streambuf>
+
+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
#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 ";
}
#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 "
#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 ";
}
#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 "
#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 "
#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 "
#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
// -----------------------
#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 << ") ";
#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 << " ";
#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 << ") ";
#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 << " ";
#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() << " ";
#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)" :
#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 << ") ";
}
#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 << " ";
#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() << " ";
#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 << " ";
#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)" :
#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) << ") ";
#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 << " ";
}
*/
#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
* SimpleMessenger
*/
#undef dout_prefix
-#define dout_prefix _prefix(this)
+#define dout_prefix _prefix(_dout, this)
void SimpleMessenger::dispatch_throttle_release(uint64_t msize)
{
class Pipe : public RefCountedObject {
public:
SimpleMessenger *messenger;
- ostream& _pipe_prefix();
+ ostream& _pipe_prefix(std::ostream *_dout);
enum {
STATE_ACCEPTING,
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;
#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"
#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");
}
#undef dout_prefix
-#define dout_prefix _prefix(*_dout, whoami, osdmap)
+#define dout_prefix _prefix(_dout, whoami, osdmap)
// cons/des
#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)
#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();
}
#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 << " ";
}