git: 148c173485ee - main - cam/iosched: Pass the transaction down we're collecting stats for

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 20 Jul 2024 02:59:07 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=148c173485eea8309e3c95db741686b3c71e83de

commit 148c173485eea8309e3c95db741686b3c71e83de
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-07-20 02:52:50 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-07-20 02:53:37 +0000

    cam/iosched: Pass the transaction down we're collecting stats for
    
    Pass the struct bio * down to the stats collection routines. This allows
    us to collect better stats and report more details.
    
    Sponsored by:           Netflix
    Reviewed by:            jhb
    Differential Revision:  https://reviews.freebsd.org/D46034
---
 sys/cam/cam_iosched.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c
index 022eb23cb621..330d5ea22b61 100644
--- a/sys/cam/cam_iosched.c
+++ b/sys/cam/cam_iosched.c
@@ -758,7 +758,7 @@ cam_iosched_cl_maybe_steer(struct control_loop *clp)
 #ifdef CAM_IOSCHED_DYNAMIC
 static void
 cam_iosched_io_metric_update(struct cam_iosched_softc *isc,
-    sbintime_t sim_latency, int cmd, size_t size);
+    sbintime_t sim_latency, const struct bio *bp);
 #endif
 
 static inline bool
@@ -1801,8 +1801,8 @@ cam_iosched_bio_complete(struct cam_iosched_softc *isc, struct bio *bp,
 		
 		sim_latency = cam_iosched_sbintime_t(done_ccb->ccb_h.qos.periph_data);
 		
-		cam_iosched_io_metric_update(isc, sim_latency,
-		    bp->bio_cmd, bp->bio_bcount);
+		cam_iosched_io_metric_update(isc, sim_latency, bp);
+
 		/*
 		 * Debugging code: allow callbacks to the periph driver when latency max
 		 * is exceeded. This can be useful for triggering external debugging actions.
@@ -1924,7 +1924,8 @@ static sbintime_t latencies[LAT_BUCKETS - 1] = {
 };
 
 static void
-cam_iosched_update(struct iop_stats *iop, sbintime_t sim_latency)
+cam_iosched_update(struct iop_stats *iop, sbintime_t sim_latency,
+    const struct bio *bp __unused)
 {
 	sbintime_t y, deltasq, delta;
 	int i;
@@ -2014,18 +2015,17 @@ cam_iosched_update(struct iop_stats *iop, sbintime_t sim_latency)
 
 static void
 cam_iosched_io_metric_update(struct cam_iosched_softc *isc,
-    sbintime_t sim_latency, int cmd, size_t size)
+    sbintime_t sim_latency, const struct bio *bp)
 {
-	/* xxx Do we need to scale based on the size of the I/O ? */
-	switch (cmd) {
+	switch (bp->bio_cmd) {
 	case BIO_READ:
-		cam_iosched_update(&isc->read_stats, sim_latency);
+		cam_iosched_update(&isc->read_stats, sim_latency, bp);
 		break;
 	case BIO_WRITE:
-		cam_iosched_update(&isc->write_stats, sim_latency);
+		cam_iosched_update(&isc->write_stats, sim_latency, bp);
 		break;
 	case BIO_DELETE:
-		cam_iosched_update(&isc->trim_stats, sim_latency);
+		cam_iosched_update(&isc->trim_stats, sim_latency, bp);
 		break;
 	default:
 		break;