]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
global: add hook to annotate crash report with EIO information
authorSage Weil <sage@redhat.com>
Thu, 4 Apr 2019 19:45:52 +0000 (14:45 -0500)
committerSage Weil <sage@redhat.com>
Sun, 7 Apr 2019 21:01:38 +0000 (16:01 -0500)
If the global g_eio* fields are populated, include them in the crash
report, similar to how we populate assertion metadata.

Signed-off-by: Sage Weil <sage@redhat.com>
src/global/global_context.cc
src/global/global_context.h
src/global/signal_handler.cc

index 9cf461bc75525e9f6c09bef9f6326432a734ef2d..1841317fde480548d06643b089113d0b6204f832 100644 (file)
@@ -15,6 +15,9 @@
 #include "common/ceph_context.h"
 #include "global/global_context.h"
 
+#include <string.h>
+
+
 /*
  * Global variables for use from process context.
  */
@@ -32,6 +35,36 @@ int g_assert_line = 0;
 const char *g_assert_func = 0;
 const char *g_assert_condition = 0;
 unsigned long long g_assert_thread = 0;
-char g_assert_thread_name[4096];
-char g_assert_msg[8096];
-char g_process_name[NAME_MAX + 1];
+char g_assert_thread_name[4096] = { 0 };
+char g_assert_msg[8096] = { 0 };
+char g_process_name[NAME_MAX + 1] = { 0 };
+
+bool g_eio = false;
+char g_eio_devname[1024] = { 0 };
+char g_eio_path[PATH_MAX] = { 0 };
+int g_eio_error = 0;    // usually -EIO...
+int g_eio_iotype = 0;   // 1 = read, 2 = write
+unsigned long long g_eio_offset = 0;
+unsigned long long g_eio_length = 0;
+
+int note_io_error_event(
+  const char *devname,
+  const char *path,
+  int error,
+  int iotype,
+  unsigned long long offset,
+  unsigned long long length)
+{
+  g_eio = true;
+  if (devname) {
+    strncpy(g_eio_devname, devname, sizeof(g_eio_devname));
+  }
+  if (path) {
+    strncpy(g_eio_path, path, sizeof(g_eio_path));
+  }
+  g_eio_error = error;
+  g_eio_iotype = iotype;
+  g_eio_offset = offset;
+  g_eio_length = length;
+  return 0;
+}
index 77b533363f6f20e8e37cccc49e0dddae87476179..7d32d8cfa5f4340028f446b10e640d95e82b9079 100644 (file)
@@ -33,4 +33,20 @@ extern char g_assert_thread_name[4096];
 extern char g_assert_msg[8096];
 extern char g_process_name[NAME_MAX + 1];
 
+extern bool g_eio;
+extern char g_eio_devname[1024];
+extern char g_eio_path[PATH_MAX];
+extern int g_eio_error;
+extern int g_eio_iotype;   // IOCB_CMD_* from libaio's aio_abh.io
+extern unsigned long long g_eio_offset;
+extern unsigned long long g_eio_length;
+
+extern int note_io_error_event(
+  const char *devname,
+  const char *path,
+  int error,
+  int iotype,
+  unsigned long long offset,
+  unsigned long long length);
+
 #endif
index 1dd344ff06b96f06916ea5df890d87773eb93fef..91be152f2b87c5eeb95f29fdc9e485438c70d384 100644 (file)
@@ -255,6 +255,29 @@ static void handle_fatal_signal(int signum)
          jf.dump_string("assert_msg", g_assert_msg);
        }
 
+       // eio?
+       if (g_eio) {
+         jf.dump_bool("io_error", true);
+         if (g_eio_devname[0]) {
+           jf.dump_string("io_error_devname", g_eio_devname);
+         }
+         if (g_eio_path[0]) {
+           jf.dump_string("io_error_path", g_eio_path);
+         }
+         if (g_eio_error) {
+           jf.dump_int("io_error_code", g_eio_error);
+         }
+         if (g_eio_iotype) {
+           jf.dump_int("io_error_optype", g_eio_iotype);
+         }
+         if (g_eio_offset) {
+           jf.dump_unsigned("io_error_offset", g_eio_offset);
+         }
+         if (g_eio_length) {
+           jf.dump_unsigned("io_error_length", g_eio_length);
+         }
+       }
+
        // backtrace
        bt.dump(&jf);