From patchwork Mon Nov 20 16:51:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10066777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE77C603FA for ; Mon, 20 Nov 2017 16:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF552904B for ; Mon, 20 Nov 2017 16:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CED2A29163; Mon, 20 Nov 2017 16:59:56 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 481002904B for ; Mon, 20 Nov 2017 16:59:56 +0000 (UTC) Received: from localhost ([::1]:58294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpQJ-0001uk-AF for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 11:59:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpI8-0002hQ-GS for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGpI4-0003sI-4a for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:28 -0500 Received: from mail-eopbgr20090.outbound.protection.outlook.com ([40.107.2.90]:45238 helo=EUR02-VE1-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 1eGpI3-0003qp-Sa; Mon, 20 Nov 2017 11:51:24 -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; bh=tTpj6RSHEb46TbUuxgUyqBn6eyQqKtS5Mj1dkUQDvzE=; b=LyDp0D1QL77IOXdqbpGEw24UmhY66wMoQ5Z8QHJfTwV/PNxfA4U5E/If3403M3Sw9Nhjb0SfdPtLL3Nh5HHP+T/i4lvBClDsNA4b8YFxDEPfaZRy97PUVyWCRAVoUqWVJx/WMexXEc2MWLiXd/dvtDMt/AG2jvrmGAa39SzP2Rg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by AM5PR0801MB1988.eurprd08.prod.outlook.com (2603:10a6:203:4b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Mon, 20 Nov 2017 16:51:21 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 20 Nov 2017 19:51:03 +0300 Message-Id: <1511196664-85304-7-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511196664-85304-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1511196664-85304-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0202CA0042.eurprd02.prod.outlook.com (2603:10a6:3:e4::28) To AM5PR0801MB1988.eurprd08.prod.outlook.com (2603:10a6:203:4b::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb68b09b-6403-40c1-4195-08d53036ee01 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:AM5PR0801MB1988; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 3:62yqxHL2t23Lb8VEta1IHBE9xyYvFXk+4OHoxTz8R+SjRkIb/EMxW3WYdYw97lYSOjSZdr3RL3IV690EjF1alE/HnhHw1OmHO4y1MVzOMYVzDgIy6CS8RkknPVpcNgtm+jsW0eE3KvKI45pE5IwNU6vRkB2zTHjr8eCY1Rx2CSI6Pv+rCtYxOYvmKr3sj+Wx+rKVb329aBH7QdV6XQ5nMzCz06cu9eglIyA4VJkNOo1ZuJaSgqvt2/n7CNnb9q/W; 25:ekkwNH3NLhnog8htCpZg+vHjRUh9rwwpK6FHwXZPuPej/L3o88xeY82Yi1XVur0ghId4kPChAjGOaGvohn5dwLnIJOYPJZKxmblR9KGsHTeF8VyANe9PZuAkWsjQOIj0jE9g4dpdWY26QoaOBAsmK/eTBygkIvA4nEFpQAUw7N+JwwxR6Tsa4gULr/28eELj6wZwDU10o4+e40r/dRgIqpIztcynpmqcY3VJ8ygNkT1QtQUm8zb7ue0eKHBakldBtm5b2U3XrWTgD4oD2FIzFYG9q3ZpV0u29LYELMdiauGxhmDZ7yc2Y4R9wHC+TmBZzGIzXXE/Wo4cGSLgKtHbEQ==; 31:7tAs5LuiZQaKOEbP0xLHhSHl9J/93JSjymZPlYc4wjP8SPX16DDqJL9G/QbRDUZgtrUMCdGIJF2yXaluICeVKDxFvDMowKB9uQycPQSADf/DvMAluXImQWD/sMGnXORe6AEdlSMV/ATxV85FgeRt+Da+EFkr7yK5jsJzoEo23OmSET3uyVnKi1CrTapduRr2K1k55vXYgq7dut8mGBrDBax1nvpeRMjKVu5SQyyAbSA= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1988: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:CtzDOJlJFwu0wG3Yn3XTI081nQfXixgFpq9A0os/TtcJpFtBfqF3eT/VWwcgt2lTYnlHnQlLavincPpE/Vx6erNh3Ql8ku5bJ2d/XFcFi8KoFD5QUTaNjDWCtwcU4P6v5nlvAAuQUs7B5RWV2DOg1Mhk2eak0m/PZHDu4trYa9BQ+Hlo7CixwqxxLrSixJawY1pSztjE23ipua499DgLb1arUCM7TeLwTOGyBQl07RX0D54M7HWD9jTi49v6eDfoVJpd2Ju5XAqvTQZG+jBMX4fD9qmK6e55dlbiYvDoDYdiX/WcDKxZ1NmXpQUZokkEK2bdyRyx2koPmu0QPHKeKolK5dZwH0j/idO6rypsTBUJZosaaPUiWdr+5zDtSuoBHAbUGwRKkemP4l6T/VlwssTx5tguiC6gm9SBG7rYdno=; 4:8ZEtgmrHR+Q/Ci0RQtradvqeH+MMwX1Ut7MR6SS3e0lVhIefa9pGbQQF4BEuLtxGpjBEvpw+rGMY5YwKTaFMKQi23K3pBcg6WMQLuXMFlAF+H8s6Dne3U7J/XxbSdHvuUjaALIWR+/3Uf32YbKONAxp3zBfE16RVLcoyNlp8nG4rQ6sEpLCcEvNhqmVIaur+V9BJeXH/Fzt+oT/YLFNvTMsL9cfpyHlvuM0Cv3uXHPccKkV2GHCysUJMPS9JUv/Y3+aqjDmh/VsGQplBIKmz7g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(3231022)(6041248)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM5PR0801MB1988; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM5PR0801MB1988; X-Forefront-PRVS: 04976078F0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(346002)(189002)(199003)(6506006)(15650500001)(6486002)(25786009)(189998001)(6512007)(16586007)(86362001)(50226002)(478600001)(316002)(68736007)(8936002)(69596002)(16526018)(50986999)(55236003)(76176999)(47776003)(5003940100001)(48376002)(50466002)(7736002)(305945005)(106356001)(101416001)(105586002)(66066001)(2906002)(3846002)(2950100002)(6666003)(53416004)(97736004)(5660300001)(107886003)(8676002)(81166006)(6116002)(33646002)(4326008)(81156014)(36756003)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1988; H:xantnef-ws.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1988; 23:30G6QA/nvBz8HapRwJuHuqGBgWofHMQw+WhraOp?= =?us-ascii?Q?d+j3PTPdPCNrxDCN6gjs9+JN54eD6WHGvy805vv0IMEkBQa4GENTvV5f/G8w?= =?us-ascii?Q?EqSzUcXDNHUNZQZKUQnL5KoXf53yxFFPhl9fF/Cn+YJKamPmnvP6OeKIOLix?= =?us-ascii?Q?7v0I39npOssf4Caka00OgdF9+I37rW15hZNr8uYyAkCgQvKGy8Sayx+cxrQ7?= =?us-ascii?Q?DnTfH7RknA1unSaP46KkDsKisI6v68CG7E8rvEnLS0l/lIJOeasdnrkXe/nH?= =?us-ascii?Q?m88VnE54xjtfnVsO59yd+HpniAazCN9laFR83Q7IL2q26OPo/zJyrCtlje22?= =?us-ascii?Q?rdNeVPHLi+rV/UBxB2m3do0BLJP23rMzZJKS+ODidsDIbOXDKPYPle9SREVh?= =?us-ascii?Q?0JOtsAZx7dIdLXYYwxEO1oWW/QzD4j0JHR5QPqeVGQueyy6hocmHzgW7Mzdd?= =?us-ascii?Q?1ZwqIecA0s2Beca39WENv4QqDxbrrT1m38ese5jUypfOs3RF3c/PWvvQnVxq?= =?us-ascii?Q?81qyvQ9IKJYcrhVyLyiquRuOXyzYbh07eHURkKFvHlf97TRY1CXgUVojKdlE?= =?us-ascii?Q?LuUbrOvZEjLNCZJQi30+mX6kDV+l8S8jf1B2m0VGF5GEZrvvXd9baOS3y+V5?= =?us-ascii?Q?gYUvFp955ycxujEeVqv4LjuUnJJbxLOJMUMc5W/+ZvLOm7bLtRWV9MX6ULZR?= =?us-ascii?Q?+iQJBPnev6CtFJ5qBORgHHjCvye6pI34Nw1rYvNCSAiunUeHwINVpnvKXmwb?= =?us-ascii?Q?2268x0CLTjy2b8IkdLGIjKfGLzYjjyUH2mKWgp/iM+YBvnKBbofEoit/u7g2?= =?us-ascii?Q?E6gMKtLiNjcORGnBcLvnX3rzySJ5yEJHHXVj1pGkNuTcVdxDDipdSbQTurQ9?= =?us-ascii?Q?d86Y4oUsgCA/I7VCjD0ybTl4E03mHmwKsLFfFN07s2oVFzfUaXvUDmMmwmEr?= =?us-ascii?Q?AYcz6BhMcofOakzKkT2G5EsFtXBa17U1KKzJf2IpWwBk1/OOmbT0pccv9gxL?= =?us-ascii?Q?hwmoP8pPRO3jpKX054dazDAQvGKHqiRp4vJDpgftMOJii6O3+9ngTs06RBT9?= =?us-ascii?Q?RgDyiyn/ZdkgvYdxxdD1ZIaJhHl6/F3VYy+ndELEBGJX2BWg4TzwW1rVxYH8?= =?us-ascii?Q?gkqvxcfRb7QXHYSZArFhkVCiWWaeB75XZ+B4LK0xn53RfFhmADNvwNA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 6:8kocbDq36HFLE7WohvCc5ppFepl6PbrCQolXtk9/lmNOPw7D0qATDlDjNHc+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dX+PKRhGD6r/auwMrWT2yw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2017 16:51:21.5345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb68b09b-6403-40c1-4195-08d53036ee01 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1988 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.2.90 Subject: [Qemu-devel] [PATCH 6/7] file-posix: account discard operations 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 , den@virtuozzo.com, armbru@redhat.com, mreitz@redhat.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 This will help to identify how many of the user-issued discard operations (accounted on a device level) have actually suceeded down on the host file (even though the numbers will not be exactly the same if non-raw format driver is used (e.g. qcow2 sending metadata discards)). Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/file-posix.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 36ee89e..544ae58 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -158,6 +158,11 @@ typedef struct BDRVRawState { bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; + struct { + int64_t discard_nb_ok; + int64_t discard_nb_failed; + int64_t discard_bytes_ok; + } stats; PRManager *pr_mgr; } BDRVRawState; @@ -1458,6 +1463,16 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) return ret; } +static void raw_account_discard(BDRVRawState *s, uint64_t nbytes, int ret) +{ + if (ret) { + s->stats.discard_nb_failed++; + } else { + s->stats.discard_nb_ok++; + s->stats.discard_bytes_ok += nbytes; + } +} + static int aio_worker(void *arg) { RawPosixAIOData *aiocb = arg; @@ -1494,6 +1509,7 @@ static int aio_worker(void *arg) break; case QEMU_AIO_DISCARD: ret = handle_aiocb_discard(aiocb); + raw_account_discard(aiocb->bs->opaque, aiocb->aio_nbytes, ret); break; case QEMU_AIO_WRITE_ZEROES: ret = handle_aiocb_write_zeroes(aiocb); @@ -2654,8 +2670,9 @@ static coroutine_fn BlockAIOCB *hdev_aio_pdiscard(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; - - if (fd_open(bs) < 0) { + int ret = fd_open(bs); + if (ret < 0) { + raw_account_discard(s, bytes, ret); return NULL; } return paio_submit(bs, s->fd, offset, NULL, bytes,