From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGC5y-0006AK-SJ for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGC5x-00026n-S1 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGC5x-00026d-LG for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:41 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RJkd0s028219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 14:46:40 -0500 From: Max Reitz Date: Tue, 27 Jan 2015 14:45:44 -0500 Message-Id: <1422387983-32153-12-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-1-git-send-email-mreitz@redhat.com> References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH RESEND 11/50] block: Move BlockAcctStats into BlockBackend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Max Reitz , Stefan Hajnoczi , John Snow 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 --- block.c | 11 ----------- block/block-backend.c | 5 ++++- block/qapi.c | 20 ++++++++++++-------- include/block/block.h | 2 -- include/block/block_int.h | 3 --- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/block.c b/block.c index 5db71c6..17e4ee3 100644 --- a/block.c +++ b/block.c @@ -6119,14 +6119,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 bf0fcc9..3d565d8 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 { @@ -849,7 +852,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/qapi.c b/block/qapi.c index 4e97574..7840c81 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -334,14 +334,18 @@ 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->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->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_sector * BDRV_SECTOR_SIZE; diff --git a/include/block/block.h b/include/block/block.h index df656db..8cd6b31 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -550,6 +550,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 e309d8a..d023913 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -363,9 +363,6 @@ struct BlockDriverState { CoQueue throttled_reqs[2]; bool io_limits_enabled; - /* I/O stats (display with "info blockstats"). */ - BlockAcctStats stats; - /* Highest sector index written to */ uint64_t wr_highest_sector; -- 2.1.0