]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: Make log_max_recent have an effect again. 46736/head
authorJoshua Baergen <jbaergen@digitalocean.com>
Thu, 16 Jun 2022 16:14:12 +0000 (10:14 -0600)
committerJoshua Baergen <jbaergen@digitalocean.com>
Wed, 29 Jun 2022 13:41:34 +0000 (07:41 -0600)
The log improvements in a747aeac13daf3dba43343120659e802cb569f6b
unfortunately left log_max_recent broken because m_max_recent wasn't
used anymore.

Eliminate m_max_recent and set the capacity of the m_recent ring buffer
when log_max_recent changes. In order to call set_capacity(),
ConcreteEntry needed its move constructor set noexcept.

I haven't followed the boost code all the way down but I suspect that
setting the ring buffer capacity to anything less than 1 entry will
probably cause problems, so restrict log_max_recent to >=1.

Also fix a wrong variable used for printing the max new entries during
"log dump".

Signed-off-by: Joshua Baergen <jbaergen@digitalocean.com>
src/common/options/global.yaml.in
src/log/Entry.h
src/log/Log.cc
src/log/Log.h

index e335c736d6745283ccab9524899631a80152370d..00eb445acda7358ce753ff800bbe86a17ae5d10c 100644 (file)
@@ -473,6 +473,7 @@ options:
     to the log.  For example, debug_osd=1/5 will write everything <= 1 to the log
     unconditionally but keep entries at levels 2-5 in memory.  If there is a seg fault
     or assertion failure, all entries will be dumped to the log.
+  min: 1
   default: 500
   daemon_default: 10000
   # default changed by common_preinit()
index 536f1a9dc8a223956c3450545484794eb739b154..3677c8eb9518040644ae3b95ed253561e23fc78a 100644 (file)
@@ -90,7 +90,7 @@ public:
     str.assign(strv.begin(), strv.end());
     return *this;
   }
-  ConcreteEntry(ConcreteEntry&& e) : Entry(e), str(std::move(e.str)) {}
+  ConcreteEntry(ConcreteEntry&& e) noexcept : Entry(e), str(std::move(e.str)) {}
   ConcreteEntry& operator=(ConcreteEntry&& e) {
     Entry::operator=(e);
     str = std::move(e.str);
index 81fb3ff5cc4033aadb803e0700c56e1cb66b1cc5..2728bbfbde745744a4286ce27b3d84a1c9a831af 100644 (file)
@@ -93,7 +93,7 @@ void Log::set_max_new(std::size_t n)
 void Log::set_max_recent(std::size_t n)
 {
   std::scoped_lock lock(m_flush_mutex);
-  m_max_recent = n;
+  m_recent.set_capacity(n);
 }
 
 void Log::set_log_file(std::string_view fn)
@@ -420,8 +420,8 @@ void Log::dump_recent()
                             tid_to_int(pthread_id), pthread_name), true);
   }
 
-  _log_message(fmt::format("  max_recent {:9}", m_max_recent), true);
-  _log_message(fmt::format("  max_new    {:9}", m_max_recent), true);
+  _log_message(fmt::format("  max_recent {:9}", m_recent.capacity()), true);
+  _log_message(fmt::format("  max_new    {:9}", m_max_new), true);
   _log_message(fmt::format("  log_file {}", m_log_file), true);
 
   _log_message("--- end dump of recent events ---", true);
index 0d83ff037f75ccbdcfe6074eab89cc6b567bcbae..670c31217158e12dd16a88dbdfe2dbfeeb285185 100644 (file)
@@ -73,7 +73,6 @@ class Log : private Thread
   bool m_stop = false;
 
   std::size_t m_max_new = DEFAULT_MAX_NEW;
-  std::size_t m_max_recent = DEFAULT_MAX_RECENT;
 
   bool m_inject_segv = false;