Skip to content

Commit

Permalink
Merge pull request iovisor#1384 from pchaigno/fix-mdflush-linux-4.14
Browse files Browse the repository at this point in the history
mdflush: fix for Linux 4.14
  • Loading branch information
yonghong-song authored Oct 27, 2017
2 parents 6e45749 + 3ffc80e commit 16f201f
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 16f201f

Please sign in to comment.