From: Sage Weil Date: Thu, 4 Apr 2019 19:45:52 +0000 (-0500) Subject: global: add hook to annotate crash report with EIO information X-Git-Tag: v15.1.0~3005^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7f9df6158dca9da40cff3e9f18009169044312b4;p=ceph-ci.git global: add hook to annotate crash report with EIO information 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 --- diff --git a/src/global/global_context.cc b/src/global/global_context.cc index 9cf461bc755..1841317fde4 100644 --- a/src/global/global_context.cc +++ b/src/global/global_context.cc @@ -15,6 +15,9 @@ #include "common/ceph_context.h" #include "global/global_context.h" +#include + + /* * 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; +} diff --git a/src/global/global_context.h b/src/global/global_context.h index 77b533363f6..7d32d8cfa5f 100644 --- a/src/global/global_context.h +++ b/src/global/global_context.h @@ -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 diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 1dd344ff06b..91be152f2b8 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -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);