Skip to content

Commit

Permalink
mdflush: fix for Linux 4.14
Browse files Browse the repository at this point in the history
Starting Linux 4.14, there's one less indirection layer to get the
disk name. Use the bio_dev macro to discriminate between versions.
  • Loading branch information
pchaigno committed Oct 23, 2017
1 parent 5b08d38 commit 3ffc80e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/mdflush.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@
u32 pid = bpf_get_current_pid_tgid();
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
bpf_probe_read(&data.disk, sizeof(data.disk), bio->bi_disk->disk_name);
#else
bpf_probe_read(&data.disk, sizeof(data.disk),
bio->bi_bdev->bd_disk->disk_name);
bio->bi_bdev->bd_disk->disk_name);
#endif
events.perf_submit(ctx, &data, sizeof(data));
return 0;
}
Expand Down

0 comments on commit 3ffc80e

Please sign in to comment.