From patchwork Fri Nov 30 14:47:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="F4S9Xshe"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435y224rqCz9s9J for ; Sat, 1 Dec 2018 01:48:42 +1100 (AEDT) Received: from localhost ([::1]:60517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk5w-0005hv-58 for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:48:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4r-0005PB-GZ for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4p-00043N-IJ for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:33 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSk4p-00040d-4K; Fri, 30 Nov 2018 09:47:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ybzCbGM4RqwyyAAzITqWmdMU3yX7G/YfY8YJVDD4Hk=; b=F4S9XshesXwICie9ZthFup8OXDczb1+1RbzYEYDD29TWTWfmQ51fJMT4pWHfYpQ14KmV3j2gGtpbOYOaIGJivzvOz6Rw0sKBZChvZ4/kKlI16rBB1PBBKMoSJo67WojM0TM4EzMKttBFGDj39V/G2OYHCW6cxo9wDJhRwWmEmTs= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:27 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:27 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 9/9] qapi: query-blockstat: add driver specific file-posix stats Thread-Index: AQHUiLucluubp+yu+0GkR1cxAnlIFA== Date: Fri, 30 Nov 2018 14:47:27 +0000 Message-ID: <20181130144705.77454-10-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3410; 20:yX2FEM+/v5zGx0AM/mtp3iLjWCnYC/BxV40BQ4kgV541zaWuDmXPIqdVbw1g3lpvb2D7uDVAtvnlPfMwyVe7Ixt3aSaAX8kJSz3VOEEATyv6s6vwvgNQs4q6z4pO6EF0j7SRB/URaAxwLudWGIoUHVWJU1W5EiCL2cb3BAjqrhc= x-ms-office365-filtering-correlation-id: 954cab5d-9b33-45e5-ea49-08d656d2bf19 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: flJVhgsIGxPzZHg30+zG8pHTR8iVg/T1kAxjkjRVLJXli2rQQIK3L1ZdmuP8qYypCVM8ITY5cSlhCE1sNvqQl+59CzK66syOuzsEkRaCOA/irVAaJXSWlpM+f3qvV9YRaxrojVagP2arirO2YWxmvwwW9tRySvE9qoM7lJDmHaZ5xylxpyu+Q/tE3fDVBseORw9lbHQojjwZOIVZ8gD0AIaF2vzUXK4a3Ee36JE2XflhUUlkOW5abUEOywJ75usS69Y1U7CD7W7Lhe+AiOQja86URaoiHRHEGEc04cL0q15GrtCzRxphEJEc6BCXxNOQewWG/jKULEuuzUZ8km7tBmuPzIDzfA2+i++6mgEwAJc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 954cab5d-9b33-45e5-ea49-08d656d2bf19 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:27.1093 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 9/9] qapi: query-blockstat: add driver specific file-posix stats X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "kwolf@redhat.com" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" A block driver can provide a callback to report driver-specific statistics. file-posix driver now reports discard statistics Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Acked-by: Markus Armbruster --- qapi/block-core.json | 38 ++++++++++++++++++++++++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++++++ block/file-posix.c | 32 ++++++++++++++++++++++++++++++++ block/qapi.c | 5 +++++ 6 files changed, 86 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 959358ccc4..b100e852c7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -877,6 +877,41 @@ '*x_wr_latency_histogram': 'BlockLatencyHistogramInfo', '*x_flush_latency_histogram': 'BlockLatencyHistogramInfo' } } +## +# @BlockStatsSpecificFile: +# +# File driver statistics +# +# @discard-nb-ok: The number of succeeded discard operations performed by +# the driver. +# +# @discard-nb-failed: The number of failed discard operations performed by +# the driver. +# +# @discard-bytes-ok: The number of bytes discarded by the driver. +# +# Since: 4.0 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'int', + 'discard-nb-failed': 'int', + 'discard-bytes-ok': 'int' } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 4.0 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile', + 'host_device': 'BlockStatsSpecificFile' } } + ## # @BlockStats: # @@ -892,6 +927,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 4.0) +# # @parent: This describes the file block device if it has one. # Contains recursively the statistics of the underlying # protocol (e.g. the host file for a qcow2 image). If there is @@ -905,6 +942,7 @@ { 'struct': 'BlockStats', 'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str', 'stats': 'BlockDeviceStats', + '*driver-specific': 'BlockStatsSpecific', '*parent': 'BlockStats', '*backing': 'BlockStats'} } diff --git a/include/block/block.h b/include/block/block.h index 7f5453b45b..d6ee3e99c9 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -478,6 +478,7 @@ const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs); void bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *cluster_offset, diff --git a/include/block/block_int.h b/include/block/block_int.h index f605622216..236d4aceef 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -320,6 +320,7 @@ struct BlockDriver { Error **errp); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs); + BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs); int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, diff --git a/block.c b/block.c index 811239ca23..5540f4f187 100644 --- a/block.c +++ b/block.c @@ -4327,6 +4327,15 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs) return NULL; } +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (!drv || !drv->bdrv_get_specific_stats) { + return NULL; + } + return drv->bdrv_get_specific_stats(bs); +} + void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event) { if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { diff --git a/block/file-posix.c b/block/file-posix.c index 1589dbf3ab..9c686961bc 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2660,6 +2660,36 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } +static BlockStatsSpecificFile get_blockstats_specific_file(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + return (BlockStatsSpecificFile) { + .discard_nb_ok = s->stats.discard_nb_ok, + .discard_nb_failed = s->stats.discard_nb_failed, + .discard_bytes_ok = s->stats.discard_bytes_ok, + }; +} + +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_FILE; + stats->u.file = get_blockstats_specific_file(bs); + + return stats; +} + +static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_HOST_DEVICE; + stats->u.host_device = get_blockstats_specific_file(bs); + + return stats; +} + static QemuOptsList raw_create_opts = { .name = "raw-create-opts", .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2771,6 +2801,7 @@ BlockDriver bdrv_file = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = raw_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, @@ -3255,6 +3286,7 @@ static BlockDriver bdrv_host_device = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = hdev_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, diff --git a/block/qapi.c b/block/qapi.c index df31f351d2..74f762ea6c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -535,6 +535,11 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset); + s->driver_specific = bdrv_get_specific_stats(bs); + if (s->driver_specific) { + s->has_driver_specific = true; + } + if (bs->file) { s->has_parent = true; s->parent = bdrv_query_bds_stats(bs->file->bs, blk_level);