]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
logging: Replace derr with dout
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 6 Dec 2010 22:30:57 +0000 (14:30 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 6 Dec 2010 23:38:14 +0000 (15:38 -0800)
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 <colinm@hq.newdream.net>
17 files changed:
src/auth/Crypto.cc
src/auth/ExportControl.cc
src/auth/cephx/CephxClientHandler.cc
src/client/SyntheticClient.cc
src/common/Thread.h
src/common/debug.cc
src/common/debug.h
src/cosd.cc
src/mon/MonitorStore.cc
src/msg/SimpleMessenger.cc
src/os/FileJournal.cc
src/os/FileStore.cc
src/osd/OSD.cc
src/osd/OSDMap.cc
src/osd/ReplicatedPG.cc
src/osdc/Journaler.cc
src/testcrypto.cc

index 26b7b5ccc616719bd5fdc25d38256ee25427804b..0a732e6bd0de3c5c1f6c3da4908796ad00209f18 100644 (file)
@@ -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;
   }
 
index 7339060c0b48dc98f2610781d5952f14e0e195fe..0c3790b46d3ff06948a6939d437677ccb89ad665 100644 (file)
@@ -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, ", ");
                }
index 098a9ddb1a61cdc6bcdd9bc1429598bf5666251a..087f371908b85e0d20cc133278cb19e5581f2cf8 100644 (file)
@@ -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;
        }
       }
     }
index 97c228c479d01c11accb03d8954eaac2843cd2d0..3786887681a71794a0e95e4c03a2bcfbf5b3a71c 100644 (file)
@@ -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;
 }
 
index a567d2dbac4c33c9065ff67df79b6c3f3c335ff9..e7da795dbddf1e956ac822e648ed0d4a741adace 100644 (file)
@@ -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.
     }
index 86def0548a14b9e583b4f72ebc03c999f0fb2751..c5e47fe69a4d1ded7cb178740e0e33e64899f5a1 100644 (file)
@@ -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};
index 7b60c38abe885f9a2f288abee7e44d51f9b2565c..f75537b4f1233eff9f329e840308b2cf2305cec1 100644 (file)
@@ -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)
 
index 7e77799de00f0690782443958e848f097b3348d7..e60c6e3eb83be7c48ebc3fb76cfba86057aa61b5 100644 (file)
@@ -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) {
index 17ca16f2d1df5fd27b23c9f20bb8b4a50fabcee9..53000c90ba6f04f08a9ebd5be2e06040e7f64d91 100644 (file)
@@ -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;
index 8d160f8e2cad90f2f2878f57d262fa699dc34637..f1b0aefbd9fde4ea9bae09d7118c76b0b011e23f 100644 (file)
@@ -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();
       }
index 3bb38a887ad1694c8fb004e0074574b3715f0798..4ab7f7c7b8f7daba40ab80c7eaf7a41a20bc4a57 100644 (file)
@@ -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();
index 840564d2a9bb89bed69e4ecd9fa11eba2d55868d..68c98690420aef9e4c4fe41271885a77696636fe 100644 (file)
@@ -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;
   }
index dbdb0481aa51a5462f4a3d3810ddd47f40f9cdc5..7386c04c6e66c5b3e20f13fd905fe7f5ef552a52 100644 (file)
@@ -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++;
     }
   }
index 33a6dac4424eac93855b3803c608648154a8c8d7..c50135b7f2e718ba1cc89fcf2018f01c5d05041d 100644 (file)
@@ -168,7 +168,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
     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; i<ndom; i++) {
index 1755427487add832af6c20337a8be214ffca38f2..b92293ac7ca3b364568dd42cde94d44d0bbe705e 100644 (file)
@@ -2597,7 +2597,7 @@ void ReplicatedPG::sub_op_modify(MOSDSubOp *op)
   Context *onapply = new C_OSD_RepModifyApply(rm);
   int r = osd->store->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++;
       }
index af12e382fb4e04b2dc9f3b25a4bc15471c0043fa..54aff6c7c22de5c21b7fa49354aeba5ed748e8e5 100644 (file)
@@ -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;
   }
index 020d3cd034381efd255da96fb1f4f2058119a402..1ec784aaa85c84b6f7979da3741f313218d357f9 100644 (file)
@@ -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;