[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] xen-blkback: move statistics data into sub-structure


  • To: linux-kernel@xxxxxxxxxxxxxxx, linux-block@xxxxxxxxxxxxxxx
  • From: Juergen Gross <jgross@xxxxxxxx>
  • Date: Wed, 11 Nov 2026 17:20:57 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"
  • Authentication-results: smtp-out2.suse.de; none
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 11 Nov 2026 16:21:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Move the statistics data into a dedicated new struct xen_blkif_stat.

This is done in preparation of not losing statistics in case of
disconnect/reconnect cycles.

No functional change intended.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 drivers/block/xen-blkback/blkback.c | 14 +++++++-------
 drivers/block/xen-blkback/common.h  | 19 ++++++++++++-------
 drivers/block/xen-blkback/xenbus.c  |  2 +-
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c 
b/drivers/block/xen-blkback/blkback.c
index f3a8f3eae86b..e2f09bd4e84e 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -958,7 +958,7 @@ static int dispatch_discard_io(struct xen_blkif_ring *ring,
                        preq.sector_number + preq.nr_sects, blkif->vbd.pdevice);
                goto fail_response;
        }
-       ring->st_ds_req++;
+       ring->st.ds_req++;
 
        if (blkif->vbd.discard_secure &&
            (req->u.discard.flag & BLKIF_DISCARD_SECURE))
@@ -1198,7 +1198,7 @@ __do_block_io_op(struct xen_blkif_ring *ring, unsigned 
int *eoi_flags)
 
                pending_req = alloc_req(ring);
                if (NULL == pending_req) {
-                       ring->st_oo_req++;
+                       ring->st.oo_req++;
                        more_to_do = 1;
                        break;
                }
@@ -1297,11 +1297,11 @@ static int dispatch_rw_block_io(struct xen_blkif_ring 
*ring,
 
        switch (req_operation) {
        case BLKIF_OP_READ:
-               ring->st_rd_req++;
+               ring->st.rd_req++;
                operation = REQ_OP_READ;
                break;
        case BLKIF_OP_WRITE:
-               ring->st_wr_req++;
+               ring->st.wr_req++;
                operation = REQ_OP_WRITE;
                operation_flags = REQ_SYNC | REQ_IDLE;
                break;
@@ -1309,7 +1309,7 @@ static int dispatch_rw_block_io(struct xen_blkif_ring 
*ring,
                drain = true;
                fallthrough;
        case BLKIF_OP_FLUSH_DISKCACHE:
-               ring->st_f_req++;
+               ring->st.f_req++;
                operation = REQ_OP_WRITE;
                operation_flags = REQ_PREFLUSH;
                break;
@@ -1445,9 +1445,9 @@ static int dispatch_rw_block_io(struct xen_blkif_ring 
*ring,
        blk_finish_plug(&plug);
 
        if (operation == REQ_OP_READ)
-               ring->st_rd_sect += preq.nr_sects;
+               ring->st.rd_sect += preq.nr_sects;
        else if (operation == REQ_OP_WRITE)
-               ring->st_wr_sect += preq.nr_sects;
+               ring->st.wr_sect += preq.nr_sects;
 
        return 0;
 
diff --git a/drivers/block/xen-blkback/common.h 
b/drivers/block/xen-blkback/common.h
index 0a60e29a7cc3..f8385c4b9d30 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -248,6 +248,17 @@ struct persistent_gnt {
        struct list_head remove_node;
 };
 
+/* Statistic data. */
+struct xen_blkif_stat {
+       unsigned long long      rd_req;
+       unsigned long long      wr_req;
+       unsigned long long      oo_req;
+       unsigned long long      f_req;
+       unsigned long long      ds_req;
+       unsigned long long      rd_sect;
+       unsigned long long      wr_sect;
+};
+
 /* Per-ring information. */
 struct xen_blkif_ring {
        /* Physical parameters of the comms window. */
@@ -277,13 +288,7 @@ struct xen_blkif_ring {
        unsigned long           next_lru;
 
        /* Statistics. */
-       unsigned long long      st_rd_req;
-       unsigned long long      st_wr_req;
-       unsigned long long      st_oo_req;
-       unsigned long long      st_f_req;
-       unsigned long long      st_ds_req;
-       unsigned long long      st_rd_sect;
-       unsigned long long      st_wr_sect;
+       struct xen_blkif_stat   st;
 
        /* Used by the kworker that offload work from the persistent purge. */
        struct list_head        persistent_purge_list;
diff --git a/drivers/block/xen-blkback/xenbus.c 
b/drivers/block/xen-blkback/xenbus.c
index 62e3bad4ab0e..b3ef483a92fd 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -408,7 +408,7 @@ void xen_blkif_interface_fini(void)
                for (i = 0; i < blkif->nr_rings; i++) {         \
                        struct xen_blkif_ring *ring = &blkif->rings[i]; \
                                                                        \
-                       result += ring->st_##name;                      \
+                       result += ring->st.name;                        \
                }                                                       \
                                                                        \
 out:                                                                   \
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.