[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBacke
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBackend |
Date: |
Fri, 18 Sep 2015 17:22:50 +0200 |
As the comment above bdrv_get_stats() says, BlockAcctStats is something
which belongs to the device instead of each BlockDriverState. This patch
therefore moves it into the BlockBackend.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block.c | 11 -----------
block/block-backend.c | 5 ++++-
block/io.c | 6 +++++-
block/qapi.c | 24 ++++++++++++++----------
include/block/block.h | 2 --
include/block/block_int.h | 3 ---
6 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/block.c b/block.c
index 55357c4..f81ef23 100644
--- a/block.c
+++ b/block.c
@@ -4256,14 +4256,3 @@ void bdrv_refresh_filename(BlockDriverState *bs)
QDECREF(json);
}
}
-
-/* This accessor function purpose is to allow the device models to access the
- * BlockAcctStats structure embedded inside a BlockDriverState without being
- * aware of the BlockDriverState structure layout.
- * It will go away when the BlockAcctStats structure will be moved inside
- * the device models.
- */
-BlockAcctStats *bdrv_get_stats(BlockDriverState *bs)
-{
- return &bs->stats;
-}
diff --git a/block/block-backend.c b/block/block-backend.c
index ff862ad..310ca50 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -34,6 +34,9 @@ struct BlockBackend {
/* the block size for which the guest device expects atomicity */
int guest_block_size;
+
+ /* I/O stats (display with "info blockstats"). */
+ BlockAcctStats stats;
};
typedef struct BlockBackendAIOCB {
@@ -875,7 +878,7 @@ void blk_io_unplug(BlockBackend *blk)
BlockAcctStats *blk_get_stats(BlockBackend *blk)
{
- return bdrv_get_stats(blk->bs);
+ return &blk->stats;
}
void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
diff --git a/block/io.c b/block/io.c
index 21cc82a..08b50c0 100644
--- a/block/io.c
+++ b/block/io.c
@@ -23,6 +23,7 @@
*/
#include "trace.h"
+#include "sysemu/block-backend.h"
#include "block/blockjob.h"
#include "block/block_int.h"
#include "block/throttle-groups.h"
@@ -1895,7 +1896,10 @@ static int multiwrite_merge(BlockDriverState *bs,
BlockRequest *reqs,
}
}
- block_acct_merge_done(&bs->stats, BLOCK_ACCT_WRITE, num_reqs - outidx - 1);
+ if (bs->blk) {
+ block_acct_merge_done(blk_get_stats(bs->blk), BLOCK_ACCT_WRITE,
+ num_reqs - outidx - 1);
+ }
return outidx + 1;
}
diff --git a/block/qapi.c b/block/qapi.c
index d3cbc80..2d1ef87 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -344,16 +344,20 @@ static BlockStats *bdrv_query_stats(const
BlockDriverState *bs,
}
s->stats = g_malloc0(sizeof(*s->stats));
- s->stats->rd_bytes = bs->stats.nr_bytes[BLOCK_ACCT_READ];
- s->stats->wr_bytes = bs->stats.nr_bytes[BLOCK_ACCT_WRITE];
- s->stats->rd_operations = bs->stats.nr_ops[BLOCK_ACCT_READ];
- s->stats->wr_operations = bs->stats.nr_ops[BLOCK_ACCT_WRITE];
- s->stats->rd_merged = bs->stats.merged[BLOCK_ACCT_READ];
- s->stats->wr_merged = bs->stats.merged[BLOCK_ACCT_WRITE];
- s->stats->flush_operations = bs->stats.nr_ops[BLOCK_ACCT_FLUSH];
- s->stats->wr_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_WRITE];
- s->stats->rd_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_READ];
- s->stats->flush_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_FLUSH];
+ if (bs->blk) {
+ BlockAcctStats *stats = blk_get_stats(bs->blk);
+
+ s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ];
+ s->stats->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE];
+ s->stats->rd_operations = stats->nr_ops[BLOCK_ACCT_READ];
+ s->stats->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE];
+ s->stats->rd_merged = stats->merged[BLOCK_ACCT_READ];
+ s->stats->wr_merged = stats->merged[BLOCK_ACCT_WRITE];
+ s->stats->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH];
+ s->stats->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE];
+ s->stats->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ];
+ s->stats->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH];
+ }
s->stats->wr_highest_offset = bs->wr_highest_offset;
diff --git a/include/block/block.h b/include/block/block.h
index 3e818f4..960eb98 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -613,6 +613,4 @@ void bdrv_io_plug(BlockDriverState *bs);
void bdrv_io_unplug(BlockDriverState *bs);
void bdrv_flush_io_queue(BlockDriverState *bs);
-BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
-
#endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 67e05ac..0376508 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -400,9 +400,6 @@ struct BlockDriverState {
unsigned pending_reqs[2];
QLIST_ENTRY(BlockDriverState) round_robin;
- /* I/O stats (display with "info blockstats"). */
- BlockAcctStats stats;
-
/* Offset after the highest byte written to */
uint64_t wr_highest_offset;
--
2.5.2
- Re: [Qemu-block] [PATCH v5 08/38] block/raw_bsd: Drop raw_is_inserted(), (continued)
- [Qemu-block] [PATCH v5 10/38] hw/block/fdc: Implement tray status, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 11/38] hw/usb-storage: Check whether BB is inserted, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 12/38] block: Fix BB AIOCB AioContext without BDS, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 13/38] block: Move guest_block_size into BlockBackend, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBackend,
Max Reitz <=
- [Qemu-block] [PATCH v5 17/38] block: Add BlockBackendRootState, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 16/38] block: Move I/O status and error actions into BB, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 18/38] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/09/18
- [Qemu-block] [PATCH v5 19/38] block: Fail requests to empty BlockBackend, Max Reitz, 2015/09/18
[Qemu-block] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/09/18