summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile.am17
-rw-r--r--src/auth/AuthServiceHandler.cc2
-rw-r--r--src/auth/AuthSupported.cc5
-rw-r--r--src/auth/KeyRing.cc3
-rw-r--r--src/auth/RotatingKeyRing.cc3
-rw-r--r--src/auth/cephx/CephxAuthorizeHandler.cc2
-rw-r--r--src/auth/cephx/CephxClientHandler.cc2
-rw-r--r--src/auth/cephx/CephxKeyServer.cc2
-rw-r--r--src/auth/cephx/CephxProtocol.cc2
-rw-r--r--src/auth/cephx/CephxServiceHandler.cc2
-rw-r--r--src/auth/none/AuthNoneAuthorizeHandler.cc2
-rw-r--r--src/ceph_fuse.cc4
-rw-r--r--src/ceph_mds.cc2
-rw-r--r--src/ceph_mon.cc2
-rw-r--r--src/ceph_osd.cc2
-rw-r--r--src/client/Client.cc2
-rw-r--r--src/client/Inode.cc2
-rw-r--r--src/client/Inode.h4
-rw-r--r--src/client/SyntheticClient.cc2
-rw-r--r--src/common/DecayCounter.h2
-rw-r--r--src/common/DoutStreambuf.cc644
-rw-r--r--src/common/DoutStreambuf.h135
-rw-r--r--src/common/Finisher.cc2
-rw-r--r--src/common/HeartbeatMap.cc2
-rw-r--r--src/common/LogClient.cc2
-rw-r--r--src/common/MemoryModel.cc2
-rw-r--r--src/common/Timer.cc2
-rw-r--r--src/common/WorkQueue.cc2
-rw-r--r--src/common/admin_socket.cc2
-rw-r--r--src/common/assert.cc10
-rw-r--r--src/common/ceph_argparse.cc8
-rw-r--r--src/common/ceph_argparse.h6
-rw-r--r--src/common/ceph_context.cc95
-rw-r--r--src/common/ceph_context.h20
-rw-r--r--src/common/common_init.cc3
-rw-r--r--src/common/config.cc199
-rw-r--r--src/common/config.h33
-rw-r--r--src/common/config_obs.h2
-rw-r--r--src/common/config_opts.h73
-rw-r--r--src/common/dout.cc12
-rw-r--r--src/common/dout.h92
-rw-r--r--src/common/lockdep.cc5
-rw-r--r--src/common/pick_address.cc2
-rw-r--r--src/common/signal.cc1
-rw-r--r--src/crush/CrushWrapper.cc2
-rw-r--r--src/crushtool.cc1
-rw-r--r--src/global/global_context.cc1
-rw-r--r--src/global/global_context.h5
-rw-r--r--src/global/global_init.cc19
-rw-r--r--src/global/signal_handler.cc1
-rw-r--r--src/include/Context.h20
-rw-r--r--src/init-ceph.in6
-rw-r--r--src/librados/IoCtxImpl.cc2
-rw-r--r--src/librados/RadosClient.cc2
-rw-r--r--src/librados/librados.cc2
-rw-r--r--src/librbd.cc2
-rw-r--r--src/log/Entry.h36
-rw-r--r--src/log/EntryQueue.h78
-rw-r--r--src/log/Log.cc229
-rw-r--r--src/log/Log.h69
-rw-r--r--src/log/SubsystemMap.h82
-rw-r--r--src/log/test.cc143
-rw-r--r--src/mds/AnchorClient.cc2
-rw-r--r--src/mds/AnchorServer.cc2
-rw-r--r--src/mds/CDentry.cc2
-rw-r--r--src/mds/CDir.cc2
-rw-r--r--src/mds/CInode.cc2
-rw-r--r--src/mds/CInode.h2
-rw-r--r--src/mds/InoTable.cc2
-rw-r--r--src/mds/Locker.cc2
-rw-r--r--src/mds/MDBalancer.cc2
-rw-r--r--src/mds/MDCache.cc2
-rw-r--r--src/mds/MDLog.cc2
-rw-r--r--src/mds/MDS.cc3
-rw-r--r--src/mds/MDSTable.cc2
-rw-r--r--src/mds/MDSTableClient.cc2
-rw-r--r--src/mds/MDSTableServer.cc2
-rw-r--r--src/mds/Migrator.cc2
-rw-r--r--src/mds/Server.cc2
-rw-r--r--src/mds/SessionMap.cc2
-rw-r--r--src/mds/SnapServer.cc2
-rw-r--r--src/mds/flock.cc2
-rw-r--r--src/mds/journal.cc2
-rw-r--r--src/mds/snap.cc2
-rw-r--r--src/mon/AuthMonitor.cc2
-rw-r--r--src/mon/Elector.cc2
-rw-r--r--src/mon/LogMonitor.cc2
-rw-r--r--src/mon/MDSMonitor.cc2
-rw-r--r--src/mon/MonCaps.cc2
-rw-r--r--src/mon/MonClient.cc2
-rw-r--r--src/mon/Monitor.cc3
-rw-r--r--src/mon/MonitorStore.cc2
-rw-r--r--src/mon/MonmapMonitor.cc2
-rw-r--r--src/mon/OSDMonitor.cc2
-rw-r--r--src/mon/PGMap.cc2
-rw-r--r--src/mon/PGMonitor.cc2
-rw-r--r--src/mon/Paxos.cc2
-rw-r--r--src/mon/PaxosService.cc2
-rw-r--r--src/msg/Message.cc7
-rw-r--r--src/msg/SimpleMessenger.cc2
-rw-r--r--src/msg/SimpleMessenger.h6
-rw-r--r--src/objclass/class_debug.cc2
-rw-r--r--src/os/DBObjectMap.cc2
-rw-r--r--src/os/FileJournal.cc2
-rw-r--r--src/os/FileStore.cc2
-rw-r--r--src/os/HashIndex.cc2
-rw-r--r--src/os/JournalingObjectStore.cc2
-rw-r--r--src/os/LFNIndex.cc2
-rw-r--r--src/osd/ClassHandler.cc2
-rw-r--r--src/osd/OSD.cc3
-rw-r--r--src/osd/OSDMap.cc2
-rw-r--r--src/osd/PG.cc2
-rw-r--r--src/osd/ReplicatedPG.cc2
-rw-r--r--src/osdc/Filer.cc2
-rw-r--r--src/osdc/Journaler.cc2
-rw-r--r--src/osdc/ObjectCacher.cc2
-rw-r--r--src/osdc/Objecter.cc2
-rw-r--r--src/rgw/librgw.cc2
-rw-r--r--src/rgw/rgw_acl.cc2
-rw-r--r--src/rgw/rgw_acl_s3.cc2
-rw-r--r--src/rgw/rgw_acl_swift.cc2
-rw-r--r--src/rgw/rgw_aclparser.cc2
-rw-r--r--src/rgw/rgw_admin.cc2
-rw-r--r--src/rgw/rgw_cache.cc2
-rw-r--r--src/rgw/rgw_cache.h16
-rw-r--r--src/rgw/rgw_common.cc2
-rw-r--r--src/rgw/rgw_env.cc2
-rw-r--r--src/rgw/rgw_formats.cc2
-rw-r--r--src/rgw/rgw_log.cc2
-rw-r--r--src/rgw/rgw_main.cc7
-rw-r--r--src/rgw/rgw_multi.cc2
-rw-r--r--src/rgw/rgw_multiparser.cc2
-rw-r--r--src/rgw/rgw_op.cc2
-rw-r--r--src/rgw/rgw_rados.cc4
-rw-r--r--src/rgw/rgw_rest.cc3
-rw-r--r--src/rgw/rgw_rest_s3.cc2
-rw-r--r--src/rgw/rgw_rest_swift.cc2
-rw-r--r--src/rgw/rgw_swift.cc2
-rw-r--r--src/rgw/rgw_swift_auth.cc2
-rw-r--r--src/rgw/rgw_tools.cc2
-rw-r--r--src/rgw/rgw_user.cc2
-rw-r--r--src/rgw/rgw_xml.cc2
-rw-r--r--src/test/TestDoutStreambuf.cc91
-rw-r--r--src/test/TestSignalHandlers.cc5
-rw-r--r--src/test/daemon_config.cc59
-rw-r--r--src/test_trans.cc1
-rw-r--r--src/testcrypto.cc1
-rw-r--r--src/testkeys.cc2
-rw-r--r--src/testmsgr.cc1
-rw-r--r--src/tools/common.cc2
-rwxr-xr-xsrc/vstart.sh5
152 files changed, 1177 insertions, 1303 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 38b8684329c..83c31f5242b 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -53,7 +53,6 @@
/xattr_bench
dev
mondata
-log
mnt
TAGS
tags
diff --git a/src/Makefile.am b/src/Makefile.am
index 4440d046fde..622c7c1a7a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -265,10 +265,6 @@ testtimers_SOURCES = test/TestTimers.cc
testtimers_LDADD = $(LIBGLOBAL_LDA)
bin_DEBUGPROGRAMS += testtimers
-testdout_streambuf_SOURCES = test/TestDoutStreambuf.cc
-testdout_streambuf_LDADD = $(LIBGLOBAL_LDA)
-bin_DEBUGPROGRAMS += testdout_streambuf
-
testsignal_handlers_SOURCES = test/TestSignalHandlers.cc
testsignal_handlers_LDADD = $(LIBGLOBAL_LDA)
bin_DEBUGPROGRAMS += testsignal_handlers
@@ -498,6 +494,11 @@ unittest_str_list_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
unittest_str_list_LDADD = libglobal.la $(PTHREAD_LIBS) -lm ${UNITTEST_LDADD} $(CRYPTO_LIBS) $(EXTRALIBS)
check_PROGRAMS += unittest_str_list
+unittest_log_SOURCES = log/test.cc
+unittest_log_LDFLAGS = $(PTHREAD_CFLAGS) ${AM_LDFLAGS}
+unittest_log_LDADD = libcommon.la ${UNITTEST_LDADD}
+unittest_log_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+check_PROGRAMS += unittest_log
unittest_base64_SOURCES = test/base64.cc
unittest_base64_LDFLAGS = $(PTHREAD_CFLAGS) ${AM_LDFLAGS}
@@ -944,6 +945,7 @@ libcommon_files = \
json_spirit/json_spirit_reader.cpp \
json_spirit/json_spirit_writer.cpp \
json_spirit/json_spirit_value.cpp \
+ log/Log.cc \
mon/MonCaps.cc \
mon/MonClient.cc \
mon/MonMap.cc \
@@ -962,6 +964,7 @@ libcommon_files = \
common/ceph_context.cc \
common/buffer.cc \
common/code_environment.cc \
+ common/dout.cc \
common/signal.cc \
common/simple_spin.cc \
common/Thread.cc \
@@ -977,7 +980,6 @@ libcommon_files = \
common/strtol.cc \
common/page.cc \
common/lockdep.cc \
- common/DoutStreambuf.cc \
common/version.cc \
common/hex.cc \
common/entity_name.cc \
@@ -1138,7 +1140,6 @@ noinst_HEADERS = \
cls_acl.cc\
cls_crypto.cc\
common/BackTrace.h\
- common/DoutStreambuf.h\
common/HeartbeatMap.h\
common/LogClient.h\
common/LogEntry.h\
@@ -1279,6 +1280,10 @@ noinst_HEADERS = \
json_spirit/json_spirit_writer.h\
json_spirit/json_spirit_writer_options.h\
json_spirit/json_spirit_writer_template.h\
+ log/Entry.h\
+ log/EntryQueue.h\
+ log/Log.h\
+ log/SubsystemMap.h\
mds/inode_backtrace.h\
mds/flock.h\
mds/locks.c\
diff --git a/src/auth/AuthServiceHandler.cc b/src/auth/AuthServiceHandler.cc
index 3eccd5d652a..02dc11e9172 100644
--- a/src/auth/AuthServiceHandler.cc
+++ b/src/auth/AuthServiceHandler.cc
@@ -18,7 +18,7 @@
#include "AuthSupported.h"
#include "common/config.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
AuthServiceHandler *get_auth_service_handler(int type, CephContext *cct, KeyServer *ks)
diff --git a/src/auth/AuthSupported.cc b/src/auth/AuthSupported.cc
index e25817794a5..f211e3339eb 100644
--- a/src/auth/AuthSupported.cc
+++ b/src/auth/AuthSupported.cc
@@ -17,10 +17,11 @@
#include "common/debug.h"
#include "include/str_list.h"
-#define DOUT_SUBSYS auth
-
#include "AuthSupported.h"
+const static int dout_subsys = ceph_subsys_auth;
+
+
AuthSupported::AuthSupported(CephContext *cct)
{
string str = cct->_conf->auth_supported;
diff --git a/src/auth/KeyRing.cc b/src/auth/KeyRing.cc
index 45b07e73e51..84720d1d8cf 100644
--- a/src/auth/KeyRing.cc
+++ b/src/auth/KeyRing.cc
@@ -26,7 +26,8 @@
#include "common/errno.h"
#include "include/str_list.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
+
#undef dout_prefix
#define dout_prefix *_dout << "auth: "
diff --git a/src/auth/RotatingKeyRing.cc b/src/auth/RotatingKeyRing.cc
index 9ded2901c9d..9470801ff7d 100644
--- a/src/auth/RotatingKeyRing.cc
+++ b/src/auth/RotatingKeyRing.cc
@@ -9,7 +9,7 @@
#include "auth/RotatingKeyRing.h"
#include "auth/KeyRing.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
#undef dout_prefix
#define dout_prefix *_dout << "auth: "
@@ -19,6 +19,7 @@ bool RotatingKeyRing::need_new_secrets() const
Mutex::Locker l(lock);
return secrets.need_new_secrets();
}
+
bool RotatingKeyRing::need_new_secrets(utime_t now) const
{
Mutex::Locker l(lock);
diff --git a/src/auth/cephx/CephxAuthorizeHandler.cc b/src/auth/cephx/CephxAuthorizeHandler.cc
index f33399484be..4c729d74099 100644
--- a/src/auth/cephx/CephxAuthorizeHandler.cc
+++ b/src/auth/cephx/CephxAuthorizeHandler.cc
@@ -4,6 +4,8 @@
#include "CephxProtocol.h"
#include "CephxAuthorizeHandler.h"
+#define dout_subsys ceph_subsys_auth
+
bool CephxAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys,
bufferlist& authorizer_data, bufferlist& authorizer_reply,
diff --git a/src/auth/cephx/CephxClientHandler.cc b/src/auth/cephx/CephxClientHandler.cc
index d608ad2b6a0..c8898bd2639 100644
--- a/src/auth/cephx/CephxClientHandler.cc
+++ b/src/auth/cephx/CephxClientHandler.cc
@@ -22,7 +22,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
#undef dout_prefix
#define dout_prefix *_dout << "cephx client: "
diff --git a/src/auth/cephx/CephxKeyServer.cc b/src/auth/cephx/CephxKeyServer.cc
index e2e02a66ffc..044aaa2d8d4 100644
--- a/src/auth/cephx/CephxKeyServer.cc
+++ b/src/auth/cephx/CephxKeyServer.cc
@@ -19,7 +19,7 @@
#include <sstream>
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
#undef dout_prefix
#define dout_prefix *_dout << "cephx keyserverdata: "
diff --git a/src/auth/cephx/CephxProtocol.cc b/src/auth/cephx/CephxProtocol.cc
index 973c5940ed0..c023c7ae3bc 100644
--- a/src/auth/cephx/CephxProtocol.cc
+++ b/src/auth/cephx/CephxProtocol.cc
@@ -18,7 +18,7 @@
#include "common/debug.h"
#include "include/buffer.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
#undef dout_prefix
#define dout_prefix *_dout << "cephx: "
diff --git a/src/auth/cephx/CephxServiceHandler.cc b/src/auth/cephx/CephxServiceHandler.cc
index 23b29c3a9a8..c52761d46c8 100644
--- a/src/auth/cephx/CephxServiceHandler.cc
+++ b/src/auth/cephx/CephxServiceHandler.cc
@@ -25,7 +25,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS auth
+#define dout_subsys ceph_subsys_auth
#undef dout_prefix
#define dout_prefix *_dout << "cephx server " << entity_name << ": "
diff --git a/src/auth/none/AuthNoneAuthorizeHandler.cc b/src/auth/none/AuthNoneAuthorizeHandler.cc
index 37bacffa7ef..517a3d608d2 100644
--- a/src/auth/none/AuthNoneAuthorizeHandler.cc
+++ b/src/auth/none/AuthNoneAuthorizeHandler.cc
@@ -15,6 +15,8 @@
#include "AuthNoneAuthorizeHandler.h"
#include "common/debug.h"
+#define dout_subsys ceph_subsys_auth
+
bool AuthNoneAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys,
bufferlist& authorizer_data, bufferlist& authorizer_reply,
EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info,
diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc
index 807d4839b1a..f3f03f5ecaa 100644
--- a/src/ceph_fuse.cc
+++ b/src/ceph_fuse.cc
@@ -108,6 +108,8 @@ int main(int argc, const char **argv, const char *envp[]) {
exit(1);
}
+ g_ceph_context->_log->stop();
+
childpid = fork();
}
@@ -117,6 +119,8 @@ int main(int argc, const char **argv, const char *envp[]) {
//cout << "child, mounting" << std::endl;
::close(fd[0]);
+ g_ceph_context->_log->start();
+
cout << "ceph-fuse[" << getpid() << "]: starting ceph client" << std::endl;
messenger->start();
diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc
index acbfa634e45..35574d8f561 100644
--- a/src/ceph_mds.cc
+++ b/src/ceph_mds.cc
@@ -45,6 +45,8 @@ using namespace std;
#include "auth/KeyRing.h"
+#define dout_subsys ceph_subsys_mds
+
void usage()
{
derr << "usage: ceph-mds -i name [flags] [[--journal_check rank]|[--hot-standby][rank]]\n"
diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
index 7a35886eb94..cd6557cd079 100644
--- a/src/ceph_mon.cc
+++ b/src/ceph_mon.cc
@@ -41,6 +41,8 @@ using namespace std;
#include "global/global_init.h"
#include "global/signal_handler.h"
+#define dout_subsys ceph_subsys_mon
+
extern CompatSet get_ceph_mon_feature_compat_set();
Monitor *mon = NULL;
diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc
index 340fecefd90..2cc520f24cd 100644
--- a/src/ceph_osd.cc
+++ b/src/ceph_osd.cc
@@ -45,6 +45,8 @@ using namespace std;
#include "perfglue/heap_profiler.h"
+#define dout_subsys ceph_subsys_osd
+
OSD *osd = NULL;
void handle_osd_signal(int signum)
diff --git a/src/client/Client.cc b/src/client/Client.cc
index 4a9ae3cb267..517a384300a 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -67,7 +67,7 @@ using namespace std;
#include "common/config.h"
-#define DOUT_SUBSYS client
+#define dout_subsys ceph_subsys_client
#include "include/lru.h"
diff --git a/src/client/Inode.cc b/src/client/Inode.cc
index 088b35d6aab..8e66165317b 100644
--- a/src/client/Inode.cc
+++ b/src/client/Inode.cc
@@ -253,7 +253,7 @@ Dir *Inode::open_dir()
{
if (!dir) {
dir = new Dir(this);
- ldout(cct, 15) << "open_dir " << dir << " on " << this << dendl;
+ lsubdout(cct, mds, 15) << "open_dir " << dir << " on " << this << dendl;
assert(dn_set.size() < 2); // dirs can't be hard-linked
if (!dn_set.empty())
(*dn_set.begin())->get(); // pin dentry
diff --git a/src/client/Inode.h b/src/client/Inode.h
index 5dde9f4882c..f7c26d91e22 100644
--- a/src/client/Inode.h
+++ b/src/client/Inode.h
@@ -163,12 +163,12 @@ class Inode {
void get() {
_ref++;
- ldout(cct, 15) << "inode.get on " << this << " " << ino << '.' << snapid
+ lsubdout(cct, mds, 15) << "inode.get on " << this << " " << ino << '.' << snapid
<< " now " << _ref << dendl;
}
int put(int n=1) {
_ref -= n;
- ldout(cct, 15) << "inode.put on " << this << " " << ino << '.' << snapid
+ lsubdout(cct, mds, 15) << "inode.put on " << this << " " << ino << '.' << snapid
<< " now " << _ref << dendl;
assert(_ref >= 0);
return _ref;
diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc
index 97237a7f172..e73899df97c 100644
--- a/src/client/SyntheticClient.cc
+++ b/src/client/SyntheticClient.cc
@@ -36,7 +36,7 @@ using namespace std;
#include "common/config.h"
-#define DOUT_SUBSYS client
+#define dout_subsys ceph_subsys_client
#undef dout_prefix
#define dout_prefix *_dout << "client." << (whoami >= 0 ? whoami:client->get_nodeid()) << " "
diff --git a/src/common/DecayCounter.h b/src/common/DecayCounter.h
index 90afb61bc2d..fa6f85f49b0 100644
--- a/src/common/DecayCounter.h
+++ b/src/common/DecayCounter.h
@@ -37,7 +37,7 @@ public:
DecayRate() : k(0) {}
DecayRate(double hl) { set_halflife(hl); }
void set_halflife(double hl) {
- k = log(.5) / hl;
+ k = ::log(.5) / hl;
}
};
diff --git a/src/common/DoutStreambuf.cc b/src/common/DoutStreambuf.cc
deleted file mode 100644
index e3416ca3916..00000000000
--- a/src/common/DoutStreambuf.cc
+++ /dev/null
@@ -1,644 +0,0 @@
-// -*- 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) 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.
- *
- */
-
-#include "common/DoutStreambuf.h"
-#include "common/Mutex.h"
-#include "common/code_environment.h"
-#include "common/config.h"
-#include "common/entity_name.h"
-#include "common/errno.h"
-#include "common/safe_io.h"
-#include "common/simple_spin.h"
-#include "common/debug.h"
-#include "include/utime.h"
-
-#if defined(__FreeBSD__)
-#include <sys/param.h>
-#else
-#include <values.h>
-#endif
-#include <errno.h>
-#include <fstream>
-#include <iostream>
-#include <memory>
-#include <time.h>
-#include <sstream>
-#include <streambuf>
-#include <string.h>
-#include <syslog.h>
-
-#include "include/assert.h"
-#include "include/compat.h"
-
-///////////////////////////// Constants /////////////////////////////
-#define TIME_FMT "%04d-%02d-%02d %02d:%02d:%02d.%06ld"
-#define TIME_FMT_SZ 26
-
-///////////////////////////// Globals /////////////////////////////
-extern DoutStreambuf <char> *_doss;
-
-// TODO: get rid of this lock using thread-local storage
-extern pthread_mutex_t _dout_lock;
-
-static simple_spinlock_t dout_emergency_lock = SIMPLE_SPINLOCK_INITIALIZER;
-
-/* Streams that we will write to in dout_emergency.
- * Protected by dout_emergency_lock. */
-EmergencyLogger *dout_emerg_streams[] =
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-
-#define NUM_DOUT_EMERG_STREAMS \
- (sizeof(dout_emerg_streams)/sizeof(dout_emerg_streams[0]))
-
-EmergencyLogger::~EmergencyLogger()
-{
-}
-
-//////////////////////// Helper functions //////////////////////////
-// Try a 0-byte write to a file descriptor to see if it open.
-static bool fd_is_open(int fd)
-{
- char buf;
- ssize_t res = TEMP_FAILURE_RETRY(write(fd, &buf, 0));
- return (res == 0);
-}
-
-static std::string normalize_relative(const char *from)
-{
- if (from[0] == '/')
- return string(from);
-
- char c[512];
- char *cwd = getcwd(c, sizeof(c));
- ostringstream oss;
- oss << cwd << "/" << from;
- return oss.str();
-}
-
-static inline bool prio_is_visible_on_stderr(signed int prio)
-{
- return prio == -1;
-}
-
-static inline int dout_prio_to_syslog_prio(int prio)
-{
- if (prio <= 3)
- return LOG_CRIT;
- if (prio <= 5)
- return LOG_ERR;
- if (prio <= 15)
- return LOG_WARNING;
- if (prio <= 30)
- return LOG_NOTICE;
- if (prio <= 40)
- return LOG_INFO;
- return LOG_DEBUG;
-}
-
-static std::string get_basename(const std::string &filename)
-{
- size_t last_slash = filename.find_last_of("/");
- if (last_slash == std::string::npos)
- return filename;
- return filename.substr(last_slash + 1);
-}
-
-static std::string get_dirname(const std::string &filename)
-{
- size_t last_slash = filename.find_last_of("/");
- if (last_slash == std::string::npos)
- return ".";
- if (last_slash == 0)
- return filename;
- return filename.substr(0, last_slash);
-}
-
-static int create_symlink(string oldpath, const string &newpath)
-{
- // Create relative symlink if the files are in the same directory
- if (get_dirname(oldpath) == get_dirname(newpath)) {
- oldpath = string("./") + get_basename(oldpath);
- }
-
- while (1) {
- if (::symlink(oldpath.c_str(), newpath.c_str()) == 0)
- return 0;
- int err = errno;
- if (err == EEXIST) {
- // Handle EEXIST
- if (::unlink(newpath.c_str())) {
- err = errno;
- ostringstream oss;
- oss << __func__ << ": failed to remove '" << newpath << "': "
- << cpp_strerror(err) << "\n";
- dout_emergency(oss.str());
- return err;
- }
- }
- else {
- // Other errors
- ostringstream oss;
- oss << __func__ << ": failed to symlink(oldpath='" << oldpath
- << "', newpath='" << newpath << "'): " << cpp_strerror(err) << "\n";
- dout_emergency(oss.str());
- return err;
- }
- }
-}
-
-///////////////////////////// DoutStreambuf /////////////////////////////
-template <typename charT, typename traits>
-DoutStreambuf<charT, traits>::DoutStreambuf()
- : flags(0), ofd(-1)
-{
- // Initialize get pointer to zero so that underflow is called on the first read.
- this->setg(0, 0, 0);
-
- // Initialize output_buffer
- _clear_output_buffer();
-
- int ret;
- pthread_mutexattr_t attr;
- ret = pthread_mutexattr_init(&attr);
- assert(ret == 0);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- ret = pthread_mutex_init(&lock, &attr);
- assert(ret == 0);
- ret = pthread_mutexattr_destroy(&attr);
- assert(ret == 0);
-
- simple_spin_lock(&dout_emergency_lock);
- for (size_t i = 0; i < NUM_DOUT_EMERG_STREAMS; ++i) {
- if (dout_emerg_streams[i] == 0) {
- dout_emerg_streams[i] = this;
- break;
- }
- }
- simple_spin_unlock(&dout_emergency_lock);
-}
-
-template <typename charT, typename traits>
-DoutStreambuf<charT, traits>::~DoutStreambuf()
-{
- simple_spin_lock(&dout_emergency_lock);
- for (size_t i = 0; i < NUM_DOUT_EMERG_STREAMS; ++i) {
- if (dout_emerg_streams[i] == this) {
- dout_emerg_streams[i] = 0;
- break;
- }
- }
- simple_spin_unlock(&dout_emergency_lock);
- if (ofd != -1) {
- TEMP_FAILURE_RETRY(::close(ofd));
- ofd = -1;
- }
- pthread_mutex_destroy(&lock);
-}
-
-// This function is called when the output buffer is filled.
-// In this function, the buffer should be written to wherever it should
-// be written to (in this case, the streambuf object that this is controlling).
-template <typename charT, typename traits>
-typename DoutStreambuf<charT, traits>::int_type
-DoutStreambuf<charT, traits>::overflow(DoutStreambuf<charT, traits>::int_type c)
-{
- {
- // zero-terminate the buffer
- charT* end_ptr = this->pptr();
- *end_ptr++ = '\0';
- *end_ptr++ = '\0';
-// char buf[1000];
-// hex2str(obuf, end_ptr - obuf, buf, sizeof(buf));
-// printf("overflow buffer: '%s'\n", buf);
- }
-
- // Get priority of message
- signed int prio = obuf[TIME_FMT_SZ] - 12;
-
- // Prepend date to buffer
- struct timeval tv;
- gettimeofday(&tv, NULL);
- struct tm tm;
- localtime_r(&tv.tv_sec, &tm);
- snprintf(obuf, TIME_FMT_SZ + 1, TIME_FMT,
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec,
- tv.tv_usec);
-
- // This byte was NULLed by snprintf, but we'd rather have a space there.
- obuf[TIME_FMT_SZ] = ' ';
-
- // Now 'obuf' points to a NULL-terminated string, which we want to
- // output with priority 'prio'
- int len = strlen(obuf);
- if (flags & DOUTSB_FLAG_SYSLOG) {
- syslog(LOG_USER | dout_prio_to_syslog_prio(prio), "%s",
- obuf + TIME_FMT_SZ + 1);
- }
- if ((prio == -1 && (flags & DOUTSB_FLAG_STDERR_ERR)) ||
- (prio != -1 && (flags & DOUTSB_FLAG_STDERR_LOG))) {
- // Just write directly out to the stderr fileno. There's no point in
- // using something like fputs to write to a temporary buffer,
- // because we would just have to flush that temporary buffer
- // immediately.
- if (safe_write(STDERR_FILENO, obuf, len))
- flags &= ~DOUTSB_FLAG_STDERR;
- }
- if (flags & DOUTSB_FLAG_OFILE) {
- if (safe_write(ofd, obuf, len))
- flags &= ~DOUTSB_FLAG_OFILE;
- }
-
- _clear_output_buffer();
-
- // A value different than EOF (or traits::eof() for other traits) signals success.
- // If the function fails, either EOF (or traits::eof() for other traits) is returned or an
- // exception is thrown.
- return traits_ty::not_eof(c);
-}
-
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::handle_stderr_shutdown()
-{
- DoutLocker _dout_locker(&lock);
- flags &= ~DOUTSB_FLAG_STDERR;
-}
-
-template <typename charT, typename traits>
-const char** DoutStreambuf<charT, traits>::
-get_tracked_conf_keys() const
-{
- static const char *KEYS[] =
- { "log_file", "log_sym_dir",
- "log_sym_history", "log_to_stderr", "err_to_stderr",
- "log_to_syslog", "log_per_instance", NULL };
- return KEYS;
-}
-
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::
-handle_conf_change(const md_config_t *conf, const std::set <std::string> &changed)
-{
- DoutLocker _dout_locker(&lock);
- type_name = conf->name.get_type_name();
-
- flags = 0;
-
- if (ofd != -1) {
- TEMP_FAILURE_RETRY(::close(ofd));
- ofd = -1;
- }
-
- if (conf->log_to_syslog) {
- if ((changed.count("log_to_syslog") || changed.count("name")) &&
- (g_code_env == CODE_ENVIRONMENT_DAEMON)) {
- closelog();
- openlog(conf->name.to_cstr(), LOG_ODELAY | LOG_PID, LOG_USER);
- }
- flags |= DOUTSB_FLAG_SYSLOG;
- }
-
- if (fd_is_open(STDERR_FILENO)) {
- if (conf->log_to_stderr)
- flags |= DOUTSB_FLAG_STDERR_LOG;
- else
- flags &= ~DOUTSB_FLAG_STDERR_LOG;
-
- if (conf->err_to_stderr)
- flags |= DOUTSB_FLAG_STDERR_ERR;
- else
- flags &= ~DOUTSB_FLAG_STDERR_ERR;
- }
-
- if (_read_ofile_config(conf) == 0) {
- flags |= DOUTSB_FLAG_OFILE;
- }
-}
-
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::
-set_prio(int prio)
-{
- charT* p = this->pptr();
- *p++ = '\1';
- unsigned char val = (prio + 11);
- *p++ = val;
- this->pbump(2);
-}
-
-template <typename charT, typename traits>
-int DoutStreambuf<charT, traits>::
-handle_pid_change(const md_config_t *conf)
-{
- DoutLocker _dout_locker(&lock);
- if (!(flags & DOUTSB_FLAG_OFILE))
- return 0;
-
- string new_opath(_calculate_opath(conf));
- if (opath == new_opath)
- return 0;
-
- if (!isym_path.empty()) {
- // Re-create the instance symlink
- int ret = create_symlink(new_opath, isym_path);
- if (ret) {
- ostringstream oss;
- oss << __func__ << ": failed to (re)create instance symlink\n";
- dout_emergency(oss.str());
- return ret;
- }
- }
-
- int ret = ::rename(opath.c_str(), new_opath.c_str());
- if (ret) {
- int err = errno;
- ostringstream oss;
- oss << __func__ << ": failed to rename '" << opath << "' to "
- << "'" << new_opath << "': " << cpp_strerror(err) << "\n";
- dout_emergency(oss.str());
- return err;
- }
-
- opath = new_opath;
-
- return 0;
-}
-
-template <typename charT, typename traits>
-std::string DoutStreambuf<charT, traits>::config_to_str() const
-{
- // should hold the dout_lock here
- ostringstream oss;
- oss << "flags = 0x" << std::hex << flags << std::dec << "\n";
- oss << "ofd = " << ofd << "\n";
- oss << "opath = '" << opath << "'\n";
- oss << "isym_path = '" << isym_path << "'\n";
- return oss.str();
-}
-
-/* This function doesn't take the dout lock, so some interleaving or weirdness
- * may happen if concurrent writes are going on. But this is for emergencies,
- * so we don't care.
- */
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::
-emergency_log_to_file_and_syslog(const char * const str) const
-{
- int len = strlen(str);
- if (ofd >= 0) {
- if (safe_write(ofd, str, len)) {
- ; // ignore error code
- }
- }
- if (flags & DOUTSB_FLAG_SYSLOG) {
- syslog(LOG_USER | LOG_CRIT, "%s", str);
- }
-}
-
-// This is called to flush the buffer.
-// This is called when we're done with the file stream (or when .flush() is called).
-template <typename charT, typename traits>
-typename DoutStreambuf<charT, traits>::int_type
-DoutStreambuf<charT, traits>::sync()
-{
- typename DoutStreambuf<charT, traits>::int_type
- ret(this->overflow(traits_ty::eof()));
- if (ret == traits_ty::eof())
- return -1;
-
- return 0;
-}
-
-template <typename charT, typename traits>
-typename DoutStreambuf<charT, traits>::int_type
-DoutStreambuf<charT, traits>::underflow()
-{
- // We can't read from this
- // TODO: some more elegant way of preventing callers from trying to get input from this stream
- assert(0);
-}
-
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::
-reopen_logs(const md_config_t *conf)
-{
- std::set <std::string> changed;
- const char **keys = get_tracked_conf_keys();
- for (const char **k = keys; *k; ++k) {
- changed.insert(*k);
- }
- handle_conf_change(conf, changed);
-}
-
-template <typename charT, typename traits>
-void DoutStreambuf<charT, traits>::_clear_output_buffer()
-{
- // Set up the put pointer.
- // Overflow is called when this buffer is filled
- this->setp(obuf + TIME_FMT_SZ, obuf + OBUF_SZ - TIME_FMT_SZ - 5);
-}
-
-template <typename charT, typename traits>
-std::string DoutStreambuf<charT, traits>::
-_calculate_opath(const md_config_t *conf) const
-{
- // should hold the dout_lock here
- if (conf->log_file.empty()) {
- // We don't want a log file.
- return "";
- }
-
- string log_file(normalize_relative(conf->log_file.c_str()));
- if ((conf->log_per_instance) && (g_code_env == CODE_ENVIRONMENT_DAEMON)) {
- ostringstream oss;
- oss << log_file << "." << getpid();
- return oss.str();
- }
- else {
- return log_file;
- }
-}
-
-template <typename charT, typename traits>
-std::string DoutStreambuf<charT, traits>::
-_get_symlink_dir(const md_config_t *conf) const
-{
- if (!conf->log_sym_dir.empty())
- return normalize_relative(conf->log_sym_dir.c_str());
- else
- return get_dirname(opath);
-}
-
-template <typename charT, typename traits>
-int DoutStreambuf<charT, traits>::
-_read_ofile_config(const md_config_t *conf)
-{
- int ret;
-
- opath.clear();
- symlink_dir.clear();
- isym_path.clear();
-
- opath = _calculate_opath(conf);
- if (opath.empty()) {
- return 1;
- }
-
- symlink_dir = _get_symlink_dir(conf);
-
- if ((conf->log_per_instance) && (g_code_env == CODE_ENVIRONMENT_DAEMON)) {
- // Calculate instance symlink path (isym_path)
- ostringstream iss;
- iss << symlink_dir << "/" << conf->name.to_str();
- isym_path = iss.str();
-
- // Rotate isym_path
- ret = _rotate_files(conf, isym_path);
- if (ret) {
- ostringstream oss;
- oss << __func__ << ": failed to rotate instance symlinks\n";
- dout_emergency(oss.str());
- return ret;
- }
-
- // Create isym_path
- ret = create_symlink(opath, isym_path);
- if (ret) {
- ostringstream oss;
- oss << __func__ << ": failed to create instance symlink\n";
- dout_emergency(oss.str());
- return ret;
- }
- }
-
- assert(ofd == -1);
- ofd = open(opath.c_str(),
- O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR);
- if (ofd == -1) {
- int err = errno;
- ostringstream oss;
- oss << "failed to open log file '" << opath << "': "
- << cpp_strerror(err) << "\n";
- dout_emergency(oss.str());
- return err;
- }
-
- return 0;
-}
-
-template <typename charT, typename traits>
-int DoutStreambuf<charT, traits>::
-_rotate_files(const md_config_t *conf, const std::string &base)
-{
- // Given a file name base, and a directory like this:
- // base
- // base.1
- // base.2
- // base.3
- // base.4
- // unrelated_blah
- // unrelated_blah.1
- //
- // We'll take the following actions:
- // base rename to base.1
- // base.1 rename to base.2
- // base.2 rename to base.3
- // base.3 (unlink)
- // base.4 (unlink)
- // unrelated_blah (do nothing)
- // unrelated_blah.1 (do nothing)
-
- signed int i;
- for (i = -1; i < INT_MAX; ++i) {
- ostringstream oss;
- oss << base;
- if (i != -1)
- oss << "." << i;
- string path(oss.str());
-
- if (::access(path.c_str(), R_OK | W_OK))
- break;
- }
- signed int max_symlink = i - 1;
-
- for (signed int j = max_symlink; j >= -1; --j) {
- ostringstream oss;
- oss << base;
- if (j != -1)
- oss << "." << j;
- string path(oss.str());
-
- signed int k = j + 1;
- if (k >= conf->log_sym_history) {
- if (::unlink(path.c_str())) {
- int err = errno;
- ostringstream ess;
- ess << __func__ << ": failed to unlink '" << path << "': "
- << cpp_strerror(err) << "\n";
- dout_emergency(ess.str());
- return err;
- }
- //*_dout << "---- " << getpid() << " removed " << path << " ----"
- // << std::endl;
- }
- else {
- ostringstream pss;
- pss << base << "." << k;
- string new_path(pss.str());
- if (::rename(path.c_str(), new_path.c_str())) {
- int err = errno;
- ostringstream ess;
- ess << __func__ << ": failed to rename '" << path << "' to "
- << "'" << new_path << "': " << cpp_strerror(err) << "\n";
- dout_emergency(ess.str());
- return err;
- }
-// *_dout << "---- " << getpid() << " renamed " << path << " -> "
-// << newpath << " ----" << std::endl;
- }
- }
- return 0;
-}
-
-/* This function may be called from a signal handler.
- * This function may be called before dout has been initialized.
- */
-void dout_emergency(const char * const str)
-{
- // Write to stderr. It may or may not be open, but if it is, there's a good
- // chance the user will see this.
- int len = strlen(str);
- if (safe_write(STDERR_FILENO, str, len)) {
- // ignore errors
- ;
- }
-
- // Write to all the file descriptors we know about.
- // If we are logging to syslog, send logs to that too.
- simple_spin_lock(&dout_emergency_lock);
- for (size_t i = 0; i < NUM_DOUT_EMERG_STREAMS; ++i) {
- if (dout_emerg_streams[i]) {
- dout_emerg_streams[i]->emergency_log_to_file_and_syslog(str);
- }
- }
- simple_spin_unlock(&dout_emergency_lock);
-}
-
-void dout_emergency(const std::string &str)
-{
- dout_emergency(str.c_str());
-}
-
-// Explicit template instantiation
-template class DoutStreambuf <char>;
diff --git a/src/common/DoutStreambuf.h b/src/common/DoutStreambuf.h
deleted file mode 100644
index bda0a91fbbd..00000000000
--- a/src/common/DoutStreambuf.h
+++ /dev/null
@@ -1,135 +0,0 @@
-// -*- 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) 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.
- *
- */
-
-/*
- * DoutStreambuf
- *
- * The stream buffer used by dout
- */
-#ifndef CEPH_DOUT_STREAMBUF_H
-#define CEPH_DOUT_STREAMBUF_H
-
-#include "common/config_obs.h"
-
-#include <iosfwd>
-#include <pthread.h>
-#include <string>
-
-class md_config_t;
-class CephContext;
-
-class EmergencyLogger {
-public:
- virtual ~EmergencyLogger();
- virtual void emergency_log_to_file_and_syslog(const char *const str) const = 0;
-};
-
-template <typename charT, typename traits = std::char_traits<charT> >
-class DoutStreambuf : public std::basic_streambuf<charT, traits>,
- public md_config_obs_t,
- public EmergencyLogger
-{
-public:
- enum dout_streambuf_flags_t {
- DOUTSB_FLAG_SYSLOG = 0x01,
- DOUTSB_FLAG_STDERR_LOG = 0x04,
- DOUTSB_FLAG_STDERR_ERR = 0x08,
- DOUTSB_FLAG_STDERR = 0x0c,
- DOUTSB_FLAG_OFILE = 0x10,
- };
-
- typedef traits traits_ty;
- typedef typename traits_ty::int_type int_type;
- typedef typename traits_ty::pos_type pos_type;
- typedef typename traits_ty::off_type off_type;
-
- // The size of the output buffer.
- static const size_t OBUF_SZ = 32000;
-
- DoutStreambuf();
- ~DoutStreambuf();
-
- // Call when you close stderr. Not strictly necessary, since we would get an
- // error the next time we tried to write to stdedrr. But nicer than waiting
- // for the error to happen.
- void handle_stderr_shutdown();
-
- virtual const char** get_tracked_conf_keys() const;
-
- virtual void handle_conf_change(const md_config_t *conf,
- const std::set <std::string> &changed);
-
- // Set the priority of the messages being put into the stream
- void set_prio(int prio);
-
- // Call after calling daemon()
- // A change in the process ID sometimes requires us to change our output
- // path name.
- int handle_pid_change(const md_config_t *conf);
-
- std::string config_to_str() const;
-
- // Output a string directly to the file and to syslog
- // (if those sinks are active)
- void emergency_log_to_file_and_syslog(const char * const str) const;
-
- // Reopen the logs
- void reopen_logs(const md_config_t *conf);
-
-protected:
- // Called when the buffer fills up
- virtual int_type overflow(int_type c);
-
- // Called when the buffer is flushed
- virtual int_type sync();
-
- // Called when we try to read, but there are no more chars in the buffer
- virtual int_type underflow();
-
-private:
- friend void dout_emergency(const char * const str);
- friend void dout_emergency(const std::string &str);
-
- void _clear_output_buffer();
- std::string _calculate_opath(const md_config_t *conf) const;
- std::string _get_symlink_dir(const md_config_t *conf) const;
- int _read_ofile_config(const md_config_t *conf);
- int _rotate_files(const md_config_t *conf, const std::string &base);
-
- std::string type_name;
-
- // Output buffer
- charT obuf[OBUF_SZ];
-
- // Output flags
- int flags;
-
- // ofile stuff
- int ofd;
- std::string opath;
- std::string symlink_dir;
- std::string isym_path;
-
- // Mutex that protects this output stream
- pthread_mutex_t lock;
-
- friend class CephContext;
-};
-
-// Secret evil interfaces for writing logs without taking the lock.
-// DO NOT USE THESE unless you have a really good reason.
-extern void dout_emergency(const char * const str);
-extern void dout_emergency(const std::string &str);
-
-#endif
diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc
index 7f21de6d23a..8876d16eea0 100644
--- a/src/common/Finisher.cc
+++ b/src/common/Finisher.cc
@@ -3,7 +3,7 @@
#include "Finisher.h"
#include "common/debug.h"
-#define DOUT_SUBSYS finisher
+#define dout_subsys ceph_subsys_finisher
#undef dout_prefix
#define dout_prefix *_dout << "finisher(" << this << ") "
diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc
index 0b914fc9138..48e6e021fc9 100644
--- a/src/common/HeartbeatMap.cc
+++ b/src/common/HeartbeatMap.cc
@@ -23,7 +23,7 @@
#include "common/errno.h"
#include "debug.h"
-#define DOUT_SUBSYS heartbeatmap
+#define dout_subsys ceph_subsys_heartbeatmap
#undef dout_prefix
#define dout_prefix *_dout << "heartbeat_map "
diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc
index 374cb8c6576..29a83637cb1 100644
--- a/src/common/LogClient.cc
+++ b/src/common/LogClient.cc
@@ -38,6 +38,8 @@
#include "common/config.h"
+#define dout_subsys ceph_subsys_monc
+
/*
* Given a clog log_type, return the equivalent syslog priority
*/
diff --git a/src/common/MemoryModel.cc b/src/common/MemoryModel.cc
index e23c6f3bdc4..b21ed6133bc 100644
--- a/src/common/MemoryModel.cc
+++ b/src/common/MemoryModel.cc
@@ -6,6 +6,8 @@
#include <fstream>
+#define dout_subsys ceph_subsys_
+
MemoryModel::MemoryModel(CephContext *cct_)
: cct(cct_)
{
diff --git a/src/common/Timer.cc b/src/common/Timer.cc
index 53e6d8dda3d..38688778368 100644
--- a/src/common/Timer.cc
+++ b/src/common/Timer.cc
@@ -20,7 +20,7 @@
#include "common/config.h"
#include "include/Context.h"
-#define DOUT_SUBSYS timer
+#define dout_subsys ceph_subsys_timer
#undef dout_prefix
#define dout_prefix *_dout << "timer(" << this << ")."
diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc
index 4d85525d82e..5d50cdfd5da 100644
--- a/src/common/WorkQueue.cc
+++ b/src/common/WorkQueue.cc
@@ -21,7 +21,7 @@
#include "common/config.h"
#include "common/HeartbeatMap.h"
-#define DOUT_SUBSYS tp
+#define dout_subsys ceph_subsys_tp
#undef dout_prefix
#define dout_prefix *_dout << name << " "
diff --git a/src/common/admin_socket.cc b/src/common/admin_socket.cc
index b8f2d5987ea..3d4e256bb2f 100644
--- a/src/common/admin_socket.cc
+++ b/src/common/admin_socket.cc
@@ -39,6 +39,8 @@
#include "include/compat.h"
+#define dout_subsys ceph_subsys_
+
using std::ostringstream;
/*
diff --git a/src/common/assert.cc b/src/common/assert.cc
index e1c1734c791..56eaa7b1f84 100644
--- a/src/common/assert.cc
+++ b/src/common/assert.cc
@@ -45,11 +45,6 @@ namespace ceph {
void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *func)
{
- DoutLocker dout_locker;
- if (g_assert_context) {
- g_assert_context->dout_trylock(&dout_locker);
- }
-
ostringstream tss;
tss << ceph_clock_now(g_assert_context);
@@ -78,11 +73,6 @@ namespace ceph {
void __ceph_assert_warn(const char *assertion, const char *file,
int line, const char *func)
{
- DoutLocker dout_locker;
- if (g_assert_context) {
- g_assert_context->dout_trylock(&dout_locker);
- }
-
char buf[8096];
snprintf(buf, sizeof(buf),
"WARNING: assert(%s) at: %s: %d: %s()\n",
diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc
index a96bb668942..4b3194a8f9f 100644
--- a/src/common/ceph_argparse.cc
+++ b/src/common/ceph_argparse.cc
@@ -184,7 +184,7 @@ bool ceph_argparse_flag(std::vector<const char*> &args,
static bool va_ceph_argparse_binary_flag(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, int *ret,
- std::ostringstream *oss, va_list ap)
+ std::ostream *oss, va_list ap)
{
const char *first = *i;
char tmp[strlen(first)+1];
@@ -231,7 +231,7 @@ static bool va_ceph_argparse_binary_flag(std::vector<const char*> &args,
bool ceph_argparse_binary_flag(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, int *ret,
- std::ostringstream *oss, ...)
+ std::ostream *oss, ...)
{
bool r;
va_list ap;
@@ -293,7 +293,7 @@ bool ceph_argparse_witharg(std::vector<const char*> &args,
bool ceph_argparse_withint(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, int *ret,
- std::ostringstream *oss, ...)
+ std::ostream *oss, ...)
{
bool r;
va_list ap;
@@ -316,7 +316,7 @@ bool ceph_argparse_withint(std::vector<const char*> &args,
bool ceph_argparse_withlonglong(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, long long *ret,
- std::ostringstream *oss, ...)
+ std::ostream *oss, ...)
{
bool r;
va_list ap;
diff --git a/src/common/ceph_argparse.h b/src/common/ceph_argparse.h
index bcad8e65b7a..0c9630d5bee 100644
--- a/src/common/ceph_argparse.h
+++ b/src/common/ceph_argparse.h
@@ -58,16 +58,16 @@ bool ceph_argparse_witharg(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, std::string *ret, ...);
bool ceph_argparse_binary_flag(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, int *ret,
- std::ostringstream *oss, ...);
+ std::ostream *oss, ...);
extern CephInitParameters ceph_argparse_early_args
(std::vector<const char*>& args, uint32_t module_type, int flags,
std::string *conf_file_list);
extern bool ceph_argparse_withint(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, int *ret,
- std::ostringstream *oss, ...);
+ std::ostream *oss, ...);
extern bool ceph_argparse_withlonglong(std::vector<const char*> &args,
std::vector<const char*>::iterator &i, long long *ret,
- std::ostringstream *oss, ...);
+ std::ostream *oss, ...);
extern void generic_server_usage();
extern void generic_client_usage();
diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc
index 02a16ead509..6ffa25429a4 100644
--- a/src/common/ceph_context.cc
+++ b/src/common/ceph_context.cc
@@ -15,13 +15,13 @@
#include <time.h>
#include "common/admin_socket.h"
-#include "common/DoutStreambuf.h"
#include "common/perf_counters.h"
#include "common/Thread.h"
#include "common/ceph_context.h"
#include "common/config.h"
#include "common/debug.h"
#include "common/HeartbeatMap.h"
+#include "log/Log.h"
#include <iostream>
#include <pthread.h>
@@ -58,7 +58,7 @@ public:
break;
}
if (_reopen_logs) {
- _cct->_doss->reopen_logs(_cct->_conf);
+ _cct->_log->reopen_log_file();
_reopen_logs = false;
}
_cct->_heartbeat_map->check_touch_file();
@@ -86,6 +86,53 @@ private:
};
+/**
+ * observe logging config changes
+ *
+ * The logging subsystem sits below most of the ceph code, including
+ * the config subsystem, to keep it simple and self-contained. Feed
+ * logging-related config changes to the log.
+ */
+class LogObs : public md_config_obs_t {
+ ceph::log::Log *log;
+
+public:
+ LogObs(ceph::log::Log *l) : log(l) {}
+
+ const char** get_tracked_conf_keys() const {
+ static const char *KEYS[] = {
+ "log_file",
+ "log_to_syslog",
+ "log_to_stderr",
+ "err_to_stderr",
+ NULL
+ };
+ return KEYS;
+ }
+
+ void handle_conf_change(const md_config_t *conf,
+ const std::set <std::string> &changed) {
+ // stderr
+ if (changed.count("log_to_stderr") || changed.count("err_to_stderr")) {
+ int l = conf->log_to_stderr ? 99 : (conf->err_to_stderr ? -1 : -2);
+ log->set_stderr_level(l, l);
+ }
+
+ // syslog
+ if (changed.count("log_to_syslog")) {
+ int l = conf->log_to_syslog ? 99 : -1;
+ log->set_syslog_level(l, l);
+ }
+
+ // file
+ if (changed.count("log_file")) {
+ log->set_log_file(conf->log_file);
+ log->reopen_log_file();
+ }
+ }
+};
+
+
// perfcounter hooks
class PerfCountersHook : public AdminSocketHook {
@@ -112,18 +159,24 @@ public:
CephContext::CephContext(uint32_t module_type_)
: _conf(new md_config_t()),
- _doss(new DoutStreambuf <char, std::basic_string<char>::traits_type>()),
- _dout(_doss),
+ _log(NULL),
_module_type(module_type_),
_service_thread(NULL),
+ _log_obs(NULL),
_admin_socket(NULL),
_perf_counters_collection(NULL),
_perf_counters_conf_obs(NULL),
_heartbeat_map(NULL)
{
pthread_spin_init(&_service_thread_lock, PTHREAD_PROCESS_SHARED);
+
+ _log = new ceph::log::Log(&_conf->subsys);
+ _log->start();
+
+ _log_obs = new LogObs(_log);
+ _conf->add_observer(_log_obs);
+
_perf_counters_collection = new PerfCountersCollection(this);
- _conf->add_observer(_doss);
_admin_socket = new AdminSocket(this);
_conf->add_observer(_admin_socket);
_heartbeat_map = new HeartbeatMap(this);
@@ -148,7 +201,6 @@ CephContext::~CephContext()
delete _heartbeat_map;
_conf->remove_observer(_admin_socket);
- _conf->remove_observer(_doss);
delete _perf_counters_collection;
_perf_counters_collection = NULL;
@@ -156,8 +208,13 @@ CephContext::~CephContext()
delete _perf_counters_conf_obs;
_perf_counters_conf_obs = NULL;
- delete _doss;
- _doss = NULL;
+ _conf->remove_observer(_log_obs);
+ delete _log_obs;
+ _log_obs = NULL;
+
+ _log->stop();
+ delete _log;
+ _log = NULL;
delete _conf;
pthread_spin_destroy(&_service_thread_lock);
@@ -184,28 +241,6 @@ void CephContext::reopen_logs()
pthread_spin_unlock(&_service_thread_lock);
}
-void CephContext::dout_lock(DoutLocker *locker)
-{
- pthread_mutex_t *lock = &_doss->lock;
- pthread_mutex_lock(lock);
- locker->lock = lock;
-}
-
-void CephContext::dout_trylock(DoutLocker *locker)
-{
- static const int MAX_DOUT_TRYLOCK_TRIES = 3;
-
- /* Try a few times to get the lock. If we can't seem to get it, just give up. */
- pthread_mutex_t *lock = &_doss->lock;
- for (int i = 0; i < MAX_DOUT_TRYLOCK_TRIES; ++i) {
- if (pthread_mutex_trylock(lock) == 0) {
- locker->lock = lock;
- return;
- }
- usleep(50000);
- }
-}
-
void CephContext::join_service_thread()
{
pthread_spin_lock(&_service_thread_lock);
diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h
index f14a9f452fa..38100ab7362 100644
--- a/src/common/ceph_context.h
+++ b/src/common/ceph_context.h
@@ -18,13 +18,8 @@
#include <iostream>
#include <stdint.h>
-/* Forward declarations */
-template <typename T, typename U>
-class DoutStreambuf;
-
class AdminSocket;
class CephContextServiceThread;
-class DoutLocker;
class PerfCountersCollection;
class md_config_obs_t;
class md_config_t;
@@ -32,6 +27,9 @@ class PerfCountersHook;
namespace ceph {
class HeartbeatMap;
+ namespace log {
+ class Log;
+ }
}
/* A CephContext represents the context held by a single library user.
@@ -46,8 +44,8 @@ public:
CephContext(uint32_t module_type_);
~CephContext();
md_config_t *_conf;
- DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
- std::ostream _dout;
+
+ ceph::log::Log *_log;
/* Start the Ceph Context's service thread */
void start_service_thread();
@@ -55,12 +53,6 @@ public:
/* Reopen the log files */
void reopen_logs();
- /* Lock the dout lock. */
- void dout_lock(DoutLocker *locker);
-
- /* Try to lock the dout lock. */
- void dout_trylock(DoutLocker *locker);
-
/* Get the module type (client, mon, osd, mds, etc.) */
uint32_t get_module_type() const;
@@ -95,6 +87,8 @@ private:
friend class CephContextServiceThread;
CephContextServiceThread *_service_thread;
+ md_config_obs_t *_log_obs;
+
/* The admin socket associated with this context */
AdminSocket *_admin_socket;
diff --git a/src/common/common_init.cc b/src/common/common_init.cc
index 58bbf6d40e8..3af8eb39c0f 100644
--- a/src/common/common_init.cc
+++ b/src/common/common_init.cc
@@ -12,7 +12,6 @@
*
*/
-#include "common/DoutStreambuf.h"
#include "common/ceph_argparse.h"
#include "common/ceph_context.h"
#include "common/ceph_crypto.h"
@@ -28,6 +27,8 @@
#include <errno.h>
#include <deque>
+#define dout_subsys ceph_subsys_
+
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
diff --git a/src/common/config.cc b/src/common/config.cc
index e15be3d462b..b18b00fa372 100644
--- a/src/common/config.cc
+++ b/src/common/config.cc
@@ -85,8 +85,13 @@ const void *config_option::conf_ptr(const md_config_t *conf) const
struct config_option config_optionsp[] = {
#define OPTION(name, type, def_val) \
{ STRINGIFY(name), type, offsetof(struct md_config_t, name) },
+#define SUBSYS(name, log, gather) \
+ { "debug_" STRINGIFY(name), OPT_INT, offsetof(struct md_config_t, debug_##name) },
+#define DEFAULT_SUBSYS(log, gather)
#include "common/config_opts.h"
#undef OPTION
+#undef SUBSYS
+#undef DEFAULT_SUBSYS
};
const int NUM_CONFIG_OPTIONS = sizeof(config_optionsp) / sizeof(config_option);
@@ -114,10 +119,28 @@ bool ceph_resolve_file_search(const std::string& filename_list,
md_config_t::md_config_t()
:
#define OPTION(name, type, def_val) name(def_val),
+#define SUBSYS(name, log, gather) debug_##name(log),
+#define DEFAULT_SUBSYS(log, gather) debug(log),
#include "common/config_opts.h"
#undef OPTION
+#undef SUBSYS
+#undef DEFAULT_SUBSYS
lock("md_config_t", true)
{
+ init_subsys();
+}
+
+void md_config_t::init_subsys()
+{
+#define SUBSYS(name, log, gather) \
+ subsys.add(ceph_subsys_##name, STRINGIFY(name), log, gather);
+#define DEFAULT_SUBSYS(log, gather) \
+ subsys.add(ceph_subsys_, "none", log, gather);
+#define OPTION(a, b, c)
+#include "common/config_opts.h"
+#undef OPTION
+#undef SUBSYS
+#undef DEFAULT_SUBSYS
}
md_config_t::~md_config_t()
@@ -199,6 +222,25 @@ int md_config_t::parse_config_files_impl(const std::list<std::string> &conf_file
set_val_impl(val.c_str(), opt);
}
}
+
+ // subsystems?
+ for (int o = 0; o < subsys.get_num(); o++) {
+ std::string as_option("debug_");
+ as_option += subsys.get_name(o);
+ std::string val;
+ int ret = get_val_from_conf_file(my_sections, as_option.c_str(), val, false);
+ if (ret == 0) {
+ int log, gather;
+ int r = sscanf(val.c_str(), "%d/%d", &log, &gather);
+ if (r >= 1) {
+ if (r < 2)
+ gather = log;
+ // cout << "config subsys " << subsys.get_name(o) << " log " << log << " gather " << gather << std::endl;
+ subsys.set_log_level(o, log);
+ subsys.set_gather_level(o, gather);
+ }
+ }
+ }
// Warn about section names that look like old-style section names
std::deque < std::string > old_style_section_names;
@@ -265,12 +307,9 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
set_val_or_die("daemonize", "false");
set_val_or_die("log_file", "");
set_val_or_die("pid_file", "");
- set_val_or_die("log_sym_dir", "");
- set_val_or_die("log_sym_history", "0");
set_val_or_die("log_to_stderr", "true");
set_val_or_die("err_to_stderr", "true");
set_val_or_die("log_to_syslog", "false");
- set_val_or_die("log_per_instance", "false");
}
// Some stuff that we wanted to give universal single-character options for
// Careful: you can burn through the alphabet pretty quickly by adding
@@ -294,97 +333,119 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
set_val_or_die("client_mountpoint", val.c_str());
}
else {
- int o;
- for (o = 0; o < NUM_CONFIG_OPTIONS; ++o) {
- const config_option *opt = config_optionsp + o;
- std::string as_option("--");
- as_option += opt->name;
-
- if (opt->type == OPT_BOOL) {
- if (ceph_argparse_flag(args, i, as_option.c_str(), (char*)NULL)) {
- set_val_impl("true", opt);
- break;
- }
- std::string no_option("--no-");
- no_option += opt->name;
- if (ceph_argparse_flag(args, i, no_option.c_str(), (char*)NULL)) {
- set_val_impl("false", opt);
- break;
- }
- }
- else if (ceph_argparse_witharg(args, i, &val,
- as_option.c_str(), (char*)NULL)) {
- set_val_impl(val.c_str(), opt);
- break;
- }
- }
- if (o == NUM_CONFIG_OPTIONS) {
- // ignore
- ++i;
- }
+ parse_option(args, i, NULL);
}
}
return 0;
}
-int md_config_t::parse_injectargs(std::vector<const char*>& args,
- std::ostringstream *oss)
+int md_config_t::parse_option(std::vector<const char*>& args,
+ std::vector<const char*>::iterator& i,
+ ostream *oss)
{
- assert(lock.is_locked());
- std::string val;
int ret = 0;
- for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
- int o;
- for (o = 0; o < NUM_CONFIG_OPTIONS; ++o) {
- const config_option *opt = config_optionsp + o;
- std::string as_option("--");
- as_option += opt->name;
- if (opt->type == OPT_BOOL) {
- int res;
- if (ceph_argparse_binary_flag(args, i, &res, oss, as_option.c_str(),
- (char*)NULL)) {
- if (res == 0)
- set_val_impl("false", opt);
- else if (res == 1)
- set_val_impl("true", opt);
- else
- ret = res;
- break;
- }
+ int o;
+ std::string val;
+
+ // subsystems?
+ for (o = 0; o < subsys.get_num(); o++) {
+ std::string as_option("--");
+ as_option += "debug_";
+ as_option += subsys.get_name(o);
+ if (ceph_argparse_witharg(args, i, &val,
+ as_option.c_str(), (char*)NULL)) {
+ int log, gather;
+ int r = sscanf(val.c_str(), "%d/%d", &log, &gather);
+ if (r >= 1) {
+ if (r < 2)
+ gather = log;
+ // cout << "subsys " << subsys.get_name(o) << " log " << log << " gather " << gather << std::endl;
+ subsys.set_log_level(o, log);
+ subsys.set_gather_level(o, gather);
}
- else if (ceph_argparse_witharg(args, i, &val,
- as_option.c_str(), (char*)NULL)) {
- if (((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) &&
- (observers.find(opt->name) == observers.end())) {
- *oss << "You cannot change " << opt->name << " using injectargs.\n";
- ret = -ENOSYS;
+ break;
+ }
+ }
+ if (o < subsys.get_num()) {
+ return ret;
+ }
+
+ for (o = 0; o < NUM_CONFIG_OPTIONS; ++o) {
+ const config_option *opt = config_optionsp + o;
+ std::string as_option("--");
+ as_option += opt->name;
+ if (opt->type == OPT_BOOL) {
+ int res;
+ if (ceph_argparse_binary_flag(args, i, &res, oss, as_option.c_str(),
+ (char*)NULL)) {
+ if (res == 0)
+ set_val_impl("false", opt);
+ else if (res == 1)
+ set_val_impl("true", opt);
+ else
+ ret = res;
+ break;
+ } else {
+ std::string no("--no-");
+ no += opt->name;
+ if (ceph_argparse_flag(args, i, &res, no.c_str(), (char*)NULL)) {
+ set_val_impl("false", opt);
break;
}
- int res = set_val_impl(val.c_str(), opt);
- if (res) {
+ }
+ }
+ else if (ceph_argparse_witharg(args, i, &val,
+ as_option.c_str(), (char*)NULL)) {
+ if (oss && (
+ ((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) &&
+ (observers.find(opt->name) == observers.end()))) {
+ *oss << "You cannot change " << opt->name << " using injectargs.\n";
+ ret = -ENOSYS;
+ break;
+ }
+ int res = set_val_impl(val.c_str(), opt);
+ if (res) {
+ if (oss) {
*oss << "Parse error setting " << opt->name << " to '"
<< val << "' using injectargs.\n";
ret = res;
break;
+ } else {
+ cerr << "parse error setting '" << opt->name << "' to '"
+ << val << "'\n" << std::endl;
}
- break;
}
+ break;
}
- if (o == NUM_CONFIG_OPTIONS) {
- // ignore
- ++i;
- }
+ }
+ if (o == NUM_CONFIG_OPTIONS) {
+ // ignore
+ ++i;
+ }
+ return ret;
+}
+
+int md_config_t::parse_injectargs(std::vector<const char*>& args,
+ std::ostream *oss)
+{
+ assert(lock.is_locked());
+ std::string val;
+ int ret = 0;
+ for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
+ int r = parse_option(args, i, oss);
+ if (r < 0)
+ ret = r;
}
return ret;
}
-void md_config_t::apply_changes(std::ostringstream *oss)
+void md_config_t::apply_changes(std::ostream *oss)
{
Mutex::Locker l(lock);
_apply_changes(oss);
}
-void md_config_t::_apply_changes(std::ostringstream *oss)
+void md_config_t::_apply_changes(std::ostream *oss)
{
/* Maps observers to the configuration options that they care about which
* have changed. */
@@ -453,7 +514,7 @@ void md_config_t::call_all_observers()
p->first->handle_conf_change(this, p->second);
}
-int md_config_t::injectargs(const std::string& s, std::ostringstream *oss)
+int md_config_t::injectargs(const std::string& s, std::ostream *oss)
{
int ret;
Mutex::Locker l(lock);
diff --git a/src/common/config.h b/src/common/config.h
index 6e5f4e918d6..4c350704b04 100644
--- a/src/common/config.h
+++ b/src/common/config.h
@@ -25,6 +25,7 @@ extern struct ceph_file_layout g_default_file_layout;
#include "common/ConfUtils.h"
#include "common/entity_name.h"
#include "common/Mutex.h"
+#include "log/SubsystemMap.h"
#include "include/assert.h" // TODO: remove
#include "common/config_obs.h"
#include "msg/msg_types.h"
@@ -108,12 +109,12 @@ public:
int parse_argv(std::vector<const char*>& args);
// Expand all metavariables. Make any pending observer callbacks.
- void apply_changes(std::ostringstream *oss);
- void _apply_changes(std::ostringstream *oss);
+ void apply_changes(std::ostream *oss);
+ void _apply_changes(std::ostream *oss);
void call_all_observers();
// Called by the Ceph daemons to make configuration changes at runtime
- int injectargs(const std::string &s, std::ostringstream *oss);
+ int injectargs(const std::string &s, std::ostream *oss);
// Set a configuration value, or crash
// Metavariables will be expanded.
@@ -140,14 +141,19 @@ public:
const char *key, std::string &out, bool emeta) const;
private:
+ int parse_option(std::vector<const char*>& args,
+ std::vector<const char*>::iterator& i,
+ std::ostream *oss);
int parse_injectargs(std::vector<const char*>& args,
- std::ostringstream *oss);
+ std::ostream *oss);
int parse_config_files_impl(const std::list<std::string> &conf_files,
std::deque<std::string> *parse_errors);
int set_val_impl(const char *val, const config_option *opt);
int set_val_raw(const char *val, const config_option *opt);
+ void init_subsys();
+
// Expand metavariables in the provided string.
// Returns true if any metavariables were found and expanded.
bool expand_meta(std::string &val) const;
@@ -159,6 +165,8 @@ private:
changed_set_t changed;
public:
+ ceph::log::SubsystemMap subsys;
+
EntityName name;
#define OPTION_OPT_INT(name) const int name;
#define OPTION_OPT_LONGLONG(name) const long long name;
@@ -170,6 +178,8 @@ public:
#define OPTION_OPT_U32(name) const uint32_t name;
#define OPTION_OPT_U64(name) const uint64_t name;
#define OPTION(name, ty, init) OPTION_##ty(name)
+#define SUBSYS(name, log, gather) OPTION_OPT_INT(debug_##name)
+#define DEFAULT_SUBSYS(log, gather) OPTION_OPT_INT(debug)
#include "common/config_opts.h"
#undef OPTION_OPT_INT
#undef OPTION_OPT_LONGLONG
@@ -181,6 +191,8 @@ public:
#undef OPTION_OPT_U32
#undef OPTION_OPT_U64
#undef OPTION
+#undef SUBSYS
+#undef DEFAULT_SUBSYS
/** A lock that protects the md_config_t internals. It is
* recursive, for simplicity.
@@ -209,4 +221,17 @@ struct config_option {
const void *conf_ptr(const md_config_t *conf) const;
};
+enum config_subsys_id {
+ ceph_subsys_, // default
+#define OPTION(a,b,c)
+#define SUBSYS(name, log, gather) \
+ ceph_subsys_##name,
+#define DEFAULT_SUBSYS(log, gather)
+#include "common/config_opts.h"
+#undef SUBSYS
+#undef OPTION
+#undef DEFAULT_SUBSYS
+ ceph_subsys_max
+};
+
#endif
diff --git a/src/common/config_obs.h b/src/common/config_obs.h
index ba2ceacd6e4..3c415cd2c55 100644
--- a/src/common/config_obs.h
+++ b/src/common/config_obs.h
@@ -26,6 +26,8 @@ public:
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;
+ virtual void handle_subsys_change(const struct md_config_t *conf,
+ const std::set<int>& changed) { }
};
#endif
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index 3a8ae15ee31..40f699d6a6c 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -26,50 +26,50 @@ OPTION(daemonize, OPT_BOOL, false)
OPTION(lockdep, OPT_BOOL, false)
OPTION(admin_socket, OPT_STR, "")
OPTION(log_file, OPT_STR, "")
-OPTION(log_sym_dir, OPT_STR, "")
-OPTION(log_sym_history, OPT_INT, 10)
OPTION(log_to_stderr, OPT_BOOL, true)
OPTION(err_to_stderr, OPT_BOOL, true)
OPTION(log_to_syslog, OPT_BOOL, false)
-OPTION(log_per_instance, OPT_BOOL, false)
OPTION(clog_to_monitors, OPT_BOOL, true)
OPTION(clog_to_syslog, OPT_BOOL, false)
OPTION(pid_file, OPT_STR, "")
OPTION(chdir, OPT_STR, "/")
OPTION(max_open_files, OPT_LONGLONG, 0)
-OPTION(debug, OPT_INT, 0)
-OPTION(debug_lockdep, OPT_INT, 0)
-OPTION(debug_context, OPT_INT, 0)
-OPTION(debug_crush, OPT_INT, 1)
-OPTION(debug_mds, OPT_INT, 1)
-OPTION(debug_mds_balancer, OPT_INT, 1)
-OPTION(debug_mds_locker, OPT_INT, 1)
-OPTION(debug_mds_log, OPT_INT, 1)
-OPTION(debug_mds_log_expire, OPT_INT, 1)
-OPTION(debug_mds_migrator, OPT_INT, 1)
-OPTION(debug_buffer, OPT_INT, 0)
-OPTION(debug_timer, OPT_INT, 0)
-OPTION(debug_filer, OPT_INT, 0)
-OPTION(debug_objecter, OPT_INT, 0)
-OPTION(debug_rados, OPT_INT, 0)
-OPTION(debug_rbd, OPT_INT, 0)
-OPTION(debug_journaler, OPT_INT, 0)
-OPTION(debug_objectcacher, OPT_INT, 0)
-OPTION(debug_client, OPT_INT, 0)
-OPTION(debug_osd, OPT_INT, 0)
-OPTION(debug_objclass, OPT_INT, 0)
-OPTION(debug_filestore, OPT_INT, 1)
-OPTION(debug_journal, OPT_INT, 1)
-OPTION(debug_bdev, OPT_INT, 1) // block device
-OPTION(debug_ms, OPT_INT, 0)
-OPTION(debug_mon, OPT_INT, 1)
-OPTION(debug_monc, OPT_INT, 0)
-OPTION(debug_paxos, OPT_INT, 0)
-OPTION(debug_tp, OPT_INT, 0)
-OPTION(debug_auth, OPT_INT, 1)
-OPTION(debug_finisher, OPT_INT, 1)
-OPTION(debug_heartbeatmap, OPT_INT, 1)
-OPTION(debug_perfcounter, OPT_INT, 1)
+
+DEFAULT_SUBSYS(0, 5)
+SUBSYS(lockdep, 0, 5)
+SUBSYS(context, 0, 5)
+SUBSYS(crush, 1, 5)
+SUBSYS(mds, 1, 5)
+SUBSYS(mds_balancer, 1, 5)
+SUBSYS(mds_locker, 1, 5)
+SUBSYS(mds_log, 1, 5)
+SUBSYS(mds_log_expire, 1, 5)
+SUBSYS(mds_migrator, 1, 5)
+SUBSYS(buffer, 0, 0)
+SUBSYS(timer, 0, 5)
+SUBSYS(filer, 0, 5)
+SUBSYS(objecter, 0, 0)
+SUBSYS(rados, 0, 5)
+SUBSYS(rbd, 0, 5)
+SUBSYS(journaler, 0, 5)
+SUBSYS(objectcacher, 0, 5)
+SUBSYS(client, 0, 5)
+SUBSYS(osd, 0, 5)
+SUBSYS(objclass, 0, 5)
+SUBSYS(filestore, 1, 5)
+SUBSYS(journal, 1, 5)
+SUBSYS(bdev, 1, 5) // block device
+SUBSYS(ms, 0, 5)
+SUBSYS(mon, 1, 5)
+SUBSYS(monc, 0, 5)
+SUBSYS(paxos, 0, 5)
+SUBSYS(tp, 0, 5)
+SUBSYS(auth, 1, 5)
+SUBSYS(finisher, 1, 5)
+SUBSYS(heartbeatmap, 1, 5)
+SUBSYS(perfcounter, 1, 5)
+SUBSYS(rgw, 1, 5) // log level for the Rados gateway
+
OPTION(key, OPT_STR, "")
OPTION(keyfile, OPT_STR, "")
OPTION(keyring, OPT_STR, "/etc/ceph/keyring,/etc/ceph/keyring.bin")
@@ -364,7 +364,6 @@ OPTION(bdev_iov_max, OPT_INT, 512) // max # iov's to collect into a s
OPTION(bdev_debug_check_io_overlap, OPT_BOOL, true) // [DEBUG] check for any pending io overlaps
OPTION(bdev_fake_mb, OPT_INT, 0)
OPTION(bdev_fake_max_mb, OPT_INT, 0)
-OPTION(debug_rgw, OPT_INT, 1) // log level for the Rados gateway
OPTION(rgw_cache_enabled, OPT_BOOL, true) // rgw cache enabled
OPTION(rgw_cache_lru_size, OPT_INT, 10000) // num of entries in rgw cache
OPTION(rgw_socket_path, OPT_STR, "") // path to unix domain socket, if not specified, rgw will not run as external fcgi
diff --git a/src/common/dout.cc b/src/common/dout.cc
new file mode 100644
index 00000000000..6c37559fbcc
--- /dev/null
+++ b/src/common/dout.cc
@@ -0,0 +1,12 @@
+
+#include <iostream>
+
+void dout_emergency(const char * const str)
+{
+ std::cerr << str << std::endl;
+}
+
+void dout_emergency(const std::string &str)
+{
+ std::cerr << str << std::endl;
+}
diff --git a/src/common/dout.h b/src/common/dout.h
index 6081dd93ae3..b38d367f7ee 100644
--- a/src/common/dout.h
+++ b/src/common/dout.h
@@ -17,46 +17,20 @@
#define CEPH_DOUT_H
#include "global/global_context.h"
-#include "common/DoutStreambuf.h"
#include "common/config.h"
#include "common/likely.h"
+#include "common/Clock.h"
+#include "log/Log.h"
#include "include/assert.h"
#include <iostream>
#include <pthread.h>
#include <streambuf>
+#include <sstream>
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;
@@ -66,41 +40,33 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
}
// 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) cct && (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)
+#define dout_impl(cct, sub, v) \
+ do { \
+ if (cct->_conf->subsys.should_gather(sub, v)) { \
+ if (0) { \
+ char __array[((v >= -1) && (v <= 200)) ? 0 : -1] __attribute__((unused)); \
+ } \
+ ceph::log::Entry *_dout_e = new ceph::log::Entry(ceph_clock_now(cct), \
+ pthread_self(), \
+ v, sub); \
+ ostringstream _dout_ss; \
+ CephContext *_dout_cct = cct; \
+ std::ostream* _dout = &_dout_ss;
+
+#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
+
+#define lgeneric_subdout(cct, sub, v) dout_impl(cct, ceph_subsys_##sub, v) *_dout
+#define lgeneric_dout(cct, v) dout_impl(cct, ceph_subsys_, v) *_dout
+#define lgeneric_derr(cct) dout_impl(cct, ceph_subsys_, -1) *_dout
+
+#define dendl std::flush; \
+ _dout_e->m_str = _dout_ss.str(); \
+ _dout_cct->_log->submit_entry(_dout_e); \
+ } \
+ } while (0)
#endif
diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc
index 8de8fca5a47..e11d64f2879 100644
--- a/src/common/lockdep.cc
+++ b/src/common/lockdep.cc
@@ -33,10 +33,9 @@ namespace __gnu_cxx {
#endif
/******* Constants **********/
-#define DOUT_SUBSYS lockdep
#undef DOUT_COND
-#define DOUT_COND(cct, l) cct && l <= XDOUT_CONDVAR(cct, DOUT_SUBSYS)
-#define lockdep_dout(v) ldout(g_lockdep_ceph_ctx, v)
+#define DOUT_COND(cct, l) cct && l <= XDOUT_CONDVAR(cct, dout_subsys)
+#define lockdep_dout(v) lsubdout(g_lockdep_ceph_ctx, lockdep, v)
#define MAX_LOCKS 100 // increase me as needed
#define BACKTRACE_SKIP 3
diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc
index 730fa5e1d59..20f300ae78a 100644
--- a/src/common/pick_address.cc
+++ b/src/common/pick_address.cc
@@ -7,6 +7,8 @@
#include <errno.h>
+#define dout_subsys ceph_subsys_
+
static const struct sockaddr *find_ip_in_subnet_list(CephContext *cct,
const struct ifaddrs *ifa,
const std::string networks)
diff --git a/src/common/signal.cc b/src/common/signal.cc
index 87b3b077d09..406ff463567 100644
--- a/src/common/signal.cc
+++ b/src/common/signal.cc
@@ -13,7 +13,6 @@
*/
#include "common/BackTrace.h"
-#include "common/DoutStreambuf.h"
#include "common/perf_counters.h"
#include "global/pidfile.h"
#include "common/debug.h"
diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc
index 7aacac1b487..b4317af13e4 100644
--- a/src/crush/CrushWrapper.cc
+++ b/src/crush/CrushWrapper.cc
@@ -4,7 +4,7 @@
#include "CrushWrapper.h"
-#define DOUT_SUBSYS crush
+#define dout_subsys ceph_subsys_crush
void CrushWrapper::find_roots(set<int>& roots) const
diff --git a/src/crushtool.cc b/src/crushtool.cc
index 6b47bfbdaf2..28a64acb95e 100644
--- a/src/crushtool.cc
+++ b/src/crushtool.cc
@@ -32,6 +32,7 @@
#include <fstream>
+#define dout_subsys ceph_subsys_crush
using namespace std;
diff --git a/src/global/global_context.cc b/src/global/global_context.cc
index 12527d7455c..05f76321ca3 100644
--- a/src/global/global_context.cc
+++ b/src/global/global_context.cc
@@ -20,4 +20,3 @@
*/
CephContext *g_ceph_context = NULL;
md_config_t *g_conf = NULL;
-DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss = NULL;
diff --git a/src/global/global_context.h b/src/global/global_context.h
index 6d08867909f..ab251dced70 100644
--- a/src/global/global_context.h
+++ b/src/global/global_context.h
@@ -20,14 +20,9 @@
#include <iostream>
#include <stdint.h>
-/* Forward declarations */
-template <typename T, typename U>
-class DoutStreambuf;
-
class md_config_t;
extern CephContext *g_ceph_context;
extern md_config_t *g_conf;
-extern DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
#endif
diff --git a/src/global/global_init.cc b/src/global/global_init.cc
index 60c0c4d0114..9f2dbf3b771 100644
--- a/src/global/global_init.cc
+++ b/src/global/global_init.cc
@@ -12,7 +12,6 @@
*
*/
-#include "common/DoutStreambuf.h"
#include "common/Thread.h"
#include "common/ceph_argparse.h"
#include "common/code_environment.h"
@@ -33,11 +32,12 @@
#include <errno.h>
#include <deque>
+#define dout_subsys ceph_subsys_
+
static void global_init_set_globals(CephContext *cct)
{
g_ceph_context = cct;
g_conf = cct->_conf;
- _doss = g_ceph_context->_doss;
}
static void output_ceph_version()
@@ -130,6 +130,10 @@ void global_init_daemonize(CephContext *cct, int flags)
const md_config_t *conf = cct->_conf;
if (!conf->daemonize)
return;
+
+ // stop log thread
+ g_ceph_context->_log->stop();
+
int num_threads = Thread::get_num_threads();
if (num_threads > 1) {
derr << "global_init_daemonize: BUG: there are " << num_threads - 1
@@ -145,6 +149,9 @@ void global_init_daemonize(CephContext *cct, int flags)
exit(1);
}
+ // restart log thread
+ g_ceph_context->_log->start();
+
if (atexit(pidfile_remove_void)) {
derr << "global_init_daemonize: failed to set pidfile_remove function "
<< "to run at exit." << dendl;
@@ -181,12 +188,6 @@ void global_init_daemonize(CephContext *cct, int flags)
}
}
pidfile_write(g_conf);
- ret = cct->_doss->handle_pid_change(g_conf);
- if (ret) {
- derr << "global_init_daemonize: _doss->handle_pid_change failed with "
- << "error code " << ret << dendl;
- exit(1);
- }
ldout(cct, 1) << "finished global_init_daemonize" << dendl;
}
@@ -215,7 +216,7 @@ int global_init_shutdown_stderr(CephContext *cct)
<< err << dendl;
return 1;
}
- cct->_doss->handle_stderr_shutdown();
+ cct->_log->set_stderr_level(-1, -1);
return 0;
}
diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc
index 2ce2f06c1c7..dc24bd91fd6 100644
--- a/src/global/signal_handler.cc
+++ b/src/global/signal_handler.cc
@@ -13,7 +13,6 @@
*/
#include "common/BackTrace.h"
-#include "common/DoutStreambuf.h"
#include "common/perf_counters.h"
#include "common/config.h"
#include "common/debug.h"
diff --git a/src/include/Context.h b/src/include/Context.h
index 05fac8a79e4..9f4d11981e9 100644
--- a/src/include/Context.h
+++ b/src/include/Context.h
@@ -24,7 +24,7 @@
#include <iostream>
-#define DOUT_SUBSYS context
+#define mydout(cct, v) lgeneric_subdout(cct, context, v)
/*
* Context - abstract callback class
@@ -56,12 +56,12 @@ inline void finish_contexts(CephContext *cct, std::list<Context*>& finished,
list<Context*> ls;
ls.swap(finished); // swap out of place to avoid weird loops
- ldout(cct,10) << ls.size() << " contexts to finish with " << result << dendl;
+ mydout(cct, 10) << ls.size() << " contexts to finish with " << result << dendl;
for (std::list<Context*>::iterator it = ls.begin();
it != ls.end();
it++) {
Context *c = *it;
- ldout(cct,10) << "---- " << c << dendl;
+ mydout(cct,10) << "---- " << c << dendl;
c->complete(result);
}
}
@@ -75,12 +75,12 @@ inline void finish_contexts(CephContext *cct, std::vector<Context*>& finished,
vector<Context*> ls;
ls.swap(finished); // swap out of place to avoid weird loops
- ldout(cct,10) << ls.size() << " contexts to finish with " << result << dendl;
+ mydout(cct,10) << ls.size() << " contexts to finish with " << result << dendl;
for (std::vector<Context*>::iterator it = ls.begin();
it != ls.end();
it++) {
Context *c = *it;
- ldout(cct,10) << "---- " << c << dendl;
+ mydout(cct,10) << "---- " << c << dendl;
c->complete(result);
}
}
@@ -143,7 +143,7 @@ private:
waitfor.erase(sub);
#endif
--sub_existing_count;
- ldout(cct,10) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub
+ mydout(cct,10) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub
#ifdef DEBUG_GATHER
<< " (remaining " << waitfor << ")"
#endif
@@ -186,11 +186,11 @@ private:
lock("C_Gather::lock", true, false), //disable lockdep
activated(false)
{
- ldout(cct,10) << "C_Gather " << this << ".new" << dendl;
+ mydout(cct,10) << "C_Gather " << this << ".new" << dendl;
}
public:
~C_Gather() {
- ldout(cct,10) << "C_Gather " << this << ".delete" << dendl;
+ mydout(cct,10) << "C_Gather " << this << ".delete" << dendl;
}
void set_finisher(Context *onfinish_) {
Mutex::Locker l(lock);
@@ -217,7 +217,7 @@ public:
#ifdef DEBUG_GATHER
waitfor.insert(s);
#endif
- ldout(cct,10) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl;
+ mydout(cct,10) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl;
return s;
}
void finish(int r) {
@@ -307,6 +307,6 @@ private:
bool activated;
};
-#undef DOUT_SUBSYS
+#undef mydout
#endif
diff --git a/src/init-ceph.in b/src/init-ceph.in
index e2bd569e808..afbd1d10df8 100644
--- a/src/init-ceph.in
+++ b/src/init-ceph.in
@@ -179,9 +179,7 @@ for name in $what; do
[ -n "$pid_file" ] && do_cmd "mkdir -p "`dirname $pid_file`
get_conf log_dir "" "log dir"
- get_conf log_sym_dir "" "log sym dir"
[ -n "$log_dir" ] && do_cmd "mkdir -p $log_dir"
- [ -n "$log_sym_dir" ] && do_cmd "mkdir -p $log_sym_dir"
binary="$BINDIR/ceph-$type"
if [ "$command" = "start" ]; then
@@ -338,15 +336,11 @@ for name in $what; do
cleanlogs)
echo removing logs
- if [ -n "$log_sym_dir" ]; then
- do_cmd "for f in $log_sym_dir/$type.$id.*; do rm -f \`readlink \$f\` ; rm -f \$f ; done ; rm -f $log_dir/$type.$id.*"
- fi
[ -n "$log_dir" ] && do_cmd "rm -f $log_dir/$type.$id.*"
;;
cleanalllogs)
echo removing all logs
- [ -n "$log_sym_dir" ] && do_cmd "rm -f $log_sym_dir/* || true"
[ -n "$log_dir" ] && do_cmd "rm -f $log_dir/* || true"
;;
diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc
index d22aebc0f81..db98a2c5132 100644
--- a/src/librados/IoCtxImpl.cc
+++ b/src/librados/IoCtxImpl.cc
@@ -19,7 +19,7 @@
#include "librados/RadosClient.h"
-#define DOUT_SUBSYS rados
+#define dout_subsys ceph_subsys_rados
#undef dout_prefix
#define dout_prefix *_dout << "librados: "
diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc
index 895db3ea091..67d882339f2 100644
--- a/src/librados/RadosClient.cc
+++ b/src/librados/RadosClient.cc
@@ -36,7 +36,7 @@
#include "PoolAsyncCompletionImpl.h"
#include "RadosClient.h"
-#define DOUT_SUBSYS rados
+#define dout_subsys ceph_subsys_rados
#undef dout_prefix
#define dout_prefix *_dout << "librados: "
diff --git a/src/librados/librados.cc b/src/librados/librados.cc
index 21bf0330875..3c12061c11e 100644
--- a/src/librados/librados.cc
+++ b/src/librados/librados.cc
@@ -27,7 +27,7 @@ using namespace std;
#include "librados/PoolAsyncCompletionImpl.h"
#include "librados/RadosClient.h"
-#define DOUT_SUBSYS rados
+#define dout_subsys ceph_subsys_rados
#undef dout_prefix
#define dout_prefix *_dout << "librados: "
diff --git a/src/librbd.cc b/src/librbd.cc
index 51cd4abd79b..0b20377d575 100644
--- a/src/librbd.cc
+++ b/src/librbd.cc
@@ -21,7 +21,7 @@
#include <errno.h>
#include <inttypes.h>
-#define DOUT_SUBSYS rbd
+#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
#define dout_prefix *_dout << "librbd: "
diff --git a/src/log/Entry.h b/src/log/Entry.h
new file mode 100644
index 00000000000..b8feb91facc
--- /dev/null
+++ b/src/log/Entry.h
@@ -0,0 +1,36 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef __CEPH_LOG_ENTRY_H
+#define __CEPH_LOG_ENTRY_H
+
+#include "include/utime.h"
+#include <pthread.h>
+#include <string>
+
+
+namespace ceph {
+namespace log {
+
+struct Entry {
+ utime_t m_stamp;
+ pthread_t m_thread;
+ short m_prio, m_subsys;
+ Entry *m_next;
+
+ std::string m_str;
+
+ Entry(utime_t s, pthread_t t, short pr, short sub,
+ const char *msg = NULL)
+ : m_stamp(s), m_thread(t), m_prio(pr), m_subsys(sub),
+ m_next(NULL)
+ {
+ if (msg)
+ m_str = msg;
+ }
+};
+
+}
+}
+
+#endif
diff --git a/src/log/EntryQueue.h b/src/log/EntryQueue.h
new file mode 100644
index 00000000000..b3b0c6b0694
--- /dev/null
+++ b/src/log/EntryQueue.h
@@ -0,0 +1,78 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef __CEPH_LOG_ENTRYQUEUE_H
+#define __CEPH_LOG_ENTRYQUEUE_H
+
+#include "Entry.h"
+
+namespace ceph {
+namespace log {
+
+struct EntryQueue {
+ int m_len, m_max_len;
+ struct Entry *m_head, *m_tail;
+
+ bool empty() const {
+ return m_len == 0;
+ }
+
+ void swap(EntryQueue& other) {
+ int len = m_len;
+ struct Entry *h = m_head, *t = m_tail;
+ m_len = other.m_len;
+ m_head = other.m_head;
+ m_tail = other.m_tail;
+ other.m_len = len;
+ other.m_head = h;
+ other.m_tail = t;
+ }
+
+ void trim() {
+ while (m_len > m_max_len) {
+ Entry *e = dequeue();
+ delete e;
+ }
+ }
+
+ void enqueue(Entry *e) {
+ if (m_tail) {
+ m_tail->m_next = e;
+ m_tail = e;
+ } else {
+ m_head = m_tail = e;
+ }
+ m_len++;
+ trim();
+ }
+
+ Entry *dequeue() {
+ if (!m_head)
+ return NULL;
+ Entry *e = m_head;
+ m_head = m_head->m_next;
+ if (!m_head)
+ m_tail = NULL;
+ m_len--;
+ e->m_next = NULL;
+ return e;
+ }
+
+ EntryQueue(int max=0)
+ : m_len(0), m_max_len(max),
+ m_head(NULL), m_tail(NULL)
+ {}
+ ~EntryQueue() {
+ Entry *t;
+ while (m_head) {
+ t = m_head->m_next;
+ delete m_head;
+ m_head = t;
+ }
+ }
+};
+
+}
+}
+
+#endif
diff --git a/src/log/Log.cc b/src/log/Log.cc
new file mode 100644
index 00000000000..8373f0ba74a
--- /dev/null
+++ b/src/log/Log.cc
@@ -0,0 +1,229 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "Log.h"
+
+#include <errno.h>
+#include <syslog.h>
+
+#include <iostream>
+#include <sstream>
+
+#include "common/errno.h"
+#include "common/safe_io.h"
+#include "common/Clock.h"
+#include "include/assert.h"
+
+#define DEFAULT_MAX_NEW 1000
+#define DEFAULT_MAX_RECENT 10000
+
+namespace ceph {
+namespace log {
+
+Log::Log(SubsystemMap *s)
+ : m_subs(s),
+ m_new(DEFAULT_MAX_NEW), m_recent(DEFAULT_MAX_RECENT),
+ m_fd(-1),
+ m_syslog_log(-1), m_syslog_crash(-1),
+ m_stderr_log(1), m_stderr_crash(-1),
+ m_stop(false)
+{
+ int ret;
+
+ ret = pthread_spin_init(&m_lock, PTHREAD_PROCESS_SHARED);
+ assert(ret == 0);
+
+ ret = pthread_mutex_init(&m_flush_mutex, NULL);
+ assert(ret == 0);
+
+ ret = pthread_mutex_init(&m_queue_mutex, NULL);
+ assert(ret == 0);
+
+ ret = pthread_cond_init(&m_cond, NULL);
+ assert(ret == 0);
+}
+
+Log::~Log()
+{
+ assert(!is_started());
+ if (m_fd >= 0)
+ TEMP_FAILURE_RETRY(::close(m_fd));
+
+ pthread_spin_destroy(&m_lock);
+ pthread_mutex_destroy(&m_queue_mutex);
+ pthread_mutex_destroy(&m_flush_mutex);
+ pthread_cond_destroy(&m_cond);
+}
+
+
+///
+
+void Log::set_log_file(string fn)
+{
+ m_log_file = fn;
+}
+
+void Log::reopen_log_file()
+{
+ if (m_fd >= 0)
+ TEMP_FAILURE_RETRY(::close(m_fd));
+ if (m_log_file.length()) {
+ m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND, 0644);
+ } else {
+ m_fd = -1;
+ }
+}
+
+void Log::set_syslog_level(int log, int crash)
+{
+ pthread_mutex_lock(&m_flush_mutex);
+ m_syslog_log = log;
+ m_syslog_crash = crash;
+ pthread_mutex_unlock(&m_flush_mutex);
+}
+
+void Log::set_stderr_level(int log, int crash)
+{
+ pthread_mutex_lock(&m_flush_mutex);
+ m_stderr_log = log;
+ m_stderr_crash = crash;
+ pthread_mutex_unlock(&m_flush_mutex);
+}
+
+void Log::submit_entry(Entry *e)
+{
+ pthread_mutex_lock(&m_queue_mutex);
+ m_new.enqueue(e);
+ pthread_cond_signal(&m_cond);
+ pthread_mutex_unlock(&m_queue_mutex);
+}
+
+void Log::flush()
+{
+ pthread_mutex_lock(&m_flush_mutex);
+ pthread_mutex_lock(&m_queue_mutex);
+ EntryQueue t;
+ t.swap(m_new);
+ pthread_mutex_unlock(&m_queue_mutex);
+ _flush(&t, &m_recent, false);
+ pthread_mutex_unlock(&m_flush_mutex);
+}
+
+void Log::_flush(EntryQueue *t, EntryQueue *requeue, bool crash)
+{
+ Entry *e;
+ while ((e = t->dequeue()) != NULL) {
+ unsigned sub = e->m_subsys;
+
+ ostringstream ss;
+ ss << e->m_stamp
+ << ' '
+ << std::hex << e->m_thread << std::dec
+ << ' '
+ << std::setw(2) << std::setfill('0') << e->m_prio << std::setw(0)
+ /*
+ << ':'
+ << std::setiosflags(ios::left)
+ << std::setw(m_subs->get_max_subsys_len()) << std::setfill(' ') << m_subs->get_name(sub)
+ << std::setiosflags(ios::right)
+ */
+ << ' ';
+
+ if ((crash || m_subs->get_log_level(sub) >= e->m_prio)) {
+ if (m_fd >= 0) {
+ int r = safe_write(m_fd, ss.str().data(), ss.str().size());
+ if (r >= 0)
+ r = safe_write(m_fd, e->m_str.data(), e->m_str.size());
+ if (r >= 0)
+ r = safe_write(m_fd, "\n", 1);
+ if (r < 0)
+ cerr << "problem writing to " << m_log_file << ": " << cpp_strerror(r) << std::endl;
+ }
+
+ if ((crash ? m_syslog_crash : m_syslog_log) >= e->m_prio) {
+ syslog(LOG_USER, "%s%s", ss.str().c_str(), e->m_str.c_str());
+ }
+
+ if ((crash ? m_stderr_crash : m_stderr_log) >= e->m_prio) {
+ cerr << ss.str() << e->m_str << std::endl;
+ }
+ }
+
+ requeue->enqueue(e);
+ }
+}
+
+void Log::_log_message(const char *s, bool crash)
+{
+ if (m_fd >= 0) {
+ int r = safe_write(m_fd, s, strlen(s));
+ if (r >= 0)
+ r = safe_write(m_fd, "\n", 1);
+ if (r < 0)
+ cerr << "problem writing to " << m_log_file << ": " << cpp_strerror(r) << std::endl;
+ }
+ if ((crash ? m_syslog_crash : m_syslog_log) >= 0) {
+ syslog(LOG_USER, "%s", s);
+ }
+
+ if ((crash ? m_stderr_crash : m_stderr_log) >= 0) {
+ cerr << s << std::endl;
+ }
+}
+
+void Log::dump_recent()
+{
+ pthread_mutex_unlock(&m_flush_mutex);
+
+ pthread_mutex_lock(&m_queue_mutex);
+ EntryQueue t(1);
+ t.swap(m_new);
+ pthread_mutex_unlock(&m_queue_mutex);
+ _flush(&t, &m_recent, false);
+
+ EntryQueue old(0);
+
+ _log_message("--- begin dump of recent events ---", true);
+ _flush(&m_recent, &old, true);
+ _log_message("--- end dump of recent events ---", true);
+
+ pthread_mutex_unlock(&m_flush_mutex);
+}
+
+void Log::start()
+{
+ assert(!is_started());
+ m_stop = false;
+ create();
+}
+
+void Log::stop()
+{
+ assert(is_started());
+ pthread_mutex_lock(&m_queue_mutex);
+ m_stop = true;
+ pthread_cond_signal(&m_cond);
+ pthread_mutex_unlock(&m_queue_mutex);
+ join();
+}
+
+void *Log::entry()
+{
+ pthread_mutex_lock(&m_queue_mutex);
+ while (!m_stop) {
+ if (!m_new.empty()) {
+ pthread_mutex_unlock(&m_queue_mutex);
+ flush();
+ pthread_mutex_lock(&m_queue_mutex);
+ continue;
+ }
+
+ pthread_cond_wait(&m_cond, &m_queue_mutex);
+ }
+ pthread_mutex_unlock(&m_queue_mutex);
+ flush();
+ return NULL;
+}
+
+} // ceph::log::
+} // ceph::
diff --git a/src/log/Log.h b/src/log/Log.h
new file mode 100644
index 00000000000..e8a497e01e7
--- /dev/null
+++ b/src/log/Log.h
@@ -0,0 +1,69 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef __CEPH_LOG_LOG_H
+#define __CEPH_LOG_LOG_H
+
+#include "common/Thread.h"
+
+#include <pthread.h>
+
+#include "Entry.h"
+#include "EntryQueue.h"
+#include "SubsystemMap.h"
+
+namespace ceph {
+namespace log {
+
+class Log : private Thread
+{
+ SubsystemMap *m_subs;
+
+ pthread_spinlock_t m_lock;
+ pthread_mutex_t m_queue_mutex;
+ pthread_mutex_t m_flush_mutex;
+ pthread_cond_t m_cond;
+
+ EntryQueue m_new; ///< new entries
+ EntryQueue m_recent; ///< recent (less new) entries we've already written at low detail
+
+ std::string m_log_file;
+ int m_fd;
+
+ int m_syslog_log, m_syslog_crash;
+ int m_stderr_log, m_stderr_crash;
+
+ bool m_stop;
+
+ void *entry();
+
+ void _flush(EntryQueue *q, EntryQueue *requeue, bool crash);
+
+ void _log_message(const char *s, bool crash);
+
+public:
+ Log(SubsystemMap *s);
+ virtual ~Log();
+
+ void set_max_new(int n);
+ void set_max_recent(int n);
+ void set_log_file(std::string fn);
+ void reopen_log_file();
+
+ void flush();
+
+ void dump_recent();
+
+ void set_syslog_level(int log, int crash);
+ void set_stderr_level(int log, int crash);
+
+ void submit_entry(Entry *e);
+
+ void start();
+ void stop();
+};
+
+}
+}
+
+#endif
diff --git a/src/log/SubsystemMap.h b/src/log/SubsystemMap.h
new file mode 100644
index 00000000000..af1430dca0c
--- /dev/null
+++ b/src/log/SubsystemMap.h
@@ -0,0 +1,82 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LOG_SUBSYSTEMS
+#define CEPH_LOG_SUBSYSTEMS
+
+#include <string>
+#include <vector>
+
+namespace ceph {
+namespace log {
+
+struct Subsystem {
+ int log_level, gather_level;
+ std::string name;
+
+ Subsystem() : log_level(0), gather_level(0) {}
+};
+
+class SubsystemMap {
+ std::vector<Subsystem> m_subsys;
+ unsigned m_max_name_len;
+
+public:
+ SubsystemMap() : m_max_name_len(0) {}
+
+ int get_num() const {
+ return m_subsys.size();
+ }
+
+ int get_max_subsys_len() const {
+ return m_max_name_len;
+ }
+
+ void add(unsigned subsys, string name, int log, int gather) {
+ if (subsys >= m_subsys.size())
+ m_subsys.resize(subsys + 1);
+ m_subsys[subsys].name = name;
+ m_subsys[subsys].log_level = log;
+ m_subsys[subsys].gather_level = gather;
+ if (name.length() > m_max_name_len)
+ m_max_name_len = name.length();
+ }
+
+ void set_log_level(unsigned subsys, int log) {
+ assert(subsys < m_subsys.size());
+ m_subsys[subsys].log_level = log;
+ }
+
+ void set_gather_level(unsigned subsys, int gather) {
+ assert(subsys < m_subsys.size());
+ m_subsys[subsys].gather_level = gather;
+ }
+
+ int get_log_level(unsigned subsys) {
+ if (subsys >= m_subsys.size())
+ subsys = 0;
+ return m_subsys[subsys].log_level;
+ }
+
+ int get_gather_level(unsigned subsys) {
+ if (subsys >= m_subsys.size())
+ subsys = 0;
+ return m_subsys[subsys].gather_level;
+ }
+
+ const string& get_name(unsigned subsys) {
+ if (subsys >= m_subsys.size())
+ subsys = 0;
+ return m_subsys[subsys].name;
+ }
+
+ bool should_gather(unsigned sub, int level) {
+ assert(sub < m_subsys.size());
+ return level <= m_subsys[sub].log_level;
+ }
+};
+
+}
+}
+
+#endif
diff --git a/src/log/test.cc b/src/log/test.cc
new file mode 100644
index 00000000000..26595bdbbf6
--- /dev/null
+++ b/src/log/test.cc
@@ -0,0 +1,143 @@
+#include <gtest/gtest.h>
+
+#include "log/log.h"
+#include "common/Clock.h"
+
+
+using namespace ceph::log;
+
+TEST(Log, Simple)
+{
+ SubsystemMap subs;
+ subs.add(0, "none", 10, 10);
+ subs.add(1, "foosys", 20, 1);
+ subs.add(2, "bar", 20, 2);
+ subs.add(3, "baz", 10, 3);
+
+ Log log(&subs);
+ log.start();
+
+ log.set_log_file("/tmp/foo");
+ log.reopen_log_file();
+
+ log.set_stderr_level(5, -1);
+
+
+ for (int i=0; i<100; i++) {
+ int sys = i % 4;
+ int l = 5 + (i%4);
+ if (subs.should_gather(sys, l)) {
+ Entry *e = new Entry(ceph_clock_now(NULL),
+ pthread_self(),
+ l,
+ sys,
+ "hello world");
+ log.submit_entry(e);
+ }
+ }
+
+ log.flush();
+
+ log.dump_recent();
+
+ log.stop();
+}
+
+int many = 10000000;
+
+TEST(Log, ManyNoGather)
+{
+ SubsystemMap subs;
+ subs.add(1, "foo", 1, 1);
+ Log log(&subs);
+ log.start();
+ log.set_log_file("/tmp/big");
+ log.reopen_log_file();
+ for (int i=0; i<many; i++) {
+ int l = 10;
+ if (subs.should_gather(1, l))
+ log.submit_entry(new Entry(ceph_clock_now(NULL), pthread_self(), l, 1));
+ }
+ log.flush();
+ log.stop();
+}
+
+
+TEST(Log, ManyGatherLog)
+{
+ SubsystemMap subs;
+ subs.add(1, "foo", 20, 10);
+ Log log(&subs);
+ log.start();
+ log.set_log_file("/tmp/big");
+ log.reopen_log_file();
+ for (int i=0; i<many; i++) {
+ int l = 10;
+ if (subs.should_gather(1, l))
+ log.submit_entry(new Entry(ceph_clock_now(NULL), pthread_self(), l, 1,
+ "this is a long string asdf asdf asdf asdf asdf asdf asd fasd fasdf "));
+ }
+ log.flush();
+ log.stop();
+}
+
+TEST(Log, ManyGatherLogB)
+{
+ SubsystemMap subs;
+ subs.add(1, "foo", 20, 10);
+ Log log(&subs);
+ log.start();
+ log.set_log_file("/tmp/big");
+ log.reopen_log_file();
+ for (int i=0; i<many; i++) {
+ int l = 10;
+ if (subs.should_gather(1, l)) {
+ Entry *e = new Entry(ceph_clock_now(NULL), pthread_self(), l, 1);
+ ostringstream oss;
+ oss << "this i a long stream asdf asdf asdf asdf asdf asdf asdf asdf asdf as fd";
+ e->m_str = oss.str();
+ log.submit_entry(e);
+ }
+ }
+ log.flush();
+ log.stop();
+}
+TEST(Log, ManyGatherLogC)
+{
+ SubsystemMap subs;
+ subs.add(1, "foo", 20, 10);
+ Log log(&subs);
+ log.start();
+ log.set_log_file("/tmp/big");
+ log.reopen_log_file();
+ for (int i=0; i<many; i++) {
+ int l = 10;
+ if (subs.should_gather(1, l)) {
+ Entry *e = new Entry(ceph_clock_now(NULL), pthread_self(), l, 1);
+ ostringstream oss;
+ oss.str().reserve(80);
+ oss << "this i a long stream asdf asdf asdf asdf asdf asdf asdf asdf asdf as fd";
+ e->m_str = oss.str();
+ log.submit_entry(e);
+ }
+ }
+ log.flush();
+ log.stop();
+}
+
+TEST(Log, ManyGather)
+{
+ SubsystemMap subs;
+ subs.add(1, "foo", 20, 1);
+ Log log(&subs);
+ log.start();
+ log.set_log_file("/tmp/big");
+ log.reopen_log_file();
+ for (int i=0; i<many; i++) {
+ int l = 10;
+ if (subs.should_gather(1, l))
+ log.submit_entry(new Entry(ceph_clock_now(NULL), pthread_self(), l, 1));
+ }
+ log.flush();
+ log.stop();
+}
diff --git a/src/mds/AnchorClient.cc b/src/mds/AnchorClient.cc
index 3dad48f1f26..7900da4ce61 100644
--- a/src/mds/AnchorClient.cc
+++ b/src/mds/AnchorClient.cc
@@ -22,7 +22,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".anchorclient "
diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc
index 423a760608b..731ec9633bb 100644
--- a/src/mds/AnchorServer.cc
+++ b/src/mds/AnchorServer.cc
@@ -17,7 +17,7 @@
#include "msg/Messenger.h"
#include "messages/MMDSTableRequest.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".anchorserver "
diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc
index 95e9eacedd7..ee58436123a 100644
--- a/src/mds/CDentry.cc
+++ b/src/mds/CDentry.cc
@@ -26,7 +26,7 @@
#include "messages/MLock.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << dir->cache->mds->get_nodeid() << ".cache.den(" << dir->dirfrag() << " " << name << ") "
diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc
index 0359676853b..d6e35e55f53 100644
--- a/src/mds/CDir.cc
+++ b/src/mds/CDir.cc
@@ -35,7 +35,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << cache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") "
diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc
index 0232e7c6ebe..70faeb81597 100644
--- a/src/mds/CInode.cc
+++ b/src/mds/CInode.cc
@@ -42,7 +42,7 @@
#include "common/config.h"
#include "global/global_context.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mdcache->mds->get_nodeid() << ".cache.ino(" << inode.ino << ") "
diff --git a/src/mds/CInode.h b/src/mds/CInode.h
index 68ee7452aa4..57c76c49441 100644
--- a/src/mds/CInode.h
+++ b/src/mds/CInode.h
@@ -81,7 +81,7 @@ struct default_file_layout {
__u8 struct_v;
::decode(struct_v, bl);
if (struct_v != 1) { //uh-oh
- dout(0) << "got default layout I don't understand!" << dendl;
+ derr << "got default layout I don't understand!" << dendl;
assert(0);
}
::decode(layout, bl);
diff --git a/src/mds/InoTable.cc b/src/mds/InoTable.cc
index a51db89e137..426b9150ea6 100644
--- a/src/mds/InoTable.cc
+++ b/src/mds/InoTable.cc
@@ -19,7 +19,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << "." << table_name << ": "
diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc
index 2999f7974aa..72802ea7e7c 100644
--- a/src/mds/Locker.cc
+++ b/src/mds/Locker.cc
@@ -56,7 +56,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#undef DOUT_COND
#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_locker
diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc
index d03c0fe192b..e39464c3b5f 100644
--- a/src/mds/MDBalancer.cc
+++ b/src/mds/MDBalancer.cc
@@ -37,7 +37,7 @@ using std::vector;
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef DOUT_COND
#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_balancer
#undef dout_prefix
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index fb7fec66301..542750d86d1 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -98,7 +98,7 @@ extern struct ceph_file_layout g_default_file_layout;
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix _prefix(_dout, mds)
static ostream& _prefix(std::ostream *_dout, MDS *mds) {
diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc
index a5c1b096578..294ad53961c 100644
--- a/src/mds/MDLog.cc
+++ b/src/mds/MDLog.cc
@@ -27,7 +27,7 @@
#include "common/config.h"
#include "common/errno.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef DOUT_COND
#define DOUT_COND(cct, l) l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_log
#undef dout_prefix
diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc
index 16ed8c8821d..8213b09e873 100644
--- a/src/mds/MDS.cc
+++ b/src/mds/MDS.cc
@@ -71,13 +71,12 @@
#include "common/config.h"
#include "common/errno.h"
-#include "common/DoutStreambuf.h"
#include "perfglue/cpu_profiler.h"
#include "perfglue/heap_profiler.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << whoami << '.' << incarnation << ' '
diff --git a/src/mds/MDSTable.cc b/src/mds/MDSTable.cc
index 41d69003dcf..308a9e5d65a 100644
--- a/src/mds/MDSTable.cc
+++ b/src/mds/MDSTable.cc
@@ -24,7 +24,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << "." << table_name << ": "
diff --git a/src/mds/MDSTableClient.cc b/src/mds/MDSTableClient.cc
index 675dfd66d4b..1d2c77bc4be 100644
--- a/src/mds/MDSTableClient.cc
+++ b/src/mds/MDSTableClient.cc
@@ -30,7 +30,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".tableclient(" << get_mdstable_name(table) << ") "
diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc
index bc03ca61e72..cfa308753dc 100644
--- a/src/mds/MDSTableServer.cc
+++ b/src/mds/MDSTableServer.cc
@@ -20,7 +20,7 @@
#include "messages/MMDSTableRequest.h"
#include "events/ETableServer.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".tableserver(" << get_mdstable_name(table) << ") "
diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc
index c1148645c14..7301875327b 100644
--- a/src/mds/Migrator.cc
+++ b/src/mds/Migrator.cc
@@ -76,7 +76,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef DOUT_COND
#define DOUT_COND(cct, l) (l <= cct->_conf->debug_mds || l <= cct->_conf->debug_mds_migrator)
#undef dout_prefix
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index 55e5a579efe..8c9d152040c 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -60,7 +60,7 @@ using namespace std;
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".server "
diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc
index 5baa43e13de..c2d348951ee 100644
--- a/src/mds/SessionMap.cc
+++ b/src/mds/SessionMap.cc
@@ -19,7 +19,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".sessionmap "
diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc
index 5352b22c5f5..4ce1f776e3b 100644
--- a/src/mds/SnapServer.cc
+++ b/src/mds/SnapServer.cc
@@ -25,7 +25,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".snap "
diff --git a/src/mds/flock.cc b/src/mds/flock.cc
index a3cac9e46e4..0deb900f0b0 100644
--- a/src/mds/flock.cc
+++ b/src/mds/flock.cc
@@ -6,6 +6,8 @@
#include "mdstypes.h"
#include "mds/flock.h"
+#define dout_subsys ceph_subsys_mds
+
bool ceph_lock_state_t::is_waiting(ceph_filelock &fl)
{
multimap<uint64_t, ceph_filelock>::iterator p = waiting_locks.find(fl.start);
diff --git a/src/mds/journal.cc b/src/mds/journal.cc
index c35a33e7219..38f8c0e7821 100644
--- a/src/mds/journal.cc
+++ b/src/mds/journal.cc
@@ -54,7 +54,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef DOUT_COND
#define DOUT_COND(cct, l) (l<=cct->_conf->debug_mds || l <= cct->_conf->debug_mds_log \
|| l <= cct->_conf->debug_mds_log_expire)
diff --git a/src/mds/snap.cc b/src/mds/snap.cc
index 0b77d7c696b..fa434b79d02 100644
--- a/src/mds/snap.cc
+++ b/src/mds/snap.cc
@@ -22,7 +22,7 @@
* SnapRealm
*/
-#define DOUT_SUBSYS mds
+#define dout_subsys ceph_subsys_mds
#undef dout_prefix
#define dout_prefix _prefix(_dout, mdcache->mds->get_nodeid(), inode, srnode.seq, this)
static ostream& _prefix(std::ostream *_dout, int whoami, CInode *inode,
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc
index d7c77ed12f3..f76caa97372 100644
--- a/src/mon/AuthMonitor.cc
+++ b/src/mon/AuthMonitor.cc
@@ -34,7 +34,7 @@
#include "common/config.h"
#include <sstream>
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, paxos->get_version())
static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) {
diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc
index a7bac193ca4..9db0216ac38 100644
--- a/src/mon/Elector.cc
+++ b/src/mon/Elector.cc
@@ -22,7 +22,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, epoch)
static ostream& _prefix(std::ostream *_dout, Monitor *mon, epoch_t epoch) {
diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc
index 199054d2747..e2b4867b44a 100644
--- a/src/mon/LogMonitor.cc
+++ b/src/mon/LogMonitor.cc
@@ -29,7 +29,7 @@
#include "common/config.h"
#include <sstream>
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, paxos->get_version())
static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) {
diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc
index 77b808a63ec..7236f588558 100644
--- a/src/mon/MDSMonitor.cc
+++ b/src/mon/MDSMonitor.cc
@@ -35,7 +35,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, mdsmap)
static ostream& _prefix(std::ostream *_dout, Monitor *mon, MDSMap& mdsmap) {
diff --git a/src/mon/MonCaps.cc b/src/mon/MonCaps.cc
index 102fc168a40..51cc7f8761b 100644
--- a/src/mon/MonCaps.cc
+++ b/src/mon/MonCaps.cc
@@ -19,6 +19,8 @@
#include "MonCaps.h"
#include "mon_types.h"
+#define dout_subsys ceph_subsys_auth
+
bool MonCaps::get_next_token(string s, size_t& pos, string& token)
{
int start = s.find_first_not_of(" \t", pos);
diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc
index 3bf5a714aee..33ee088961b 100644
--- a/src/mon/MonClient.cc
+++ b/src/mon/MonClient.cc
@@ -40,7 +40,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS monc
+#define dout_subsys ceph_subsys_monc
#undef dout_prefix
#define dout_prefix *_dout << "monclient" << (hunting ? "(hunting)":"") << ": "
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 5461b9cad17..0ff20e356d7 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -45,7 +45,6 @@
#include "common/ceph_argparse.h"
#include "common/Timer.h"
#include "common/Clock.h"
-#include "common/DoutStreambuf.h"
#include "common/errno.h"
#include "common/perf_counters.h"
#include "common/admin_socket.h"
@@ -70,7 +69,7 @@
#include <stdlib.h>
#include <signal.h>
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, this)
static ostream& _prefix(std::ostream *_dout, const Monitor *mon) {
diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc
index d41209c2e02..5c6edefb9b9 100644
--- a/src/mon/MonitorStore.cc
+++ b/src/mon/MonitorStore.cc
@@ -28,7 +28,7 @@
#include "include/compat.h"
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, dir)
static ostream& _prefix(std::ostream *_dout, const string& dir) {
diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc
index 7f167437fb7..3d7d775f860 100644
--- a/src/mon/MonmapMonitor.cc
+++ b/src/mon/MonmapMonitor.cc
@@ -28,7 +28,7 @@
#include <sstream>
#include "common/config.h"
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon)
static ostream& _prefix(std::ostream *_dout, Monitor *mon) {
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index b39029af41b..3f0db37ae04 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -45,7 +45,7 @@
#include <sstream>
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, osdmap)
static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) {
diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc
index d961ac1b55e..107c1130fc4 100644
--- a/src/mon/PGMap.cc
+++ b/src/mon/PGMap.cc
@@ -3,7 +3,7 @@
#include "PGMap.h"
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#include "common/debug.h"
#include "common/Formatter.h"
diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc
index ff0f0a9c21a..3b4cf283bdd 100644
--- a/src/mon/PGMonitor.cc
+++ b/src/mon/PGMonitor.cc
@@ -41,7 +41,7 @@
#include "common/config.h"
#include <sstream>
-#define DOUT_SUBSYS mon
+#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, pg_map)
static ostream& _prefix(std::ostream *_dout, const Monitor *mon, const PGMap& pg_map) {
diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc
index 66c720af533..e3e1577f521 100644
--- a/src/mon/Paxos.cc
+++ b/src/mon/Paxos.cc
@@ -21,7 +21,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS paxos
+#define dout_subsys ceph_subsys_paxos
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, mon->name, mon->rank, machine_name, state, first_committed, last_committed)
static ostream& _prefix(std::ostream *_dout, Monitor *mon, const string& name, int rank,
diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc
index 399fd071977..812ae996a17 100644
--- a/src/mon/PaxosService.cc
+++ b/src/mon/PaxosService.cc
@@ -20,7 +20,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS paxos
+#define dout_subsys ceph_subsys_paxos
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, paxos, paxos->machine_id)
static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, int machine_id) {
diff --git a/src/msg/Message.cc b/src/msg/Message.cc
index ff71356bc2a..a6bd1f2976b 100644
--- a/src/msg/Message.cc
+++ b/src/msg/Message.cc
@@ -146,6 +146,7 @@ using namespace std;
#define DEBUGLVL 10 // debug level of output
+#define dout_subsys ceph_subsys_ms
void Message::encode(uint64_t features, bool datacrc)
{
@@ -632,9 +633,9 @@ Message *decode_message(CephContext *cct, ceph_msg_header& header, ceph_msg_foot
}
catch (const buffer::error &e) {
if (cct) {
- ldout(cct, 0) << "failed to decode message of type " << type
- << " v" << header.version
- << ": " << e.what() << dendl;
+ lderr(cct) << "failed to decode message of type " << type
+ << " v" << header.version
+ << ": " << e.what() << dendl;
if (cct->_conf->ms_die_on_bad_msg)
assert(0);
}
diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc
index a1e1cc4edc7..e81796d2a5b 100644
--- a/src/msg/SimpleMessenger.cc
+++ b/src/msg/SimpleMessenger.cc
@@ -42,7 +42,7 @@
#include "include/compat.h"
-#define DOUT_SUBSYS ms
+#define dout_subsys ceph_subsys_ms
#undef dout_prefix
#define dout_prefix _prefix(_dout, msgr)
static ostream& _prefix(std::ostream *_dout, SimpleMessenger *msgr) {
diff --git a/src/msg/SimpleMessenger.h b/src/msg/SimpleMessenger.h
index 8ab78c9fc1a..d87c9a3bde1 100644
--- a/src/msg/SimpleMessenger.h
+++ b/src/msg/SimpleMessenger.h
@@ -223,20 +223,20 @@ private:
/* Clean up sent list */
void handle_ack(uint64_t seq) {
- ldout(msgr->cct, 15) << "reader got ack seq " << seq << dendl;
+ lsubdout(msgr->cct, ms, 15) << "reader got ack seq " << seq << dendl;
// trim sent list
while (!sent.empty() &&
sent.front()->get_seq() <= seq) {
Message *m = sent.front();
sent.pop_front();
- ldout(msgr->cct, 10) << "reader got ack seq "
+ lsubdout(msgr->cct, ms, 10) << "reader got ack seq "
<< seq << " >= " << m->get_seq() << " on " << m << " " << *m << dendl;
m->put();
}
if (sent.empty() && close_on_empty) {
// this is slightly hacky
- ldout(msgr->cct, 10) << "reader got last ack, queue empty, closing" << dendl;
+ lsubdout(msgr->cct, ms, 10) << "reader got last ack, queue empty, closing" << dendl;
policy.lossy = true;
fault();
}
diff --git a/src/objclass/class_debug.cc b/src/objclass/class_debug.cc
index 9614274210e..8ebf82ccb13 100644
--- a/src/objclass/class_debug.cc
+++ b/src/objclass/class_debug.cc
@@ -9,7 +9,7 @@
#include <iostream>
-#define DOUT_SUBSYS objclass
+#define dout_subsys ceph_subsys_objclass
int cls_log(const char *format, ...)
{
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index f425d88223c..09418cbcdc6 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/DBObjectMap.cc
@@ -20,7 +20,7 @@
#include "common/debug.h"
#include "common/config.h"
-#define DOUT_SUBSYS filestore
+#define dout_subsys ceph_subsys_filestore
#undef dout_prefix
#define dout_prefix *_dout << "filestore "
diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc
index 5dc21205b8e..28ed274fe11 100644
--- a/src/os/FileJournal.cc
+++ b/src/os/FileJournal.cc
@@ -34,7 +34,7 @@
#endif
-#define DOUT_SUBSYS journal
+#define dout_subsys ceph_subsys_journal
#undef dout_prefix
#define dout_prefix *_dout << "journal "
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index db66a7b0a2d..1271ce4146a 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -76,7 +76,7 @@ using ceph::crypto::SHA1;
#include "common/config.h"
-#define DOUT_SUBSYS filestore
+#define dout_subsys ceph_subsys_filestore
#undef dout_prefix
#define dout_prefix *_dout << "filestore(" << basedir << ") "
diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc
index a47f457e83b..bf8c3f7b188 100644
--- a/src/os/HashIndex.cc
+++ b/src/os/HashIndex.cc
@@ -20,7 +20,7 @@
#include "HashIndex.h"
#include "common/debug.h"
-#define DOUT_SUBSYS filestore
+#define dout_subsys ceph_subsys_filestore
const string HashIndex::SUBDIR_ATTR = "contents";
const string HashIndex::IN_PROGRESS_OP_TAG = "in_progress_op";
diff --git a/src/os/JournalingObjectStore.cc b/src/os/JournalingObjectStore.cc
index 71c96e1c8d6..75bb2788439 100644
--- a/src/os/JournalingObjectStore.cc
+++ b/src/os/JournalingObjectStore.cc
@@ -3,7 +3,7 @@
#include "common/debug.h"
-#define DOUT_SUBSYS journal
+#define dout_subsys ceph_subsys_journal
#undef dout_prefix
#define dout_prefix *_dout << "journal "
diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc
index 89de9c71ac4..2402d04e72f 100644
--- a/src/os/LFNIndex.cc
+++ b/src/os/LFNIndex.cc
@@ -35,7 +35,7 @@
#include "LFNIndex.h"
using ceph::crypto::SHA1;
-#define DOUT_SUBSYS filestore
+#define dout_subsys ceph_subsys_filestore
#undef dout_prefix
#define dout_prefix *_dout << "LFNIndex(" << get_base_path() << ") "
diff --git a/src/osd/ClassHandler.cc b/src/osd/ClassHandler.cc
index a0ebdca9018..35768c25272 100644
--- a/src/osd/ClassHandler.cc
+++ b/src/osd/ClassHandler.cc
@@ -14,7 +14,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS osd
+#define dout_subsys ceph_subsys_osd
#undef dout_prefix
#define dout_prefix *_dout
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index bf904eeffb5..f3333a4d59e 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -86,7 +86,6 @@
#include "messages/MWatchNotify.h"
-#include "common/DoutStreambuf.h"
#include "common/perf_counters.h"
#include "common/Timer.h"
#include "common/LogClient.h"
@@ -113,7 +112,7 @@
#include "include/assert.h"
#include "common/config.h"
-#define DOUT_SUBSYS osd
+#define dout_subsys ceph_subsys_osd
#undef dout_prefix
#define dout_prefix _prefix(*_dout, whoami, osdmap)
diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc
index fff48c08900..88eec892d89 100644
--- a/src/osd/OSDMap.cc
+++ b/src/osd/OSDMap.cc
@@ -20,6 +20,8 @@
#include "common/code_environment.h"
+#define dout_subsys ceph_subsys_osd
+
// ----------------------------------
// osd_info_t
diff --git a/src/osd/PG.cc b/src/osd/PG.cc
index 1516fe20555..9dde84c8699 100644
--- a/src/osd/PG.cc
+++ b/src/osd/PG.cc
@@ -31,7 +31,7 @@
#include <sstream>
-#define DOUT_SUBSYS osd
+#define dout_subsys ceph_subsys_osd
#undef dout_prefix
#define dout_prefix _prefix(_dout, this)
static ostream& _prefix(std::ostream *_dout, const PG *pg) {
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index 4f641fd3e68..59bccd93119 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -44,7 +44,7 @@
#include "json_spirit/json_spirit_value.h"
#include "json_spirit/json_spirit_reader.h"
-#define DOUT_SUBSYS osd
+#define dout_subsys ceph_subsys_osd
#define DOUT_PREFIX_ARGS this, osd->whoami, get_osdmap()
#undef dout_prefix
#define dout_prefix _prefix(_dout, this, osd->whoami, get_osdmap())
diff --git a/src/osdc/Filer.cc b/src/osdc/Filer.cc
index d29fb656292..b10dc74e419 100644
--- a/src/osdc/Filer.cc
+++ b/src/osdc/Filer.cc
@@ -26,7 +26,7 @@
#include "common/config.h"
-#define DOUT_SUBSYS filer
+#define dout_subsys ceph_subsys_filer
#undef dout_prefix
#define dout_prefix *_dout << objecter->messenger->get_myname() << ".filer "
diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc
index 35a6a232cbc..57b70ce6a30 100644
--- a/src/osdc/Journaler.cc
+++ b/src/osdc/Journaler.cc
@@ -19,7 +19,7 @@
#include "osdc/Journaler.h"
#include "common/errno.h"
-#define DOUT_SUBSYS journaler
+#define dout_subsys ceph_subsys_journaler
#undef dout_prefix
#define dout_prefix *_dout << objecter->messenger->get_myname() << ".journaler" << (readonly ? "(ro) ":"(rw) ")
diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc
index 1dc4c869a18..e4e6d3e8582 100644
--- a/src/osdc/ObjectCacher.cc
+++ b/src/osdc/ObjectCacher.cc
@@ -12,7 +12,7 @@
/*** ObjectCacher::Object ***/
-#define DOUT_SUBSYS objectcacher
+#define dout_subsys ceph_subsys_objectcacher
#undef dout_prefix
#define dout_prefix *_dout << oc->objecter->messenger->get_myname() << ".objectcacher.object(" << oid << ") "
diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc
index 0caa2ba453b..f9644dab1a6 100644
--- a/src/osdc/Objecter.cc
+++ b/src/osdc/Objecter.cc
@@ -41,7 +41,7 @@
#include "common/perf_counters.h"
-#define DOUT_SUBSYS objecter
+#define dout_subsys ceph_subsys_objecter
#undef dout_prefix
#define dout_prefix *_dout << messenger->get_myname() << ".objecter "
diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc
index 3e73b08959d..b5db66a3558 100644
--- a/src/rgw/librgw.cc
+++ b/src/rgw/librgw.cc
@@ -25,7 +25,7 @@
#include <sstream>
#include <string.h>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
int librgw_create(librgw_t *rgw, const char * const id)
{
diff --git a/src/rgw/rgw_acl.cc b/src/rgw/rgw_acl.cc
index 02b2ac04d13..9edb5e67b7d 100644
--- a/src/rgw/rgw_acl.cc
+++ b/src/rgw/rgw_acl.cc
@@ -12,7 +12,7 @@
#include "rgw_acl_s3.h" // required for backward compatibility
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_acl_s3.cc b/src/rgw/rgw_acl_s3.cc
index abbfd12e321..5483322e082 100644
--- a/src/rgw/rgw_acl_s3.cc
+++ b/src/rgw/rgw_acl_s3.cc
@@ -8,7 +8,7 @@
#include "rgw_acl_s3.h"
#include "rgw_user.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_acl_swift.cc b/src/rgw/rgw_acl_swift.cc
index 8123b2cf6ff..73be02b6ce6 100644
--- a/src/rgw/rgw_acl_swift.cc
+++ b/src/rgw/rgw_acl_swift.cc
@@ -7,6 +7,8 @@
#include "rgw_user.h"
#include "rgw_acl_swift.h"
+#define dout_subsys ceph_subsys_rgw
+
using namespace std;
#define SWIFT_PERM_READ RGW_PERM_READ_OBJS
diff --git a/src/rgw/rgw_aclparser.cc b/src/rgw/rgw_aclparser.cc
index 7ac400f05d5..8eb2a5eb28d 100644
--- a/src/rgw/rgw_aclparser.cc
+++ b/src/rgw/rgw_aclparser.cc
@@ -7,7 +7,7 @@
#include <iostream>
#include <map>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
int main(int argc, char **argv) {
RGWACLXMLParser parser;
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index 0be7f9ddc84..ff72353ec5e 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -21,7 +21,7 @@ using namespace std;
#include "rgw_formats.h"
#include "auth/Crypto.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
#define SECRET_KEY_LEN 40
#define PUBLIC_ID_LEN 20
diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc
index 019b38afd8c..644914b356e 100644
--- a/src/rgw/rgw_cache.cc
+++ b/src/rgw/rgw_cache.cc
@@ -2,7 +2,7 @@
#include <errno.h>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h
index 36e4105cbd5..6f32759df24 100644
--- a/src/rgw/rgw_cache.h
+++ b/src/rgw/rgw_cache.h
@@ -17,6 +17,8 @@ enum {
#define CACHE_FLAG_META 0x4
#define CACHE_FLAG_MODIFY_XATTRS 0x8
+#define mydout(v) lsubdout(T::cct, rgw, v)
+
struct ObjectMetaInfo {
uint64_t size;
time_t mtime;
@@ -290,7 +292,7 @@ int RGWCache<T>::set_attr(void *ctx, rgw_obj& obj, const char *attr_name, buffer
cache.put(name, info);
int r = distribute(obj, info, UPDATE_OBJ);
if (r < 0)
- ldout(T::cct, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
+ mydout(0) << "ERROR: failed to distribute cache for " << obj << dendl;
} else {
cache.remove(name);
}
@@ -324,7 +326,7 @@ int RGWCache<T>::set_attrs(void *ctx, rgw_obj& obj,
cache.put(name, info);
int r = distribute(obj, info, UPDATE_OBJ);
if (r < 0)
- ldout(T::cct, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
+ mydout(0) << "ERROR: failed to distribute cache for " << obj << dendl;
} else {
cache.remove(name);
}
@@ -360,7 +362,7 @@ int RGWCache<T>::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mt
cache.put(name, info);
int r = distribute(obj, info, UPDATE_OBJ);
if (r < 0)
- ldout(T::cct, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
+ mydout(0) << "ERROR: failed to distribute cache for " << obj << dendl;
} else {
cache.remove(name);
}
@@ -395,7 +397,7 @@ int RGWCache<T>::put_obj_data(void *ctx, rgw_obj& obj, const char *data,
cache.put(name, info);
int r = distribute(obj, info, UPDATE_OBJ);
if (r < 0)
- ldout(T::cct, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
+ mydout(0) << "ERROR: failed to distribute cache for " << obj << dendl;
} else {
cache.remove(name);
}
@@ -475,10 +477,10 @@ int RGWCache<T>::watch_cb(int opcode, uint64_t ver, bufferlist& bl)
bufferlist::iterator iter = bl.begin();
::decode(info, iter);
} catch (buffer::end_of_buffer& err) {
- ldout(T::cct, 0) << "ERROR: got bad notification" << dendl;
+ mydout(0) << "ERROR: got bad notification" << dendl;
return -EIO;
} catch (buffer::error& err) {
- ldout(T::cct, 0) << "ERROR: buffer::error" << dendl;
+ mydout(0) << "ERROR: buffer::error" << dendl;
return -EIO;
}
@@ -492,7 +494,7 @@ int RGWCache<T>::watch_cb(int opcode, uint64_t ver, bufferlist& bl)
cache.remove(name);
break;
default:
- ldout(T::cct, 0) << "WARNING: got unknown notification op: " << info.op << dendl;
+ mydout(0) << "WARNING: got unknown notification op: " << info.op << dendl;
return -EINVAL;
}
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc
index ce1247c506f..f012b2b107d 100644
--- a/src/rgw/rgw_common.cc
+++ b/src/rgw/rgw_common.cc
@@ -13,7 +13,7 @@
#include <sstream>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
PerfCounters *perfcounter = NULL;
diff --git a/src/rgw/rgw_env.cc b/src/rgw/rgw_env.cc
index c913541af11..5b782c4358c 100644
--- a/src/rgw/rgw_env.cc
+++ b/src/rgw/rgw_env.cc
@@ -4,7 +4,7 @@
#include <string>
#include <map>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
RGWEnv::RGWEnv()
{
diff --git a/src/rgw/rgw_formats.cc b/src/rgw/rgw_formats.cc
index 94cd335b59b..6153ec0c4bb 100644
--- a/src/rgw/rgw_formats.cc
+++ b/src/rgw/rgw_formats.cc
@@ -19,7 +19,7 @@
#define LARGE_SIZE 8192
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
RGWFormatter_Plain::RGWFormatter_Plain()
: buf(NULL), len(0), max_len(0), min_stack_level(0)
diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc
index 1f049eeb37c..27f0a921dd8 100644
--- a/src/rgw/rgw_log.cc
+++ b/src/rgw/rgw_log.cc
@@ -5,7 +5,7 @@
#include "rgw_acl.h"
#include "rgw_rados.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
{
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc
index a479343c2f5..7781690479b 100644
--- a/src/rgw/rgw_main.cc
+++ b/src/rgw/rgw_main.cc
@@ -43,7 +43,7 @@
#include "include/types.h"
#include "common/BackTrace.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
@@ -353,6 +353,9 @@ int main(int argc, const char **argv)
cerr << "radosgw: must specify 'rgw socket path' to run as a daemon" << std::endl;
exit(1);
}
+
+ g_ceph_context->_log->stop();
+
childpid = fork();
if (childpid) {
// i am the parent
@@ -368,6 +371,8 @@ int main(int argc, const char **argv)
if (r < 0) {
dout(0) << "weird, i couldn't chdir to '" << g_conf->chdir << "'" << dendl;
}
+
+ g_ceph_context->_log->start();
}
Mutex mutex("main");
SafeTimer init_timer(g_ceph_context, mutex);
diff --git a/src/rgw/rgw_multi.cc b/src/rgw/rgw_multi.cc
index 44d6ad41354..8c592d3b635 100644
--- a/src/rgw/rgw_multi.cc
+++ b/src/rgw/rgw_multi.cc
@@ -8,7 +8,7 @@
#include "rgw_xml.h"
#include "rgw_multi.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_multiparser.cc b/src/rgw/rgw_multiparser.cc
index 12e12f039d0..58e8751cc7e 100644
--- a/src/rgw/rgw_multiparser.cc
+++ b/src/rgw/rgw_multiparser.cc
@@ -7,7 +7,7 @@
#include "rgw_multi.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index 577bcba077a..adce22cab49 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -24,7 +24,7 @@
# include "fcgiapp.h"
#endif
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
using ceph::crypto::MD5;
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 3308f6341bf..a66f5521190 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -26,7 +26,7 @@ using namespace librados;
#include "rgw_log.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
@@ -355,7 +355,7 @@ static void get_obj_bucket_and_oid_key(rgw_obj& obj, rgw_bucket& bucket, string&
}
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
{
diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index 85e71467d80..1906b811314 100644
--- a/src/rgw/rgw_rest.cc
+++ b/src/rgw/rgw_rest.cc
@@ -19,8 +19,7 @@
# include "fcgiapp.h"
#endif
-
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
static void dump_status(struct req_state *s, const char *status)
{
diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index 0757e5f3589..9fbaafc2c6c 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -16,7 +16,7 @@
# include "fcgiapp.h"
#endif
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace ceph::crypto;
diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc
index 29c4da2e9aa..b84d55f3b69 100644
--- a/src/rgw/rgw_rest_swift.cc
+++ b/src/rgw/rgw_rest_swift.cc
@@ -12,7 +12,7 @@
#include <sstream>
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
int RGWListBuckets_REST_SWIFT::get_params()
{
diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc
index 4e4f6b9a29b..8e77768fcdc 100644
--- a/src/rgw/rgw_swift.cc
+++ b/src/rgw/rgw_swift.cc
@@ -10,7 +10,7 @@
#include "rgw_swift_auth.h"
#include "rgw_user.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
static size_t read_http_header(void *ptr, size_t size, size_t nmemb, void *_info)
{
diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc
index a3f8f0a839d..56498617741 100644
--- a/src/rgw/rgw_swift_auth.cc
+++ b/src/rgw/rgw_swift_auth.cc
@@ -12,7 +12,7 @@
# include "fcgiapp.h"
#endif
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
#define DEFAULT_SWIFT_PREFIX "swift"
diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc
index 93e6b4751ba..6778d548b67 100644
--- a/src/rgw/rgw_tools.cc
+++ b/src/rgw/rgw_tools.cc
@@ -8,7 +8,7 @@
#include "rgw_rados.h"
#include "rgw_tools.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
#define READ_CHUNK_LEN (16 * 1024)
diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc
index 230be99956e..0735bd59aaa 100644
--- a/src/rgw/rgw_user.cc
+++ b/src/rgw/rgw_user.cc
@@ -10,7 +10,7 @@
#include "include/types.h"
#include "rgw_user.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/rgw/rgw_xml.cc b/src/rgw/rgw_xml.cc
index c27e8cfab60..2cd55dc8d04 100644
--- a/src/rgw/rgw_xml.cc
+++ b/src/rgw/rgw_xml.cc
@@ -8,7 +8,7 @@
#include "rgw_common.h"
#include "rgw_xml.h"
-#define DOUT_SUBSYS rgw
+#define dout_subsys ceph_subsys_rgw
using namespace std;
diff --git a/src/test/TestDoutStreambuf.cc b/src/test/TestDoutStreambuf.cc
deleted file mode 100644
index fa1693fe8d0..00000000000
--- a/src/test/TestDoutStreambuf.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// -*- 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) 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.
- *
- */
-
-/*
- * TestDoutStreambuf
- *
- * Puts some output into the DoutStreambuf class.
- * Check your syslog to see what it did.
- */
-#include "common/DoutStreambuf.h"
-#include "common/ceph_argparse.h"
-#include "common/config.h"
-#include "common/debug.h"
-#include "global/global_context.h"
-#include "global/global_init.h"
-
-#include <iostream>
-#include <set>
-#include <sstream>
-#include <string>
-#include <syslog.h>
-
-using std::string;
-
-int main(int argc, const char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, argv, args);
- env_to_vec(args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- DoutStreambuf<char> *dos = new DoutStreambuf<char>();
-
- {
- std::set <std::string> changed;
- for (const char** t = dos->get_tracked_conf_keys(); *t; ++t) {
- changed.insert(*t);
- }
- DoutLocker _dout_locker;
- dos->handle_conf_change(g_conf, changed);
- }
- derr << "using configuration: " << dos->config_to_str() << dendl;
-
- std::ostream oss(dos);
- syslog(LOG_USER | LOG_NOTICE, "TestDoutStreambuf: starting test\n");
-
- dos->set_prio(1);
- oss << "1. I am logging to dout now!" << std::endl;
-
- dos->set_prio(2);
- oss << "2. And here is another line!" << std::endl;
-
- oss.flush();
-
- dos->set_prio(3);
- oss << "3. And here is another line!" << std::endl;
-
- dos->set_prio(16);
- oss << "4. Stuff ";
- oss << "that ";
- oss << "will ";
- oss << "all ";
- oss << "be ";
- oss << "on ";
- oss << "one ";
- oss << "line.\n";
- oss.flush();
-
- dos->set_prio(10);
- oss << "5. There will be no blank lines here.\n" << std::endl;
- oss.flush();
- oss.flush();
- oss.flush();
-
- syslog(LOG_USER | LOG_NOTICE, "TestDoutStreambuf: ending test\n");
-
- return 0;
-}
diff --git a/src/test/TestSignalHandlers.cc b/src/test/TestSignalHandlers.cc
index f9ea6749dfe..ae0bc2ae3e3 100644
--- a/src/test/TestSignalHandlers.cc
+++ b/src/test/TestSignalHandlers.cc
@@ -17,7 +17,6 @@
*
* Test the Ceph signal handlers
*/
-#include "common/DoutStreambuf.h"
#include "common/ceph_argparse.h"
#include "global/global_init.h"
#include "common/errno.h"
@@ -39,7 +38,7 @@ static int* get_null()
static void simple_segv_test()
{
- dout(-1) << "triggering SIGSEGV..." << dendl;
+ generic_dout(-1) << "triggering SIGSEGV..." << dendl;
int i = *get_null();
std::cout << "i = " << i << std::endl;
}
@@ -51,7 +50,7 @@ static void infinite_recursion_test_impl()
static void infinite_recursion_test()
{
- dout(0) << "triggering SIGSEGV with infinite recursion..." << dendl;
+ generic_dout(0) << "triggering SIGSEGV with infinite recursion..." << dendl;
infinite_recursion_test_impl();
}
diff --git a/src/test/daemon_config.cc b/src/test/daemon_config.cc
index 6a09e094391..e85de9485d9 100644
--- a/src/test/daemon_config.cc
+++ b/src/test/daemon_config.cc
@@ -27,13 +27,13 @@ using std::string;
TEST(DaemonConfig, SimpleSet) {
int ret;
- ret = g_ceph_context->_conf->set_val("debug", "21");
+ ret = g_ceph_context->_conf->set_val("num_client", "21");
ASSERT_EQ(ret, 0);
g_ceph_context->_conf->apply_changes(NULL);
char buf[128];
memset(buf, 0, sizeof(buf));
char *tmp = buf;
- ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("21"), string(buf));
}
@@ -43,7 +43,7 @@ TEST(DaemonConfig, ArgV) {
"false"));
int ret;
- const char *argv[] = { "foo", "--debug", "22",
+ const char *argv[] = { "foo", "--num-client", "22",
"--keyfile", "/tmp/my-keyfile", NULL };
size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1;
vector<const char*> args;
@@ -59,7 +59,7 @@ TEST(DaemonConfig, ArgV) {
ASSERT_EQ(string("/tmp/my-keyfile"), string(buf));
memset(buf, 0, sizeof(buf));
- ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("22"), string(buf));
@@ -69,27 +69,26 @@ TEST(DaemonConfig, ArgV) {
TEST(DaemonConfig, InjectArgs) {
int ret;
- std::ostringstream chat;
- std::string injection("--debug 56 --debug-mds 42");
- ret = g_ceph_context->_conf->injectargs(injection, &chat);
+ std::string injection("--num-client 56 --max-open-files 42");
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
char buf[128];
char *tmp = buf;
memset(buf, 0, sizeof(buf));
- ret = g_ceph_context->_conf->get_val("debug_mds", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("max_open_files", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("42"), string(buf));
memset(buf, 0, sizeof(buf));
- ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("56"), string(buf));
- injection = "--debug 57";
- ret = g_ceph_context->_conf->injectargs(injection, &chat);
+ injection = "--num-client 57";
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
- ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("57"), string(buf));
}
@@ -102,14 +101,13 @@ TEST(DaemonConfig, InjectArgsReject) {
char *tmp2 = buf2;
// We should complain about the garbage in the input
- std::ostringstream chat;
- std::string injection("--random-garbage-in-injectargs 26 --debug 28");
- ret = g_ceph_context->_conf->injectargs(injection, &chat);
+ std::string injection("--random-garbage-in-injectargs 26 --num-client 28");
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, -EINVAL);
// But, debug should still be set...
memset(buf, 0, sizeof(buf));
- ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("28"), string(buf));
@@ -120,8 +118,8 @@ TEST(DaemonConfig, InjectArgsReject) {
// Injectargs shouldn't let us change this, since it is a string-valued
// variable and there isn't an observer for it.
- std::string injection2("--osd_data /tmp/some-other-directory --debug 4");
- ret = g_ceph_context->_conf->injectargs(injection2, &chat);
+ std::string injection2("--osd_data /tmp/some-other-directory --num-client 4");
+ ret = g_ceph_context->_conf->injectargs(injection2, &cout);
ASSERT_EQ(ret, -ENOSYS);
// It should be unchanged.
@@ -137,9 +135,8 @@ TEST(DaemonConfig, InjectArgsBooleans) {
char *tmp = buf;
// Change log_to_syslog
- std::ostringstream chat;
- std::string injection("--log_to_syslog --debug 28");
- ret = g_ceph_context->_conf->injectargs(injection, &chat);
+ std::string injection("--log_to_syslog --num-client 28");
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
// log_to_syslog should be set...
@@ -149,9 +146,8 @@ TEST(DaemonConfig, InjectArgsBooleans) {
ASSERT_EQ(string("true"), string(buf));
// Turn off log_to_syslog
- std::ostringstream chat2;
- injection = "--log_to_syslog=false --debug 28";
- ret = g_ceph_context->_conf->injectargs(injection, &chat2);
+ injection = "--log_to_syslog=false --num-client 28";
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
// log_to_syslog should be cleared...
@@ -161,9 +157,8 @@ TEST(DaemonConfig, InjectArgsBooleans) {
ASSERT_EQ(string("false"), string(buf));
// Turn on log_to_syslog
- std::ostringstream chat3;
- injection = "--debug 1 --log_to_syslog=true --debug-ms 40";
- ret = g_ceph_context->_conf->injectargs(injection, &chat3);
+ injection = "--num-client 1 --log_to_syslog=true --max-open-files 40";
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
// log_to_syslog should be set...
@@ -173,9 +168,8 @@ TEST(DaemonConfig, InjectArgsBooleans) {
ASSERT_EQ(string("true"), string(buf));
// parse error
- std::ostringstream chat4;
- injection = "--debug 1 --log_to_syslog=falsey --debug-ms 42";
- ret = g_ceph_context->_conf->injectargs(injection, &chat3);
+ injection = "--num-client 1 --log_to_syslog=falsey --max-open-files 42";
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, -EINVAL);
// log_to_syslog should still be set...
@@ -186,14 +180,13 @@ TEST(DaemonConfig, InjectArgsBooleans) {
// debug-ms should still become 42...
memset(buf, 0, sizeof(buf));
- ret = g_ceph_context->_conf->get_val("debug_ms", &tmp, sizeof(buf));
+ ret = g_ceph_context->_conf->get_val("max_open_files", &tmp, sizeof(buf));
ASSERT_EQ(ret, 0);
ASSERT_EQ(string("42"), string(buf));
}
TEST(DaemonConfig, InjectArgsLogfile) {
int ret;
- std::ostringstream chat;
char tmpfile[PATH_MAX];
const char *tmpdir = getenv("TMPDIR");
if (!tmpdir)
@@ -203,7 +196,7 @@ TEST(DaemonConfig, InjectArgsLogfile) {
std::string injection("--log_file ");
injection += tmpfile;
// We're allowed to change log_file because there is an observer.
- ret = g_ceph_context->_conf->injectargs(injection, &chat);
+ ret = g_ceph_context->_conf->injectargs(injection, &cout);
ASSERT_EQ(ret, 0);
// It should have taken effect.
diff --git a/src/test_trans.cc b/src/test_trans.cc
index 170927c1408..6c3d2d65695 100644
--- a/src/test_trans.cc
+++ b/src/test_trans.cc
@@ -18,6 +18,7 @@
#include "os/FileStore.h"
#include "global/global_init.h"
+#define dout_subsys ceph_subsys_filestore
#undef dout_prefix
#define dout_prefix *_dout
diff --git a/src/testcrypto.cc b/src/testcrypto.cc
index 85195e4ec7c..3237f3c8b83 100644
--- a/src/testcrypto.cc
+++ b/src/testcrypto.cc
@@ -4,6 +4,7 @@
#include "common/config.h"
#include "common/debug.h"
+#define dout_subsys ceph_subsys_auth
#define AES_KEY_LEN 16
diff --git a/src/testkeys.cc b/src/testkeys.cc
index 239956be926..c120921a3cf 100644
--- a/src/testkeys.cc
+++ b/src/testkeys.cc
@@ -16,7 +16,7 @@ int main(int argc, const char **argv)
KeyServer server(g_ceph_context);
- dout(0) << "server created" << dendl;
+ generic_dout(0) << "server created" << dendl;
getchar();
diff --git a/src/testmsgr.cc b/src/testmsgr.cc
index badad96f5b6..a2b13170ff4 100644
--- a/src/testmsgr.cc
+++ b/src/testmsgr.cc
@@ -36,6 +36,7 @@ using namespace std;
#include <sys/stat.h>
#include <fcntl.h>
+#define dout_subsys ceph_subsys_ms
Messenger *messenger = 0;
diff --git a/src/tools/common.cc b/src/tools/common.cc
index 3ee2ded7e46..2bdc6999ebb 100644
--- a/src/tools/common.cc
+++ b/src/tools/common.cc
@@ -45,6 +45,8 @@ extern "C" {
#include <histedit.h>
}
+#define dout_subsys ceph_subsys_
+
// TODO: should move these into CephToolCtx for consistency
static enum ceph_tool_mode_t
ceph_tool_mode(CEPH_TOOL_MODE_CLI_INPUT);
diff --git a/src/vstart.sh b/src/vstart.sh
index d5292f46184..cddb7ebad04 100755
--- a/src/vstart.sh
+++ b/src/vstart.sh
@@ -198,7 +198,6 @@ $SUDO rm -f core*
test -d out || mkdir out
$SUDO rm -rf out/*
-test -d log && rm -f log/*
test -d gmon && $SUDO rm -rf gmon/*
[ "$cephx" -eq 1 ] && test -e $keyring_fn && rm $keyring_fn
@@ -246,9 +245,7 @@ do
done
DAEMONOPTS="
- log file = out/\$host
- log per instance = true
- log sym history = 100
+ log file = out/\$name.log
admin socket = out/\$name.asok
chdir = \"\"
pid file = out/\$name.pid