From 9811fbd0475b0a16868a054e88ef5066e53658b2 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Mon, 6 Dec 2010 14:30:57 -0800 Subject: [PATCH] logging: Replace derr with dout derr was really just an alias for STDERR. Unfortunately, after we call daemonize, STDERR is connected to /dev/null. So just replace calls to derr with dout so that our important messages don't get lost. Signed-off-by: Colin McCabe --- src/auth/Crypto.cc | 2 +- src/auth/ExportControl.cc | 2 +- src/auth/cephx/CephxClientHandler.cc | 2 +- src/client/SyntheticClient.cc | 3 +-- src/common/Thread.h | 12 ++++++------ src/common/debug.cc | 1 - src/common/debug.h | 8 -------- src/cosd.cc | 2 +- src/mon/MonitorStore.cc | 6 +++--- src/msg/SimpleMessenger.cc | 16 ++++++++-------- src/os/FileJournal.cc | 6 +++--- src/os/FileStore.cc | 12 ++++++------ src/osd/OSD.cc | 4 ++-- src/osd/OSDMap.cc | 2 +- src/osd/ReplicatedPG.cc | 4 ++-- src/osdc/Journaler.cc | 2 +- src/testcrypto.cc | 4 ++-- 17 files changed, 39 insertions(+), 49 deletions(-) diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index 26b7b5ccc6167..0a732e6bd0de3 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -141,7 +141,7 @@ int CryptoAES::encrypt(bufferptr& secret, const bufferlist& in, bufferlist& out) unsigned char outbuf[max_out + OUT_BUF_EXTRA]; if (secret.length() < AES_KEY_LEN) { - derr(0) << "key is too short" << dendl; + dout(0) << "key is too short" << dendl; return false; } diff --git a/src/auth/ExportControl.cc b/src/auth/ExportControl.cc index 7339060c0b48d..0c3790b46d3ff 100644 --- a/src/auth/ExportControl.cc +++ b/src/auth/ExportControl.cc @@ -388,7 +388,7 @@ void GroupEntry::init(ConfFile *cf, const char *section, const char *options) } else if (strcmp(op, "ro") == 0) { set_readonly(true); } else { - derr(0) << "Error: unknown option '" << op << "'" << dendl; + dout(0) << "Error: unknown option '" << op << "'" << dendl; } op = strsep(&tmp, ", "); } diff --git a/src/auth/cephx/CephxClientHandler.cc b/src/auth/cephx/CephxClientHandler.cc index 098a9ddb1a61c..087f371908b85 100644 --- a/src/auth/cephx/CephxClientHandler.cc +++ b/src/auth/cephx/CephxClientHandler.cc @@ -151,7 +151,7 @@ int CephxClientHandler::handle_response(int ret, bufferlist::iterator& indata) if (decode_decrypt(secrets, secret_key, indata) == 0) { rotating_secrets->set_secrets(secrets); } else { - derr(0) << "could not set rotating key: decode_decrypt failed" << dendl; + dout(0) << "could not set rotating key: decode_decrypt failed" << dendl; } } } diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 97c228c479d01..3786887681a71 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1614,7 +1614,7 @@ int SyntheticClient::dump_placement(string& fn) { struct stat stbuf; int lstat_result = client->lstat(fn.c_str(), &stbuf); if (lstat_result < 0) { - derr(0) << "lstat error for file " << fn << dendl; + dout(0) << "lstat error for file " << fn << dendl; return lstat_result; } @@ -2201,7 +2201,6 @@ int SyntheticClient::create_objects(int nobj, int osize, int inflight) lock.Unlock(); dout(5) << "create_objects done" << dendl; - derr(0) << "create_objects done" << dendl; return 0; } diff --git a/src/common/Thread.h b/src/common/Thread.h index a567d2dbac4c3..e7da795dbddf1 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -75,7 +75,7 @@ class Thread { if (r) { char buf[80]; - generic_derr(0) << "pthread_create failed with message: " << strerror_r(r, buf, sizeof(buf)) << dendl; + generic_dout(0) << "pthread_create failed with message: " << strerror_r(r, buf, sizeof(buf)) << dendl; } else { _num_threads.inc(); generic_dout(10) << "thread " << thread_id << " start" << dendl; @@ -84,7 +84,7 @@ class Thread { } int join(void **prval = 0) { if (thread_id == 0) { - generic_derr(0) << "WARNING: join on thread that was never started" << dendl; + generic_dout(0) << "WARNING: join on thread that was never started" << dendl; assert(0); return -EINVAL; // never started. } @@ -93,17 +93,17 @@ class Thread { if (status != 0) { switch (status) { case -EINVAL: - generic_derr(0) << "thread " << thread_id << " join status = EINVAL" << dendl; + generic_dout(0) << "thread " << thread_id << " join status = EINVAL" << dendl; break; case -ESRCH: - generic_derr(0) << "thread " << thread_id << " join status = ESRCH" << dendl; + generic_dout(0) << "thread " << thread_id << " join status = ESRCH" << dendl; assert(0); break; case -EDEADLK: - generic_derr(0) << "thread " << thread_id << " join status = EDEADLK" << dendl; + generic_dout(0) << "thread " << thread_id << " join status = EDEADLK" << dendl; break; default: - generic_derr(0) << "thread " << thread_id << " join status = " << status << dendl; + generic_dout(0) << "thread " << thread_id << " join status = " << status << dendl; } assert(0); // none of these should happen. } diff --git a/src/common/debug.cc b/src/common/debug.cc index 86def0548a14b..c5e47fe69a4d1 100644 --- a/src/common/debug.cc +++ b/src/common/debug.cc @@ -18,7 +18,6 @@ using namespace std; // debug output Mutex _dout_lock("_dout_lock", false, false /* no lockdep */); ostream *_dout = &std::cout; -ostream *_derr = &std::cerr; char _dout_dir[PATH_MAX] = {0}; char _dout_symlink_dir[PATH_MAX] = {0}; char _dout_file[PATH_MAX] = {0}; diff --git a/src/common/debug.h b/src/common/debug.h index 7b60c38abe885..f75537b4f1233 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -13,7 +13,6 @@ using std::ostream; // the streams extern ostream *_dout; -extern ostream *_derr; extern Mutex _dout_lock; @@ -22,11 +21,6 @@ extern bool _dout_is_open; extern void _dout_open_log(); -static inline void dout_open_log() { - _dout_lock.Lock(); - _dout_open_log(); - _dout_lock.Unlock(); -} extern int dout_rename_output_file(); // after calling daemon() extern int dout_create_rank_symlink(int64_t n); @@ -76,7 +70,6 @@ inline ostream& operator<<(ostream& out, _bad_endl_use_dendl_t) { // generic macros #define generic_dout(x) do { if ((x) <= g_conf.debug) { *_dout << dbeginl -#define generic_derr(x) do { if ((x) <= g_conf.debug) { *_derr << dbeginl #define pdout(x,p) do { if ((x) <= (p)) { *_dout << dbeginl @@ -87,7 +80,6 @@ inline ostream& operator<<(ostream& out, _bad_endl_use_dendl_t) { #define DOUT_COND(l) l <= XDOUT_CONDVAR(DOUT_SUBSYS) #define dout(l) do { if (DOUT_COND(l)) { dout_prefix -#define derr(l) do { if (DOUT_COND(l)) { dout_prefix #define dendl std::endl; _dout_end_line(); } } while (0) diff --git a/src/cosd.cc b/src/cosd.cc index 7e77799de00f0..e60c6e3eb83be 100644 --- a/src/cosd.cc +++ b/src/cosd.cc @@ -184,7 +184,7 @@ int main(int argc, const char **argv) cerr << TEXT_RED << " ** ERROR: unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror_r(-r, buf, sizeof(buf)) << TEXT_NORMAL << std::endl; if (r == -ENOTSUP) cerr << TEXT_RED << " ** please verify that underlying storage supports xattrs" << TEXT_NORMAL << std::endl; - derr(0) << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror_r(-r, buf, sizeof(buf)) << dendl; + dout(0) << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror_r(-r, buf, sizeof(buf)) << dendl; exit(1); } if (w != whoami) { diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 17ca16f2d1df5..53000c90ba6f0 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -64,7 +64,7 @@ int MonitorStore::mount() // verify dir exists DIR *d = ::opendir(dir.c_str()); if (!d) { - derr(1) << "basedir " << dir << " dne" << dendl; + dout(1) << "basedir " << dir << " dne" << dendl; return -ENOENT; } ::closedir(d); @@ -82,7 +82,7 @@ int MonitorStore::mount() l.l_len = 0; int r = ::fcntl(lock_fd, F_SETLK, &l); if (r < 0) { - derr(0) << "failed to lock " << t << ", is another cmon still running?" << dendl; + dout(0) << "failed to lock " << t << ", is another cmon still running?" << dendl; return -errno; } @@ -245,7 +245,7 @@ int MonitorStore::get_bl_ss(bufferlist& bl, const char *a, const char *b) int r = ::read(fd, bp.c_str()+off, len-off); if (r < 0) { char buf[80]; - derr(0) << "errno on read " << strerror_r(errno, buf, sizeof(buf)) << dendl; + dout(0) << "errno on read " << strerror_r(errno, buf, sizeof(buf)) << dendl; } assert(r>0); off += r; diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index 8d160f8e2cad9..f1b0aefbd9fde 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -66,7 +66,7 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce, entity_addr_t &bind_add listen_sd = ::socket(family, SOCK_STREAM, 0); if (listen_sd < 0) { char buf[80]; - derr(0) << "accepter.bind unable to create socket: " + dout(0) << "accepter.bind unable to create socket: " << strerror_r(errno, buf, sizeof(buf)) << dendl; cerr << "accepter.bind unable to create socket: " << strerror_r(errno, buf, sizeof(buf)) << std::endl; @@ -88,7 +88,7 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce, entity_addr_t &bind_add rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr.ss_addr(), sizeof(listen_addr.ss_addr())); if (rc < 0) { char buf[80]; - derr(0) << "accepter.bind unable to bind to " << bind_addr.ss_addr() + dout(0) << "accepter.bind unable to bind to " << bind_addr.ss_addr() << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl; cerr << "accepter.bind unable to bind to " << bind_addr.ss_addr() << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl; @@ -106,7 +106,7 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce, entity_addr_t &bind_add } if (rc < 0) { char buf[80]; - derr(0) << "accepter.bind unable to bind to " << bind_addr.ss_addr() + dout(0) << "accepter.bind unable to bind to " << bind_addr.ss_addr() << " on any port in range " << CEPH_PORT_START << "-" << CEPH_PORT_LAST << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl; cerr << "accepter.bind unable to bind to " << bind_addr.ss_addr() @@ -127,7 +127,7 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce, entity_addr_t &bind_add rc = ::listen(listen_sd, 128); if (rc < 0) { char buf[80]; - derr(0) << "accepter.bind unable to listen on " << bind_addr.ss_addr() + dout(0) << "accepter.bind unable to listen on " << bind_addr.ss_addr() << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl; cerr << "accepter.bind unable to listen on " << bind_addr.ss_addr() << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl; @@ -1457,7 +1457,7 @@ void SimpleMessenger::Pipe::fault(bool onconnect, bool onread) void SimpleMessenger::Pipe::fail() { - derr(10) << "fail" << dendl; + dout(10) << "fail" << dendl; assert(pipe_lock.is_locked()); stop(); @@ -1720,7 +1720,7 @@ void SimpleMessenger::Pipe::writer() pipe_lock.Lock(); if (rc < 0) { - derr(1) << "writer error sending " << m << ", " + dout(1) << "writer error sending " << m << ", " << errno << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl; fault(); } @@ -2373,7 +2373,7 @@ int SimpleMessenger::start(bool nodaemon) // daemonize? if (g_conf.daemonize && !nodaemon) { if (Thread::get_num_threads() > 0) { - derr(0) << "messenger.start BUG: there are " << Thread::get_num_threads() + dout(0) << "messenger.start BUG: there are " << Thread::get_num_threads() << " already started that will now die! call messenger.start() sooner." << dendl; } @@ -2565,7 +2565,7 @@ void SimpleMessenger::submit_message(Message *m, const entity_addr_t& dest_addr, dout(20) << "submit_message " << *m << " local" << dendl; dispatch_queue.local_delivery(m, m->get_priority()); } else { - derr(0) << "submit_message " << *m << " " << dest_addr << " local but no local endpoint, dropping." << dendl; + dout(0) << "submit_message " << *m << " " << dest_addr << " local but no local endpoint, dropping." << dendl; assert(0); // hmpf, this is probably mds->mon beacon from newsyn. m->put(); } diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 3bb38a887ad16..4ab7f7c7b8f7d 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -321,12 +321,12 @@ int FileJournal::open(uint64_t next_seq) err = -EINVAL; } if (header.alignment != block_size && directio) { - derr(0) << "open journal alignment " << header.alignment << " does not match block size " + dout(0) << "open journal alignment " << header.alignment << " does not match block size " << block_size << " (required for direct_io journal mode)" << dendl; err = -EINVAL; } if ((header.alignment % PAGE_SIZE) && directio) { - derr(0) << "open journal alignment " << header.alignment << " is not multiple of page size " << PAGE_SIZE + dout(0) << "open journal alignment " << header.alignment << " is not multiple of page size " << PAGE_SIZE << " (required for direct_io journal mode)" << dendl; err = -EINVAL; } @@ -631,7 +631,7 @@ void FileJournal::write_bl(off64_t& pos, bufferlist& bl) int err = bl.write_fd(fd); if (err) { char buf[80]; - derr(0) << "write_bl failed with " << err << " " << strerror_r(-err, buf, sizeof(buf)) + dout(0) << "write_bl failed with " << err << " " << strerror_r(-err, buf, sizeof(buf)) << dendl; } pos += bl.length(); diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 840564d2a9bb8..68c98690420ae 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -699,7 +699,7 @@ int FileStore::lock_fsid() int r = ::fcntl(fsid_fd, F_SETLK, &l); if (r < 0) { char buf[80]; - derr(0) << "lock_fsid failed to lock " << basedir << "/fsid, is another cosd still running? " << strerror_r(errno, buf, sizeof(buf)) << dendl; + dout(0) << "lock_fsid failed to lock " << basedir << "/fsid, is another cosd still running? " << strerror_r(errno, buf, sizeof(buf)) << dendl; return -errno; } return 0; @@ -748,7 +748,7 @@ int FileStore::_detect_fs() << " " << strerror(errno) << dendl;*/ if (x != y) { - derr(0) << "xattrs don't appear to work (" << strerror_r(errno, buf, sizeof(buf)) + dout(0) << "xattrs don't appear to work (" << strerror_r(errno, buf, sizeof(buf)) << ") on " << fn << ", be sure to mount underlying file system with 'user_xattr' option" << dendl; return -errno; } @@ -997,7 +997,7 @@ int FileStore::mount() struct stat st; int r = ::stat(basedir.c_str(), &st); if (r != 0) { - derr(0) << "unable to stat basedir " << basedir << ", " << strerror_r(errno, buf, sizeof(buf)) << dendl; + dout(0) << "unable to stat basedir " << basedir << ", " << strerror_r(errno, buf, sizeof(buf)) << dendl; return -errno; } @@ -1539,14 +1539,14 @@ int FileStore::_transaction_start(uint64_t bytes, uint64_t ops) char buf[80]; int fd = ::open(basedir.c_str(), O_RDONLY); if (fd < 0) { - derr(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf)) + dout(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf)) << " from btrfs open" << dendl; assert(0); } int r = ::ioctl(fd, BTRFS_IOC_TRANS_START); if (r < 0) { - derr(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf)) + dout(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf)) << " from btrfs ioctl" << dendl; ::close(fd); return -errno; @@ -1992,7 +1992,7 @@ int FileStore::_write(coll_t cid, const sobject_t& oid, int flags = O_WRONLY|O_CREAT; int fd = ::open(fn, flags, 0644); if (fd < 0) { - derr(0) << "write couldn't open " << fn << " flags " << flags << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl; + dout(0) << "write couldn't open " << fn << " flags " << flags << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl; r = -errno; goto out; } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dbdb0481aa51a..7386c04c6e66c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -787,7 +787,7 @@ int OSD::read_superblock() } if (whoami != superblock.whoami) { - derr(0) << "read_superblock superblock says osd" << superblock.whoami + dout(0) << "read_superblock superblock says osd" << superblock.whoami << ", but i (think i) am osd" << whoami << dendl; return -1; } @@ -4828,7 +4828,7 @@ void OSD::handle_op(MOSDOp *op) if (!op->may_write()) { stat_rd_ops++; if (op->get_source().is_osd()) { - //derr(-10) << "shed in " << stat_rd_ops_shed_in << " / " << stat_rd_ops << dendl; + //dout(-10) << "shed in " << stat_rd_ops_shed_in << " / " << stat_rd_ops << dendl; stat_rd_ops_shed_in++; } } diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 33a6dac4424ea..c50135b7f2e71 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -168,7 +168,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map& int rweights[ndom]; int nper = ((num_osd - 1) / ndom) + 1; - derr(0) << ndom << " failure domains, " << nper << " osds each" << dendl; + dout(0) << ndom << " failure domains, " << nper << " osds each" << dendl; int o = 0; for (int i=0; istore->queue_transactions(&osr, rm->tls, onapply, oncommit); if (r) { - derr(0) << "error applying transaction: r = " << r << dendl; + dout(0) << "error applying transaction: r = " << r << dendl; assert(0); } // op is cleaned up by oncommit/onapply when both are executed @@ -3995,7 +3995,7 @@ int ReplicatedPG::_scrub(ScrubMap& scrubmap, int& errors, int& fixed) // did we finish the last oid? if (head != sobject_t()) { - derr(0) << " missing clone(s) for " << head << dendl; + dout(0) << " missing clone(s) for " << head << dendl; assert(head == sobject_t()); // we had better be done errors++; } diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index af12e382fb4e0..54aff6c7c22de 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -741,7 +741,7 @@ bool Journaler::try_read_entry(bufferlist& bl) << read_pos << "~" << (sizeof(s)+s) << " (have " << read_buf.length() << ")" << dendl; if (s == 0) { - derr(0) << "try_read_entry got 0 len entry at offset " << read_pos << dendl; + dout(0) << "try_read_entry got 0 len entry at offset " << read_pos << dendl; error = -EINVAL; return false; } diff --git a/src/testcrypto.cc b/src/testcrypto.cc index 020d3cd034381..1ec784aaa85c8 100644 --- a/src/testcrypto.cc +++ b/src/testcrypto.cc @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) bufferlist enc_out; if (key.encrypt(enc_in, enc_out) < 0) { - derr(0) << "couldn't encode!" << dendl; + dout(0) << "couldn't encode!" << dendl; exit(1); } @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) dec_in = enc_out; if (key.decrypt(dec_in, dec_out) < 0) { - derr(0) << "couldn't decode!" << dendl; + dout(0) << "couldn't decode!" << dendl; } dout(0) << "decoded len: " << dec_out.length() << dendl; -- 2.39.5