]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: use the new block_rq_error tracepoint
authorYang Shi <shy828301@gmail.com>
Mon, 4 Apr 2022 23:34:05 +0000 (16:34 -0700)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 21 Jan 2023 06:17:17 +0000 (07:17 +0100)
Since Linux 5.18-rc1 a new block tracepoint called block_rq_error is
available for tracing disk error events dedicatedly.  Currently
rasdaemon is using block_rq_complete which also traces successful cases.
It incurs excessive tracing logs and somehow overhead since the event is
triggered quite often.

Use the new tracepoint for disk error reporting, and the new trace point
has the same format as block_rq_complete.

Signed-off-by: Yang Shi <shy828301@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
ras-events.c
ras-record.c

index 39cab20197df6cf95b322f7e4f47fc3bf4f2860e..3080a88e5bba67b16a97772effefd5a9cc79cbad 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/poll.h>
 #include <signal.h>
 #include <sys/signalfd.h>
+#include <linux/version.h>
 #include "libtrace/kbuffer.h"
 #include "libtrace/event-parse.h"
 #include "ras-mc-handler.h"
@@ -230,8 +231,12 @@ int toggle_ras_mc_event(int enable)
 #endif
 
 #ifdef HAVE_DISKERROR
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+       rc |= __toggle_ras_mc_event(ras, "block", "block_rq_error", enable);
+#else
        rc |= __toggle_ras_mc_event(ras, "block", "block_rq_complete", enable);
 #endif
+#endif
 
 #ifdef HAVE_MEMORY_FAILURE
        rc |= __toggle_ras_mc_event(ras, "ras", "memory_failure_event", enable);
@@ -242,6 +247,7 @@ free_ras:
        return rc;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
 /*
  * Set kernel filter. libtrace doesn't provide an API for setting filters
  * in kernel, we have to implement it here.
@@ -273,6 +279,7 @@ static int filter_ras_mc_event(struct ras_events *ras, char *group, char *event,
 
        return 0;
 }
+#endif
 
 /*
  * Tracing read code
@@ -902,6 +909,16 @@ int handle_ras_events(int record_events)
 #endif
 
 #ifdef HAVE_DISKERROR
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+       rc = add_event_handler(ras, pevent, page_size, "block",
+                              "block_rq_error", ras_diskerror_event_handler,
+                               NULL, DISKERROR_EVENT);
+       if (!rc)
+               num_events++;
+       else
+               log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
+                   "block", "block_rq_error");
+#else
        rc = filter_ras_mc_event(ras, "block", "block_rq_complete", "error != 0");
        if (!rc) {
                rc = add_event_handler(ras, pevent, page_size, "block",
@@ -914,6 +931,7 @@ int handle_ras_events(int record_events)
                            "block", "block_rq_complete");
        }
 #endif
+#endif
 
 #ifdef HAVE_MEMORY_FAILURE
        rc = add_event_handler(ras, pevent, page_size, "ras", "memory_failure_event",
index d845f81554a96b54a921fe20468acd55703c14df..a3679391778ab32f94e45ca88a352a5cab071f13 100644 (file)
@@ -456,7 +456,7 @@ int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev)
 #endif
 
 /*
- * Table and functions to handle block:block_rq_complete
+ * Table and functions to handle block:block_rq_{complete|error}
  */
 
 #ifdef HAVE_DISKERROR