From patchwork Mon Oct 12 20:00:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 529434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0949E140DA5 for ; Tue, 13 Oct 2015 07:14:20 +1100 (AEDT) Received: from localhost ([::1]:58485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZljUA-00049R-2a for incoming@patchwork.ozlabs.org; Mon, 12 Oct 2015 16:14:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZljI5-0007ex-Mj for qemu-devel@nongnu.org; Mon, 12 Oct 2015 16:01:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZljI4-0000gN-IP for qemu-devel@nongnu.org; Mon, 12 Oct 2015 16:01:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZljHy-0000dq-2i; Mon, 12 Oct 2015 16:01:42 -0400 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 (Postfix) with ESMTPS id AF2B419CF6D; Mon, 12 Oct 2015 20:01:41 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9CK1dxt004085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 12 Oct 2015 16:01:40 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 12 Oct 2015 22:00:18 +0200 Message-Id: <1444680042-13207-16-git-send-email-mreitz@redhat.com> In-Reply-To: <1444680042-13207-1-git-send-email-mreitz@redhat.com> References: <1444680042-13207-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , John Snow , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v6 15/39] block: Move BlockAcctStats into BlockBackend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Reviewed-by: Kevin Wolf --- 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 baad2b4..3e13b7f 100644 --- a/block.c +++ b/block.c @@ -4143,14 +4143,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 7bc2eb1..a52037b 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 { @@ -892,7 +895,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 b80044b..2fd7a1d 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" @@ -1905,7 +1906,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 0360126..7c8209b 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 f923a01..d19903a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -621,6 +621,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 b8e1c59..f9c7ec5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -399,9 +399,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;