]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: add tracepoint for blkdev_zone_mgmt
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 15 Jul 2025 11:53:23 +0000 (13:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Jul 2025 14:03:49 +0000 (08:03 -0600)
Add a tracepoint for blkdev_zone_mgmt to trace zone management commands
submitted by higher layers like file systems or user space.

An example output for this tracepoint is as follows:

  mkfs.btrfs-203  [001] .....  42.877493: blkdev_zone_mgmt: 8,0 ZRS 5242880 + 0

This example output shows a REQ_OP_ZONE_RESET operation submitted by
mkfs.btrfs.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20250715115324.53308-5-johannes.thumshirn@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-zoned.c
include/trace/events/block.h

index 69af3caa3b1c33c7b5bdaf571cb92485f3661592..70003a4bc7db7649533eeae758b43148801d64a1 100644 (file)
@@ -179,6 +179,7 @@ static int blkdev_zone_reset_all(struct block_device *bdev)
        struct bio bio;
 
        bio_init(&bio, bdev, NULL, 0, REQ_OP_ZONE_RESET_ALL | REQ_SYNC);
+       trace_blkdev_zone_mgmt(&bio, 0);
        return submit_bio_wait(&bio);
 }
 
@@ -242,6 +243,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
                cond_resched();
        }
 
+       trace_blkdev_zone_mgmt(bio, nr_sectors);
        ret = submit_bio_wait(bio);
        bio_put(bio);
 
index 4855abdf98800f5ba56a596429a5ed428f26eced..ff7698efdfde43273d06c247e6de12779de21f84 100644 (file)
@@ -599,6 +599,40 @@ TRACE_EVENT(block_rq_remap,
                  (unsigned long long)__entry->old_sector, __entry->nr_bios)
 );
 
+/**
+ * blkdev_zone_mgmt - Execute a zone management operation on a range of zones
+ * @bio: The block IO operation sent down to the device
+ * @nr_sectors: The number of sectors affected by this operation
+ *
+ * Execute a zone management operation on a specified range of zones. This
+ * range is encoded in %nr_sectors, which has to be a multiple of the zone
+ * size.
+ */
+TRACE_EVENT(blkdev_zone_mgmt,
+
+       TP_PROTO(struct bio *bio, sector_t nr_sectors),
+
+       TP_ARGS(bio, nr_sectors),
+
+       TP_STRUCT__entry(
+           __field(  dev_t,    dev             )
+           __field(  sector_t, sector          )
+           __field(  sector_t, nr_sectors      )
+           __array(  char,     rwbs,   RWBS_LEN)
+       ),
+
+       TP_fast_assign(
+           __entry->dev        = bio_dev(bio);
+           __entry->sector     = bio->bi_iter.bi_sector;
+           __entry->nr_sectors = bio_sectors(bio);
+           blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
+        ),
+
+       TP_printk("%d,%d %s %llu + %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sectors)
+);
 #endif /* _TRACE_BLOCK_H */
 
 /* This part must be outside protection */