]> sourceware.org Git - systemtap.git/commitdiff
Further tweak deviceseeks.stp example to work on Fedora 32/33/34
authorWilliam Cohen <wcohen@redhat.com>
Tue, 4 May 2021 21:56:27 +0000 (17:56 -0400)
committerWilliam Cohen <wcohen@redhat.com>
Tue, 4 May 2021 21:56:27 +0000 (17:56 -0400)
The previous fix for Fedora rawhide Linux kernels (5.12) did not work
on earlier Linux 5.11 kernels in Fedora 32/33/34 because struct bio
has a different field, bd_disk that has a pointer to the queue.
Separated the process for getting the sector size into two steps:

-find the request queue struct
-find the sector size for the device

This script has been tested on RHEL8, Fedora 34, and Fedora Rawhide.

testsuite/systemtap.examples/io/deviceseeks.stp

index 95cdf4bc1138bf1ae5eb8136ced95ffb0e28896b..c68b9951825d6a0bf3bacaf80d0c3179db23cf89 100755 (executable)
 
 global seeks, oldsec
 
+@define q_cast(var) %( @cast(@var, "request_queue", "kernel") %)
+
 probe ioblock_trace.request {
   if (size == 0) next
   %( $# == 1 %? if (devname !~ @1) next %) // reject mismatching device names
-  sectorsize = @choose_defined ($bio->bi_bdev->bd_disk->queue->limits->logical_block_size,
-               (@defined($q->limits->logical_block_size)
-               ? $q->limits->logical_block_size
-               : (@defined($q->logical_block_size) ? $q->logical_block_size
-                  : $q->hardsect_size)))
+  # Newer kernels remove the $q parameter from tracepoint
+  # For 5.12 and newer get the q from $bio->bi_bdev->bd_disk->queue
+  # For 5.11 get queue from $bio->bi_disk->queue
+  queue =  @defined ($q) ? $q
+    : @choose_defined($bio->bi_bdev->bd_disk->queue, $bio->bi_disk->queue)
+  sectorsize = (@defined(@q_cast(queue)->limits->logical_block_size) ?
+               queue->limits->logical_block_size :
+               (@defined(@q_cast(queue)->logical_block_size) ?
+                queue->logical_block_size :
+                queue->hardsect_size ))
   # printf("%s %s\n", devname, rw ? "w" : "r")
   sec = sector
   seeks[devname] <<< sec - oldsec[devname]
This page took 0.030154 seconds and 5 git commands to generate.