]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
log: Make log_max_recent have an effect again. 48310/head
authorJoshua Baergen <jbaergen@digitalocean.com>
Thu, 16 Jun 2022 16:14:12 +0000 (10:14 -0600)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Tue, 8 Oct 2024 18:46:28 +0000 (01:46 +0700)
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>
(cherry picked from commit 3d59ba1671e3e76326fb706a76b8d9638d782924)

src/common/options/global.yaml.in
src/log/Entry.h
src/log/Log.cc
src/log/Log.h

index a8a00325bde38fe327ccf3f74ccd6d8a4e9a3d3e..07cba961ec08884b3b7afb3522dd756ef36ccddc 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 0a16d6fa69fc1923c6bf07fd5644b31ce5a7a38e..46eeff26d597482a28b5a8d2b96ab41d5f848743 100644 (file)
@@ -134,7 +134,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)
@@ -524,8 +524,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 b22245d427a0006585947fae288cc07d8c56ee88..14ea8588fff753cee050ee93af10f713d489189c 100644 (file)
@@ -127,7 +127,6 @@ private:
   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;