Skip to content

Commit

Permalink
Use block_rq_error if RHEL >= 9.1
Browse files Browse the repository at this point in the history
The commit introducing block_rq_error tracepoint
has been backported in RHEL 9.1, so improve the check
for block_rq_error presence to use it.

Signed-off-by: Etienne Champetier <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
champtar authored and mchehab committed Jun 11, 2024
1 parent ced615c commit aca1339
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ AS_IF([test "x$enable_diskerror" = "xyes" || test "x$enable_all" = "xyes"], [
AM_CONDITIONAL([WITH_DISKERROR], [test x$enable_diskerror = xyes || test x$enable_all = xyes])
AM_COND_IF([WITH_DISKERROR], [USE_DISKERROR="yes"], [USE_DISKERROR="no"])

AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
#ifdef RHEL_RELEASE_CODE
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 1)
# error kernel too old
#endif
#else
# error kernel too old
#endif
#endif
]])], [AC_DEFINE(HAVE_BLK_RQ_ERROR,1,"have block_rq_error tracepoint")])

AC_ARG_ENABLE([memory_failure],
AS_HELP_STRING([--enable-memory-failure], [enable memory failure events (currently experimental)]))

Expand Down
7 changes: 3 additions & 4 deletions ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <sys/poll.h>
#include <signal.h>
#include <sys/signalfd.h>
#include <linux/version.h>
#include <traceevent/kbuffer.h>
#include <traceevent/event-parse.h>
#include "ras-mc-handler.h"
Expand Down Expand Up @@ -250,7 +249,7 @@ int toggle_ras_mc_event(int enable)
#endif

#ifdef HAVE_DISKERROR
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
#ifdef HAVE_BLK_RQ_ERROR
rc |= __toggle_ras_mc_event(ras, "block", "block_rq_error", enable);
#else
rc |= __toggle_ras_mc_event(ras, "block", "block_rq_complete", enable);
Expand All @@ -277,7 +276,7 @@ int toggle_ras_mc_event(int enable)
return rc;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
#ifndef HAVE_BLK_RQ_ERROR
/*
* Set kernel filter. libtrace doesn't provide an API for setting filters
* in kernel, we have to implement it here.
Expand Down Expand Up @@ -1014,7 +1013,7 @@ int handle_ras_events(int record_events)
#endif

#ifdef HAVE_DISKERROR
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
#ifdef HAVE_BLK_RQ_ERROR
rc = add_event_handler(ras, pevent, page_size, "block",
"block_rq_error", ras_diskerror_event_handler,
NULL, DISKERROR_EVENT);
Expand Down

0 comments on commit aca1339

Please sign in to comment.