]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/asserts: Fix formatting
authorMatan Breizman <mbreizma@redhat.com>
Wed, 4 Jun 2025 10:51:40 +0000 (10:51 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 8 Jun 2025 14:15:56 +0000 (14:15 +0000)
* Move to GENERIC_ERROR
* Remove seastar's backtrace. It was never printted anyway due to
  missing "{}" when formatting. Moreover, Seastar's internal backtrace
  is not relevant to Ceph crashes.
* Fix formatting printing "%s"
* No need to call std::flush as this will be called when printing
  the backtrace later on.

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/common/assert.cc

index 07610c33f891bec56f4d79f90ec1571181703bb6..2e6bd6142fecec4fbfd56f61b9d13d4426fc064e 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "crimson/common/log.h"
 
+SET_SUBSYS(osd);
+
 namespace ceph {
   [[gnu::cold]] void __ceph_assert_fail(const ceph::assert_data &ctx)
   {
@@ -18,12 +20,8 @@ namespace ceph {
                                         const char* file, int line,
                                         const char* func)
   {
-    seastar::logger& logger = crimson::get_logger(0);
-    logger.error("{}:{} : In function '{}', ceph_assert(%s)\n"
-                 "{}",
-                 file, line, func, assertion,
-                 seastar::current_backtrace());
-    std::cout << std::flush;
+    GENERIC_ERROR("{}:{} : In function '{}', ceph_assert({})\n",
+                  file, line, func, assertion);
     abort();
   }
   [[gnu::cold]] void __ceph_assertf_fail(const char *assertion,
@@ -37,25 +35,15 @@ namespace ceph {
     std::vsnprintf(buf, sizeof(buf), msg, args);
     va_end(args);
 
-    seastar::logger& logger = crimson::get_logger(0);
-    logger.error("{}:{} : In function '{}', ceph_assert(%s)\n"
-                 "{}\n{}\n",
-                 file, line, func, assertion,
-                 buf,
-                 seastar::current_backtrace());
-    std::cout << std::flush;
+    GENERIC_ERROR("{}:{} : In function '{}', ceph_assert({})\n {}\n",
+                 file, line, func, assertion, buf);
     abort();
   }
 
   [[gnu::cold]] void __ceph_abort(const char* file, int line,
                                   const char* func, const std::string& msg)
   {
-    seastar::logger& logger = crimson::get_logger(0);
-    logger.error("{}:{} : In function '{}', abort(%s)\n"
-                 "{}",
-                 file, line, func, msg,
-                 seastar::current_backtrace());
-    std::cout << std::flush;
+    GENERIC_ERROR("{}:{} : In function '{}', abort({})\n", file, line, func, msg);
     abort();
   }
 
@@ -69,12 +57,8 @@ namespace ceph {
     std::vsnprintf(buf, sizeof(buf), fmt, args);
     va_end(args);
 
-    seastar::logger& logger = crimson::get_logger(0);
-    logger.error("{}:{} : In function '{}', abort()\n"
-                 "{}\n{}\n",
-                 file, line, func,
-                 buf,
-                 seastar::current_backtrace());
+    GENERIC_ERROR("{}:{} : In function '{}', abort()\n {}\n",
+                  file, line, func, buf);
     std::cout << std::flush;
     abort();
   }