From patchwork Tue Aug 21 09:46:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10571319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88CA0921 for ; Tue, 21 Aug 2018 09:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75AC7299A0 for ; Tue, 21 Aug 2018 09:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69537299AF; Tue, 21 Aug 2018 09:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9649B29990 for ; Tue, 21 Aug 2018 09:58:37 +0000 (UTC) Received: from localhost ([::1]:52032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3Qq-0006FR-R5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Aug 2018 05:58:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3Fe-000422-V6 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fs3Fa-00086L-5D for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:47:02 -0400 Received: from mail-eopbgr40131.outbound.protection.outlook.com ([40.107.4.131]:48462 helo=EUR03-DB5-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 1fs3FZ-00085E-Kp; Tue, 21 Aug 2018 05:46:57 -0400 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=M9NaEPEAeQQ5jlmY5Sg5vGfVuh67ReC4Dp0qNAyb81I=; b=fUmkrx44cYJnmkVo1orXJCZiGtY8OrOmLu6PGaxidxRaZwze0t31HAbCwvBaY9xwGDRmuaRlqdw/4MFAJQQLaXaoZl5VO6ml8LqF2LV8Izp/YxZwFCOf1Zg0zC6Pl7APnH8+nk5swSNzerNfLgpU2avxlh+tu/0KxkGSDMlW57c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (185.231.240.5) by AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.22; Tue, 21 Aug 2018 09:46:54 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 12:46:19 +0300 Message-Id: <1534844779-118784-9-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534844779-118784-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1534844779-118784-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: HE1PR08CA0076.eurprd08.prod.outlook.com (2603:10a6:7:2a::47) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b016028c-effc-4b30-e313-08d6074b07bc X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3347; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 3:iyE7BIxro0I+F7L7KzbhgsrNM+Pn4gxfh9OX5D/RQSkMMYXZ5wwYGeA4xnzDBgbms+s09TjMwUGlM0x+6RUDXIOlgRqNGgQ7k4ZeekKYalbn7oWSnEAlBPQZA+7fteqw1qMe1vaByK0Hszj4Qb1F/HsSrIjelnqzNXxN2sFG8dKV03hmDg4OH5K4kPExD/1E4A9hfK6U8xmYTrZxzJDMinwqAvDxZ2EWIgJBaDl1Bw2mBoX1Kyzt+1ziLJ6IG5f8; 25:oP2EW315eBzxNZrWISA8Jvmjzs1AwPbZcOI5tKwhF7VbpCOjh9P2WUBoP0ImO+DMDemjOccTDc9sG4RUTKJJ/TbCEDQASNltWEQOXBDY7x2t5qOX5lsvp2zg/MNF80AHMwB6MXaECSc0Q8HFcoAMcCLfa1WrRwkMCIUPGwdc/G0mMg1pXMDK07niV0CGM8DJTz1q3B8ojRy1Ol4JUBYc15nIqMqCnTebQhK05+SWFZD9n6X+YOno7XVp4g//RJSg+WsJcQMeRyb9e3lOQ1bbV3vvJ72FpbadeXv+jQAPbPIxSXldTVksykOuzQqoH/IQdlWRWyfjCDl5KwNl6dibVQ==; 31:0/pAEjp+Vamw2yHa3+3XWLcSq++RPxlsk18N1sEuP0mK7rzN9lolaH9MtU6Ts3u1Ptj3aEKyOY0Nhjdoe4mIpRFMRSQXLAwRbGzvn7RrmorRlvXx8KcZwT7hmskVA4gJBX1kuC6jf4mkI6HbARh4sCwXuKN6HVrCMM+P9xZ3/XK+UlTQKvX/lbgfpeEUnogPgn1Jl8IZ2njvIRtiLAiURsshRBwzuImhGiGgUoAeMUc= X-MS-TrafficTypeDiagnostic: AM0PR08MB3347: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:LjwKXZoiGExXd7zuE8W1QjudvD4w6NgQsP5Ygvv+PNCAmvxCq75UNqO+fsbIV8KX8nNbn4IRch0aHCU9qqIlJhtgRUJIWbdNLOoCB5qawvAmI5oTVwP8EkbOcb4DXA4YxN8Q7u0pLfSJm5eG7kb9WC8V3efXO/F5Jp/zpNhStDl8IK+ZmR8thBIW4c3zjAcPZ80V8wfRX7am4yCrvKKeVRyjoNcJtERpormIcZ+rLFiDpVUTD8oLzsAlkG4IPfe3fA06i3CUUEmD6+hxpjgxRF6gM1LiRg2ArDV7OlUKVthgsCfzLQ7lnTfUV5GfZ3Hhl+1pHhdkTwfDBmCcFEPU5YgZG0MIVmnOFrEtU9pi0486esAF8JgpsH3h4hbnhDQ/il0NHpUW4NaYvEt2v4H2LFzyRaTmkRAHz7es6z+wCVU9tm3cpht23vYzT+QYIqJ5fITsQXCDeth/RwaHNbU1Ao3AAHRYTr8as0BOOinfpJ01qmUqnZVXEqMkQXqTkA4k; 4:qmtdN2knjz3tRj8tqEaUUHfhVsNU0fTAW/QpGdPOPXVIseR0pFKXiqp+3zLOw8c8UASnsd6bbEVo+dxzlGwMMRG9ICNH1bYJSvIDMnzUgVeGqvLUqr90hi2R5oxsTIpkZidA3cUgUpQhcVfpYqH8a4OHnhslWvK12VU/kmTUS/hPc+Jgn7Uv+uSkkuQLLXHLD3QTq8RD+z81av26Yc382SpHzfjLfaDKPNzgLmQI/Abw9kUArk2QKEH8kJjIwrksEq+zOW76h6km1UqHaqeDlBHj3NE9wHj1VGiYw6Ez1tQFYOtGqs6OC1SbTa9gUZwR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699016); SRVR:AM0PR08MB3347; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3347; X-Forefront-PRVS: 0771670921 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39850400004)(136003)(396003)(376002)(366004)(346002)(199004)(189003)(36756003)(305945005)(53416004)(105586002)(51416003)(48376002)(50226002)(8936002)(6116002)(7736002)(956004)(3846002)(69596002)(50466002)(68736007)(186003)(106356001)(2616005)(16526019)(16586007)(47776003)(486006)(476003)(52116002)(446003)(66066001)(86362001)(14444005)(107886003)(76176011)(2351001)(4326008)(316002)(5660300001)(25786009)(53936002)(478600001)(2361001)(6506007)(386003)(2906002)(6916009)(6486002)(6512007)(81156014)(81166006)(97736004)(6666003)(11346002)(8676002)(26005)(7416002)(44832011); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3347; H:xantnef-ws.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR08MB3347; 23:EuTiyKwKQKV4a80YRMf444Xlsn/K1z1v3jfVU4ukF?= tBv8370LBoxpn08tU7rYKRLhAuFu0EtJNL7M/i/xaTMz0YV57lq8UbRJqt0iuRrHnAXWFI6fvoJfkUd+yIxmRLEFx0T/oP12LqUGmtblhmu8kpOVLlUoh+bQGi+VYBdq8KiFhzDRIboY0o/XsBR5f1Tj3IJr8sSyK30nMcijgWVjGveWfldkQaKBehKE2OBWc21jihFBkZTDOfQNjmjYG2oGUpmzDOXV4GwIQGpr3kO13XtZZhI+yPuqFDvcSMDS9TmUYh2fHd1EQIrxoinVIr03kDnBq+6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ksAX6zxu/c8RouFjAhdZw6c2itIfa/VgYlPv1oekYBfbB2cJAjHRf2nFErKj06hywsc65qMnQpM54thdkFnwRfUMpHlSY3hk0ES9vvrONanNzI10PC6QF+tZJxfkG/6kHbkUjy+5JRDG5dC9CZWqMDVgi5xPf+1z1CrN1olr4eWOMn1ZLU7mNxyaHK/9fzl3nNJDGI3BQp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:khSOCaunJ5R4eIO/KoJOeY0xoojU6t3I1KZ1S7OZEP6FUyWy+faGWj1SLkbycXsBbQ/9CykGUjW1xRwxROMBlivxIDnsP1C4Q+D1/3gjj1/hiSsP98ppOhCIzstqdBIVvK0feYhIUJUi2hf0ytIpGKaQmPsaRgLKW1JoFHefUnU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 09:46:54.1858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b016028c-effc-4b30-e313-08d6074b07bc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3347 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.4.131 Subject: [Qemu-devel] [PATCH v4 8/8] 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, Anton Nefedov , famz@redhat.com, den@virtuozzo.com, qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, berto@igalia.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A block driver can provide a callback to report driver-specific statistics. file-posix driver now reports discard statistics Signed-off-by: Anton Nefedov --- qapi/block-core.json | 39 +++++++++++++++++++++++++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++++++ block/file-posix.c | 17 +++++++++++++++++ block/qapi.c | 5 +++++ tests/qemu-iotests/227.out | 18 ++++++++++++++++++ 7 files changed, 90 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 19d4743..9cac2aa 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -878,6 +878,42 @@ '*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 3.1 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'int', + 'discard-nb-failed': 'int', + 'discard-bytes-ok': 'int' + } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 3.1 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile' + } } + +## # @BlockStats: # # Statistics of a virtual block device or a block backing device. @@ -892,6 +928,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 3.1) +# # @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 +943,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 4e0871a..cbfd831 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 903b9c1..3ffe2e1 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 6161dbe..0ce4f4d 100644 --- a/block.c +++ b/block.c @@ -4200,6 +4200,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 c420f76..cc46ef8 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2623,6 +2623,21 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_FILE; + stats->u.file = (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, + }; + + return stats; +} + static QemuOptsList raw_create_opts = { .name = "raw-create-opts", .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2734,6 +2749,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, @@ -3219,6 +3235,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 = raw_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 df31f35..74f762e 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); diff --git a/tests/qemu-iotests/227.out b/tests/qemu-iotests/227.out index 736f2e3..62a9dba 100644 --- a/tests/qemu-iotests/227.out +++ b/tests/qemu-iotests/227.out @@ -15,6 +15,8 @@ Testing: -drive driver=null-co,if=virtio { "device": "virtio0", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -24,13 +26,17 @@ Testing: -drive driver=null-co,if=virtio "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": true, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": true, "rd_operations": 0, @@ -73,6 +79,8 @@ Testing: -drive driver=null-co,if=none { "device": "none0", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -82,13 +90,17 @@ Testing: -drive driver=null-co,if=none "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": true, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": true, "rd_operations": 0, @@ -160,6 +172,8 @@ Testing: -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,i { "device": "", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -169,13 +183,17 @@ Testing: -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,i "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": false, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": false, "rd_operations": 0,