From a31e69cf007dd2e7f6912b7839de1ebd1a41d091 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 8 Sep 2014 18:51:01 +0200 Subject: thread-pool: Drop unnecessary includes Dragging block_int.h into a header is *not* nice. Fortunately, this is the only offender. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- include/block/thread-pool.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include') diff --git a/include/block/thread-pool.h b/include/block/thread-pool.h index 32afcdd..4723752 100644 --- a/include/block/thread-pool.h +++ b/include/block/thread-pool.h @@ -18,11 +18,7 @@ #ifndef QEMU_THREAD_POOL_H #define QEMU_THREAD_POOL_H 1 -#include "qemu-common.h" -#include "qemu/queue.h" -#include "qemu/thread.h" -#include "block/coroutine.h" -#include "block/block_int.h" +#include "block/block.h" typedef int ThreadPoolFunc(void *opaque); -- cgit v1.1 From 0ddd0ad96abf55acad06324b26b69a24bde23ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 5 Sep 2014 15:46:15 +0200 Subject: block: Extract the BlockAcctStats structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract the block accounting statistics into a structure so the block device models can hold them in the future. CC: Kevin Wolf CC: Stefan Hajnoczi CC: Max Reitz CC: Eric Blake Signed-off-by: Benoît Canet Signed-off-by: Kevin Wolf --- include/block/block.h | 7 +++++++ include/block/block_int.h | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'include') 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; -- cgit v1.1 From 5e5a94b60518002e8ecc7afa78a9e7565b23e38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 5 Sep 2014 15:46:16 +0200 Subject: block: Extract the block accounting code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The plan is to add new accounting metrics (latency, invalid requests, failed requests, queue depth) and block.c is overpopulated so it will be better to work in a separate module. Moreover the long term plan is to have statistics in each of the BDS of the graph for metrology purpose; this means that the device model statistics must move from the topmost BDS to the device model. So we need to decouple the statistic code from BlockDriverState. This is another argument for the extraction of the code in a separate module. CC: Kevin Wolf CC: Stefan Hajnoczi CC: Max Reitz CC: Eric Blake CC: Benoit Canet CC: Fam Zheng CC: Peter Crosthwaite CC: Paolo Bonzini Signed-off-by: Benoît Canet Signed-off-by: Kevin Wolf --- include/block/accounting.h | 57 ++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 24 ------------------ include/block/block_int.h | 1 + include/hw/virtio/virtio-blk.h | 1 + include/sysemu/dma.h | 1 + 5 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 include/block/accounting.h (limited to 'include') diff --git a/include/block/accounting.h b/include/block/accounting.h new file mode 100644 index 0000000..2b2d857 --- /dev/null +++ b/include/block/accounting.h @@ -0,0 +1,57 @@ +/* + * QEMU System Emulator block accounting + * + * Copyright (c) 2011 Christoph Hellwig + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef BLOCK_ACCOUNTING_H +#define BLOCK_ACCOUNTING_H + +#include + +#include "qemu/typedefs.h" + +enum BlockAcctType { + BDRV_ACCT_READ, + BDRV_ACCT_WRITE, + BDRV_ACCT_FLUSH, + 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; + enum BlockAcctType type; +} BlockAcctCookie; + +void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, + int64_t bytes, enum BlockAcctType type); +void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie); +void bdrv_acct_highest_sector(BlockDriverState *bs, int64_t sector_num, + unsigned int nb_sectors); + +#endif diff --git a/include/block/block.h b/include/block/block.h index f47d66f..5fb36b1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -485,30 +485,6 @@ void bdrv_op_block_all(BlockDriverState *bs, Error *reason); void bdrv_op_unblock_all(BlockDriverState *bs, Error *reason); bool bdrv_op_blocker_is_empty(BlockDriverState *bs); -enum BlockAcctType { - BDRV_ACCT_READ, - BDRV_ACCT_WRITE, - BDRV_ACCT_FLUSH, - 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; - enum BlockAcctType type; -} BlockAcctCookie; - -void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, - int64_t bytes, enum BlockAcctType type); -void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie); - typedef enum { BLKDBG_L1_UPDATE, diff --git a/include/block/block_int.h b/include/block/block_int.h index 20954f3..8d86a6c 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -24,6 +24,7 @@ #ifndef BLOCK_INT_H #define BLOCK_INT_H +#include "block/accounting.h" #include "block/block.h" #include "qemu/option.h" #include "qemu/queue.h" diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index afb7b8d..cf61154 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -18,6 +18,7 @@ #include "hw/block/block.h" #include "sysemu/iothread.h" #include "block/block.h" +#include "block/accounting.h" #define TYPE_VIRTIO_BLK "virtio-blk-device" #define VIRTIO_BLK(obj) \ diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 00f21f3..73ff86d 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -15,6 +15,7 @@ #include "exec/address-spaces.h" #include "hw/hw.h" #include "block/block.h" +#include "block/accounting.h" #include "sysemu/kvm.h" typedef struct ScatterGatherEntry ScatterGatherEntry; -- cgit v1.1 From 28298fd3d9df6685c069fa0d03398c8c585a83ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 5 Sep 2014 15:46:17 +0200 Subject: block: rename BlockAcctType members to start with BLOCK_ instead of BDRV_ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The middle term goal is to move the BlockAcctStats structure in the device models. (Capturing I/O accounting statistics in the device models is good for billing) This patch make a small step in this direction by removing a reference to BDRV. CC: Kevin Wolf CC: Stefan Hajnoczi CC: Keith Busch CC: Anthony Liguori CC: "Michael S. Tsirkin" CC: Paolo Bonzini CC: John Snow CC: Richard Henderson CC: Markus Armbruster CC: Alexander Graf i Signed-off-by: Benoît Canet Signed-off-by: Kevin Wolf --- include/block/accounting.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/block/accounting.h b/include/block/accounting.h index 2b2d857..ea5998d 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -29,16 +29,16 @@ #include "qemu/typedefs.h" enum BlockAcctType { - BDRV_ACCT_READ, - BDRV_ACCT_WRITE, - BDRV_ACCT_FLUSH, - BDRV_MAX_IOTYPE, + BLOCK_ACCT_READ, + BLOCK_ACCT_WRITE, + BLOCK_ACCT_FLUSH, + BLOCK_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 nr_bytes[BLOCK_MAX_IOTYPE]; + uint64_t nr_ops[BLOCK_MAX_IOTYPE]; + uint64_t total_time_ns[BLOCK_MAX_IOTYPE]; uint64_t wr_highest_sector; } BlockAcctStats; -- cgit v1.1 From 5366d0c8bc2a8bb7a4e58e75c7e457e86d3d56f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 5 Sep 2014 15:46:18 +0200 Subject: block: Make the block accounting functions operate on BlockAcctStats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the next step for decoupling block accounting functions from BlockDriverState. In a future commit the BlockAcctStats structure will be moved from BlockDriverState to the device models structures. Note that bdrv_get_stats was introduced so device models can retrieve the BlockAcctStats structure of a BlockDriverState without being aware of it's layout. This function should go away when BlockAcctStats will be embedded in the device models structures. CC: Kevin Wolf CC: Stefan Hajnoczi CC: Keith Busch CC: Anthony Liguori CC: "Michael S. Tsirkin" CC: Paolo Bonzini CC: Eric Blake CC: Peter Maydell CC: Michael Tokarev CC: John Snow CC: Markus Armbruster CC: Alexander Graf CC: Max Reitz Signed-off-by: Benoît Canet Signed-off-by: Kevin Wolf --- include/block/accounting.h | 10 +++++----- include/block/block.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/block/accounting.h b/include/block/accounting.h index ea5998d..50b42b3 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -48,10 +48,10 @@ typedef struct BlockAcctCookie { enum BlockAcctType type; } BlockAcctCookie; -void bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, - int64_t bytes, enum BlockAcctType type); -void bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie); -void bdrv_acct_highest_sector(BlockDriverState *bs, int64_t sector_num, - unsigned int nb_sectors); +void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, + int64_t bytes, enum BlockAcctType type); +void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie); +void block_acct_highest_sector(BlockAcctStats *stats, int64_t sector_num, + unsigned int nb_sectors); #endif diff --git a/include/block/block.h b/include/block/block.h index 5fb36b1..07d6d8e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -5,6 +5,7 @@ #include "qemu-common.h" #include "qemu/option.h" #include "block/coroutine.h" +#include "block/accounting.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" @@ -574,4 +575,6 @@ 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 -- cgit v1.1