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)]))
#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"
#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);
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.
#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);