Skip to content

Commit

Permalink
Fix accounting error for pending sync IO ops in zpool iostat
Browse files Browse the repository at this point in the history
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 <ImeriMigel@gmail.com>
  • Loading branch information
MigeljanImeri committed Nov 2, 2023
1 parent 57b4098 commit 8e59cee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/sys/vdev_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions module/zfs/vdev_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 8e59cee

Please sign in to comment.