From patchwork Wed Oct 31 11:35:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10662517 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 BEE8014BD for ; Wed, 31 Oct 2018 11:40:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2E092AAEE for ; Wed, 31 Oct 2018 11:40:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A77C62AAEC; Wed, 31 Oct 2018 11:40:50 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0D3BB2AAF0 for ; Wed, 31 Oct 2018 11:40:49 +0000 (UTC) Received: from localhost ([::1]:58757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHorh-0000nH-7o for patchwork-qemu-devel@patchwork.kernel.org; Wed, 31 Oct 2018 07:40:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomp-0003v5-6q for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomn-0002iD-29 for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:46 -0400 Received: from mail-eopbgr00117.outbound.protection.outlook.com ([40.107.0.117]:4800 helo=EUR02-AM5-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 1gHomm-0001Pq-L5; Wed, 31 Oct 2018 07:35:44 -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=0VrORBFA74CVkedaKXbfiQrKIJxLlPP5eSqBYyHl6cI=; b=Cszjc5E/b8Oak6PkdLwJYLWg3/iOhlRsjEwnEQaiJhH4kucRwww8MXF6ruBV8kMfmiYtVnIVueM2TAWuWbc7qEhaEvYqlSVXfDbLqOYcSofK8DiqaH23NWj6bcg2msxW0tWTeEEst49Zc7qkGEtXJkMOvHRU2ylAsKr7vHy55Lo= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3007.eurprd08.prod.outlook.com (52.133.14.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:35:05 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:35:05 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 9/9] qapi: query-blockstat: add driver specific file-posix stats Thread-Index: AQHUcQ3EEpawXPtnxEqdd6MeYR5xNw== Date: Wed, 31 Oct 2018 11:35:05 +0000 Message-ID: <20181031113418.29796-10-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) 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; VI1PR08MB3007; 20:3vBFrrkteZwzjn46yGPQEHDoquV7yg+caoR7aGebsLzuL5xqDkKXIi73k47y+OTwsibUUjJiCbN4W69nS6PjIX3Y4/vnGTekp0cad0bMxlLWH8xm72OrCl5xU1D/8lpgMwvH0e6t0OkkXRVxQwdr/CfVTjKprcqV8H12Aqct7MI= x-ms-office365-filtering-correlation-id: 72b00c56-bb67-4fe7-a1d0-08d63f24e71a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3007; x-ms-traffictypediagnostic: VI1PR08MB3007: 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)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3007; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(136003)(39850400004)(346002)(189003)(199004)(256004)(7416002)(5640700003)(575784001)(6486002)(2900100001)(446003)(11346002)(53936002)(2906002)(14454004)(316002)(68736007)(36756003)(5250100002)(66066001)(86362001)(99286004)(6436002)(54906003)(14444005)(2501003)(5660300001)(2351001)(1076002)(102836004)(106356001)(44832011)(81166006)(81156014)(6916009)(97736004)(8676002)(25786009)(4326008)(52116002)(8936002)(2616005)(6512007)(476003)(26005)(3846002)(386003)(6116002)(486006)(107886003)(7736002)(76176011)(105586002)(6506007)(478600001)(305945005)(71190400001)(71200400001)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3007; H:VI1PR08MB3358.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: m6P0twhRI1TvkMFTDY3kNfPcOEs4/y9DSCjohTsDauAhvbRohzKa7tq84vklomsu5nEDEiw0P99P9VSUN82VEiGpdbKzDgO2eikRvs6pFqGow2Z9IkPZYpJ99zVCEqaP1p8GrKFIdVFKin/f1XffwN2Wu5B05H2qCdhWWm3M+wMSizbZwjHSuIe6EJlPlYIFkxjKjceqxLy7h5SLqlr1pi+QOQajipKPBMWsttlvHa01f/Cs1zCA6ZC7OruN+cEHYUQNi63x8Z7ZPEGuyTxnjA9j4tNTxXQNy7MIj4NV9hjjsBCjV8u4P5eY8dodqDH77OY8DktjVi4vxzAQ99xPFux0Xjo78Nuw9lKjELPLaBk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b00c56-bb67-4fe7-a1d0-08d63f24e71a X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:35:05.8005 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3007 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.117 Subject: [Qemu-devel] [PATCH v5 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+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 +++++ 6 files changed, 72 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 01da84cb61..cd0344435e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -877,6 +877,42 @@ '*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 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: # @@ -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 b189cf422e..07a3b31386 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -475,6 +475,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 95d8635aa1..1e5bba4ac6 100644 --- a/block.c +++ b/block.c @@ -4244,6 +4244,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 1a7126046c..a0a06585ab 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2630,6 +2630,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), @@ -2741,6 +2756,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, @@ -3226,6 +3242,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 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);