From 5e7543d35596fabd9e5b02b58f8910bf572ca2fa Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Thu, 7 Oct 2021 17:31:53 +0200
Subject: [PATCH] C9S: Fix mdflush
Since kernel commit 309dca309fc ("block: store a block_device pointer
in struct bio") struct bio points again to a block_device and not to a
gendisk directly. However mdflush is looking at the presence or not of
the bio_dev macro to check whether to get the gendisk directly from
the bio or not, which doesn't work anymore since the bio_dev macro
still exists. Since we don't have to deal other ekrnel kernel version
but our own, just use the definition that we use in our kernels.
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
tools/mdflush.py | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/tools/mdflush.py b/tools/mdflush.py
index 8a23520b..3581d1bf 100755
--- a/tools/mdflush.py
+++ b/tools/mdflush.py
@@ -35,18 +35,7 @@ int kprobe__md_flush_request(struct pt_regs *ctx, void *mddev, struct bio *bio)
u32 pid = bpf_get_current_pid_tgid() >> 32;
data.pid = pid;
bpf_get_current_comm(&data.comm, sizeof(data.comm));
-/*
- * The following deals with a kernel version change (in mainline 4.14, although
- * it may be backported to earlier kernels) with how the disk name is accessed.
- * We handle both pre- and post-change versions here. Please avoid kernel
- * version tests like this as much as possible: they inflate the code, test,
- * and maintenance burden.
- */
-#ifdef bio_dev
- struct gendisk *bi_disk = bio->bi_disk;
-#else
struct gendisk *bi_disk = bio->bi_bdev->bd_disk;
-#endif
bpf_probe_read_kernel(&data.disk, sizeof(data.disk), bi_disk->disk_name);
events.perf_submit(ctx, &data, sizeof(data));
return 0;
--
2.35.1