From 154debb1c54bc41e7d57e670dbfc2207912d2c36 Mon Sep 17 00:00:00 2001 From: MigeljanImeri Date: Wed, 1 Nov 2023 11:13:33 -0600 Subject: [PATCH] Fix accounting error for pending sync IO ops in zpool iostat Currently vdev_queue_class_length is responsible for checking how long the queue length is, however, it doesn't check the length when a list is used, rather it just returns whether it is empty or not. To fix this I added a counter variable to vdev_queue_t to keep track of the sync IO ops, and changed vdev_queue_class_length to reference this variable instead. Signed-off-by: MigeljanImeri --- include/sys/vdev_impl.h | 1 + lib/libzfs/libzfs.abi | 563 +++++++++++++++++++++++++++------------- module/zfs/vdev_queue.c | 7 +- 3 files changed, 385 insertions(+), 186 deletions(-) diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h index ad9dc3aefd8e..45636a5a1be5 100644 --- a/include/sys/vdev_impl.h +++ b/include/sys/vdev_impl.h @@ -138,6 +138,7 @@ typedef union vdev_queue_class { struct vdev_queue { vdev_t *vq_vdev; vdev_queue_class_t vq_class[ZIO_PRIORITY_NUM_QUEUEABLE]; + ulong_t vq_sync_pending_count[ZIO_PRIORITY_NUM_QUEUEABLE]; avl_tree_t vq_read_offset_tree; avl_tree_t vq_write_offset_tree; uint64_t vq_last_offset; diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index c1ce3d0f67d8..bc914dbd16cd 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -649,6 +649,10 @@ + + + + @@ -737,6 +741,14 @@ + + + + + + + + @@ -772,6 +784,13 @@ + + + + + + + @@ -1243,6 +1262,19 @@ + + + + + + + + + + + + + @@ -1256,41 +1288,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1336,7 +1342,6 @@ - @@ -1386,13 +1391,6 @@ - - - - - - - @@ -1520,18 +1518,10 @@ - - - - - - - - @@ -1560,12 +1550,6 @@ - - - - - - @@ -1675,6 +1659,7 @@ + @@ -1867,7 +1852,8 @@ - + + @@ -2176,6 +2162,9 @@ + + + @@ -2339,6 +2328,14 @@ + + + + + + + + @@ -2355,6 +2352,13 @@ + + + + + + + @@ -2422,7 +2426,6 @@ - @@ -2771,14 +2774,6 @@ - - - - - - - - @@ -3383,19 +3378,6 @@ - - - - - - - - - - - - - @@ -3437,27 +3419,17 @@ - - - - - - + - - - - - @@ -3475,10 +3447,6 @@ - - - - @@ -3505,10 +3473,6 @@ - - - - @@ -3521,13 +3485,6 @@ - - - - - - - @@ -4305,11 +4262,9 @@ - - - - - + + + @@ -4320,6 +4275,10 @@ + + + + @@ -4359,6 +4318,13 @@ + + + + + + + @@ -4889,6 +4855,11 @@ + + + + + @@ -5765,6 +5736,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5938,6 +6015,13 @@ + + + + + + + @@ -5986,6 +6070,10 @@ + + + + @@ -6553,6 +6641,15 @@ + + + + + + + + + @@ -6574,6 +6671,9 @@ + + + @@ -7120,25 +7220,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7299,6 +7477,23 @@ + + + + + + + + + + + + + + + + + @@ -7317,15 +7512,37 @@ + + + + + + + + + + + + + + + + + - - - + + + + + + + + @@ -7404,6 +7621,10 @@ + + + + @@ -7588,6 +7809,12 @@ + + + + + + @@ -7597,9 +7824,9 @@ - + - + @@ -7671,10 +7898,6 @@ - - - - @@ -7714,6 +7937,11 @@ + + + + + @@ -7753,10 +7981,9 @@ - - + - + @@ -7881,6 +8108,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8070,22 +8328,8 @@ - - - - - - - - - - - - - - @@ -8098,14 +8342,12 @@ - - - - - + + + - + @@ -8191,10 +8433,6 @@ - - - - @@ -8376,9 +8614,6 @@ - - - @@ -8471,39 +8706,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -8514,9 +8716,6 @@ - - - @@ -8570,10 +8769,6 @@ - - - - @@ -8718,8 +8913,8 @@ - - + + @@ -8796,7 +8991,7 @@ - + diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c index 08d918467d03..00e23170118b 100644 --- a/module/zfs/vdev_queue.c +++ b/module/zfs/vdev_queue.c @@ -273,8 +273,10 @@ vdev_queue_class_add(vdev_queue_t *vq, zio_t *zio) { zio_priority_t p = zio->io_priority; vq->vq_cqueued |= 1U << p; - if (vdev_queue_class_fifo(p)) + if (vdev_queue_class_fifo(p)) { list_insert_tail(&vq->vq_class[p].vqc_list, zio); + vq->vq_sync_pending_count[p]++; + } else avl_add(&vq->vq_class[p].vqc_tree, zio); } @@ -288,6 +290,7 @@ vdev_queue_class_remove(vdev_queue_t *vq, zio_t *zio) list_t *list = &vq->vq_class[p].vqc_list; list_remove(list, zio); empty = list_is_empty(list); + vq->vq_sync_pending_count[p]--; } else { avl_tree_t *tree = &vq->vq_class[p].vqc_tree; avl_remove(tree, zio); @@ -1069,7 +1072,7 @@ vdev_queue_class_length(vdev_t *vd, zio_priority_t p) { vdev_queue_t *vq = &vd->vdev_queue; if (vdev_queue_class_fifo(p)) - return (list_is_empty(&vq->vq_class[p].vqc_list) == 0); + return (vq->vq_sync_pending_count[p]); else return (avl_numnodes(&vq->vq_class[p].vqc_tree)); }