[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/22] block: Extract the BlockAcctStats structure
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 08/22] block: Extract the BlockAcctStats structure |
Date: |
Fri, 12 Sep 2014 17:56:52 +0200 |
From: Benoît Canet <address@hidden>
Extract the block accounting statistics into a structure so the block device
models can hold them in the future.
CC: Kevin Wolf <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Max Reitz <address@hidden>
CC: Eric Blake <address@hidden>
Signed-off-by: Benoît Canet <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 11 ++++++-----
block/qapi.c | 19 ++++++++++---------
include/block/block.h | 7 +++++++
include/block/block_int.h | 5 +----
4 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/block.c b/block.c
index 460effe..e90f431 100644
--- a/block.c
+++ b/block.c
@@ -3363,8 +3363,8 @@ static int coroutine_fn
bdrv_aligned_pwritev(BlockDriverState *bs,
bdrv_set_dirty(bs, sector_num, nb_sectors);
- if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
- bs->wr_highest_sector = sector_num + nb_sectors - 1;
+ if (bs->stats.wr_highest_sector < sector_num + nb_sectors - 1) {
+ bs->stats.wr_highest_sector = sector_num + nb_sectors - 1;
}
if (bs->growable && ret >= 0) {
bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
@@ -5588,9 +5588,10 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie
*cookie)
{
assert(cookie->type < BDRV_MAX_IOTYPE);
- bs->nr_bytes[cookie->type] += cookie->bytes;
- bs->nr_ops[cookie->type]++;
- bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
+ bs->stats.nr_bytes[cookie->type] += cookie->bytes;
+ bs->stats.nr_ops[cookie->type]++;
+ bs->stats.total_time_ns[cookie->type] += get_clock() -
+ cookie->start_time_ns;
}
void bdrv_img_create(const char *filename, const char *fmt,
diff --git a/block/qapi.c b/block/qapi.c
index 79d1e6a..3d3d30b 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -333,15 +333,16 @@ static BlockStats *bdrv_query_stats(const
BlockDriverState *bs)
}
s->stats = g_malloc0(sizeof(*s->stats));
- s->stats->rd_bytes = bs->nr_bytes[BDRV_ACCT_READ];
- s->stats->wr_bytes = bs->nr_bytes[BDRV_ACCT_WRITE];
- s->stats->rd_operations = bs->nr_ops[BDRV_ACCT_READ];
- s->stats->wr_operations = bs->nr_ops[BDRV_ACCT_WRITE];
- s->stats->wr_highest_offset = bs->wr_highest_sector * BDRV_SECTOR_SIZE;
- s->stats->flush_operations = bs->nr_ops[BDRV_ACCT_FLUSH];
- s->stats->wr_total_time_ns = bs->total_time_ns[BDRV_ACCT_WRITE];
- s->stats->rd_total_time_ns = bs->total_time_ns[BDRV_ACCT_READ];
- s->stats->flush_total_time_ns = bs->total_time_ns[BDRV_ACCT_FLUSH];
+ s->stats->rd_bytes = bs->stats.nr_bytes[BDRV_ACCT_READ];
+ s->stats->wr_bytes = bs->stats.nr_bytes[BDRV_ACCT_WRITE];
+ s->stats->rd_operations = bs->stats.nr_ops[BDRV_ACCT_READ];
+ s->stats->wr_operations = bs->stats.nr_ops[BDRV_ACCT_WRITE];
+ s->stats->wr_highest_offset =
+ bs->stats.wr_highest_sector * BDRV_SECTOR_SIZE;
+ s->stats->flush_operations = bs->stats.nr_ops[BDRV_ACCT_FLUSH];
+ s->stats->wr_total_time_ns = bs->stats.total_time_ns[BDRV_ACCT_WRITE];
+ s->stats->rd_total_time_ns = bs->stats.total_time_ns[BDRV_ACCT_READ];
+ s->stats->flush_total_time_ns = bs->stats.total_time_ns[BDRV_ACCT_FLUSH];
if (bs->file) {
s->has_parent = true;
diff --git a/include/block/block.h b/include/block/block.h
index 8f4ad16..f47d66f 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -492,6 +492,13 @@ enum BlockAcctType {
BDRV_MAX_IOTYPE,
};
+typedef struct BlockAcctStats {
+ uint64_t nr_bytes[BDRV_MAX_IOTYPE];
+ uint64_t nr_ops[BDRV_MAX_IOTYPE];
+ uint64_t total_time_ns[BDRV_MAX_IOTYPE];
+ uint64_t wr_highest_sector;
+} BlockAcctStats;
+
typedef struct BlockAcctCookie {
int64_t bytes;
int64_t start_time_ns;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8a61215..20954f3 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -359,10 +359,7 @@ struct BlockDriverState {
bool io_limits_enabled;
/* I/O stats (display with "info blockstats"). */
- uint64_t nr_bytes[BDRV_MAX_IOTYPE];
- uint64_t nr_ops[BDRV_MAX_IOTYPE];
- uint64_t total_time_ns[BDRV_MAX_IOTYPE];
- uint64_t wr_highest_sector;
+ BlockAcctStats stats;
/* I/O Limits */
BlockLimits bl;
--
1.8.3.1
- [Qemu-devel] [PULL 02/22] Fix improper usage of cpu_to_be32 in vpc, (continued)
- [Qemu-devel] [PULL 02/22] Fix improper usage of cpu_to_be32 in vpc, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 03/22] qemu-io: Clean up openfile() after commit 2e40134, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 04/22] xen_disk: Plug memory leak on error path, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 05/22] xen: Drop redundant bdrv_close() from pci_piix3_xen_ide_unplug(), Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 09/22] block: Extract the block accounting code, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 01/22] block: extend BLOCK_IO_ERROR event with nospace indicator, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 07/22] IDE: MMIO IDE device control should be little endian, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 10/22] block: rename BlockAcctType members to start with BLOCK_ instead of BDRV_, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 11/22] block: Make the block accounting functions operate on BlockAcctStats, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 06/22] thread-pool: Drop unnecessary includes, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 08/22] block: Extract the BlockAcctStats structure,
Kevin Wolf <=
- [Qemu-devel] [PULL 12/22] block/archipelago: Implement bdrv_truncate(), Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 13/22] qemu-iotests: Run 025 for Archipelago block driver, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 14/22] dataplane: fix virtio_blk_data_plane_create() op blocker error path, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 17/22] iotests: Send the correct fd in socket_scm_helper, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 18/22] block: round up file size to nearest sector, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 16/22] blockdev: Refuse to drive_del something added with blockdev-add, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 19/22] block: don't convert file size to sector size, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 15/22] block: extend BLOCK_IO_ERROR with reason string, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 20/22] qapi: introduce PreallocMode and new PreallocModes full and falloc., Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 21/22] raw-posix: Add falloc and full preallocation option, Kevin Wolf, 2014/09/12