]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Create de-globalized versions of the dout macro
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 10 Jun 2011 18:07:45 +0000 (11:07 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 20 Jun 2011 23:06:54 +0000 (16:06 -0700)
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 <colin.mccabe@dreamhost.com>
34 files changed:
src/common/DoutStreambuf.h
src/common/Thread.h
src/common/ceph_context.cc
src/common/ceph_context.h
src/common/config.h
src/common/config_obs.h [new file with mode: 0644]
src/common/debug.h
src/common/dout.h [new file with mode: 0644]
src/mds/Locker.cc
src/mds/MDBalancer.cc
src/mds/MDCache.cc
src/mds/MDLog.cc
src/mds/Migrator.cc
src/mds/journal.cc
src/mds/snap.cc
src/mon/AuthMonitor.cc
src/mon/Elector.cc
src/mon/LogMonitor.cc
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/mon/MonitorStore.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc
src/mon/Paxos.cc
src/mon/PaxosService.cc
src/msg/SimpleMessenger.cc
src/msg/SimpleMessenger.h
src/objclass/class_debug.cc
src/os/FileStore.cc
src/osd/OSD.cc
src/osd/OSDCaps.cc
src/osd/PG.cc
src/osd/ReplicatedPG.cc

index 472dfefbe1ac959878deff637def2e81697aee24..52279edf6aa649c7a98dfcaf29bef8960c57fbb7 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef CEPH_DOUT_STREAMBUF_H
 #define CEPH_DOUT_STREAMBUF_H
 
-#include "common/config.h"
+#include "common/config_obs.h"
 
 #include <iosfwd>
 #include <pthread.h>
index 226256870075059616436422f0817a758a9f3ab9..2c5b061464a8794f68954f1bbcc022e9b0a681b8 100644 (file)
 #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:
index 275110e9d03663533612c7471ca80a8faeab481d..7ab89b4e8dee5e2eaaab0320385204f867a505ef 100644 (file)
@@ -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 <char, std::basic_string<char>::traits_type> *_doss(g_ceph_context._doss);
 
 class CephContextServiceThread : public Thread
index 6974cc8ac814dc1cb6663964b6cb89575439fd77..840b8c506e229b349aecd23a67a9326ea7c6cb9e 100644 (file)
@@ -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 <char, std::basic_string<char>::traits_type> *_doss;
 
 
index 1a389d9807d4dd0e404e5fc9da9602ed807a48aa..19180ad8ccbcf53ad59e214bb0f8bafae2963b3c 100644 (file)
@@ -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 <std::string> &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 (file)
index 0000000..904ebe3
--- /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
+/*
+ * 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
index 7aaa7665ddf19a1fe54280796e851fc75cda23a3..1cf31d0c469fd9a5e5d09affe06bc225ebe5a2ad 100644 (file)
@@ -3,8 +3,7 @@
 /*
  * 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
diff --git a/src/common/dout.h b/src/common/dout.h
new file mode 100644 (file)
index 0000000..4b3e0e2
--- /dev/null
@@ -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 <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
index a87edb10563ff2bc784418136d6024e5f25771b2..b6cce0a4a9fc2dcc0477ceafe036e8788cf2d7c2 100644 (file)
@@ -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 ";
 }
 
index db4a07f19f80678f9feb1a46edb01561a7d93e66..8ef0569c26c8c809a99ae840efc7c69ac3823e6c 100644 (file)
@@ -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 "
 
index d7a929d1c6d03261c43a9b163e85b7cd10ae6223..64b80ff274ba64aea7cce4181bbde2cb72ab232f 100644 (file)
@@ -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 ";
 }
 
index dcc9c0450aa1243c89924659978a9316b54b4950..400dc097a701371c054f752081fd5546c5f4128c 100644 (file)
@@ -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 "
 
index 68f9cd71acbd93f0ac50cc9357b1d78a9752e9f3..50a25cc7ea73471ea05ee22ca7d148153e71681e 100644 (file)
@@ -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 "
 
index 681482ce8dccb1a9244564bc4f03a7b11be2606d..b24e1619f89bb0899a4be48d5dc6ef0d2477a2ee 100644 (file)
@@ -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
 
 
 // -----------------------
index cfa2af5f18cfedc1d2cf607ca2d4735853164088..026fcd3e8f18a5be27e85a5cadf5360bc08fea75 100644 (file)
@@ -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 << ") ";
index 2b5f70a3f73ccb193423ef2e86e397c8f9d74734..4cfc0769a233e3262c06ab5a73ce4ce82a4b619d 100644 (file)
@@ -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 << " ";
index 19845c0a77c9ae2ef7359f17173718d0bcfde9bb..d8515eb76f635b8c0d13eb5f554f233ec2d5a19a 100644 (file)
@@ -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 << ") ";
index 8732f57c29c76df1cb5550118c92464a54c1abc5..a72d1d74280d70acec102971599742cb2396e7ac 100644 (file)
@@ -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 << " ";
index 9733d208305970f3c7806c58b421f57650227714..95079725062bffc51a78b2056253ba7aa788c8d7 100644 (file)
@@ -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() << " ";
index 75fd0506d321d1ad501a6e3d9eac7378f2887ce5..c5fdf422282f771b8bd9acc5ad2f11254eac25c2 100644 (file)
@@ -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)" : 
index 95983dc3bd2ec2a2233a1967a75d5dd40d75a9dd..fedb10d9e9e479b86428c5052183c9e62a81526b 100644 (file)
@@ -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 << ") ";
 }
 
index 496e6071fde4c33e664861152b33c79b35f5b76f..d7b9c0ecc880d9a00c8ca2945eeef2816e3790c8 100644 (file)
@@ -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 << " ";
index de4771b8be16d4a04b062173dfd6eb801010935f..693d36ccb1cb18369ea156d1b0d6e767e4ff7753 100644 (file)
@@ -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() << " ";
index 6d854a4ee45914cb75340220ee1e3913d4242060..b9b464e09025f2e57222ba2a41b8fa22c80ffffd 100644 (file)
@@ -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 << " ";
index d44a70e64f80e2c75ee1d76cfd9f7a09e74e14bc..4afc0a86a92d34cbe0bed7d5d0c3ba14902e187f 100644 (file)
@@ -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)" :
index 451e18d5e20350f8d85327c592027812f1ee0931..11e6b3838db9c3eeaf8c0095d9c02ddfce31ce02 100644 (file)
@@ -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) << ") ";
index 4e13093d33db310ba4d0645e6653d9dabe7bf751..99f300a642bda87464bfd71cf1044affba9f4960 100644 (file)
@@ -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)
 {
index 10f70792b9523302aec8a5772fb46af2661c303c..e5f4fdfbb83cd1b8a5afddf9ada77f1ca61805cb 100644 (file)
@@ -115,7 +115,7 @@ private:
   class Pipe : public RefCountedObject {
   public:
     SimpleMessenger *messenger;
-    ostream& _pipe_prefix();
+    ostream& _pipe_prefix(std::ostream *_dout);
 
     enum {
       STATE_ACCEPTING,
index 3041f55c7bf20e46bfaeb2c229774dfcc1420748..85c809f910a7d3c7c988ae370f16e253d0ea0a0a 100644 (file)
@@ -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;
index 407edc50f40c706ae2bbba9bc3ef545635b1f38a..0d65fe9a6ecf8171756e2d2739a0cef0a8c262db 100644 (file)
@@ -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"
index 731d2f7fd51e337d9106194316764e7c3d356d3e..e44641313e1811075253628758ac05df5ff2d759 100644 (file)
 #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
 
index fbeb33f10c9b7b355a17c90d81bcaa01f0f6449b..c3f0a40f3d8b65dff8b5e0d840bcd95c5d9ad06b 100644 (file)
@@ -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)
 
index 58cbc7f45e3dc5096fa974a6232466ce7ac8268e..643002f96240945771d7fd8c766668a2672ab758 100644 (file)
@@ -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();
 }
 
index 0c2715da7345c4b013e79e943458bb1d9b9f9ccd..3e6ccb7a175806abb704e88ba6b5af0c4761dba5 100644 (file)
@@ -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 << " ";
 }