From patchwork Mon Nov 20 16:50:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10066759 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 77162603FA for ; Mon, 20 Nov 2017 16:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A05D29407 for ; Mon, 20 Nov 2017 16:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EEA629414; Mon, 20 Nov 2017 16:53:08 +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 EA49D29413 for ; Mon, 20 Nov 2017 16:53:07 +0000 (UTC) Received: from localhost ([::1]:58237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpJj-0002hO-41 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 11:53:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpI3-0002f6-Dm for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGpHz-0003px-HX for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:23 -0500 Received: from mail-eopbgr20093.outbound.protection.outlook.com ([40.107.2.93]:54656 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 1eGpHz-0003oW-9y; Mon, 20 Nov 2017 11:51:19 -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=yOaiDv5bevmymI1BCKCCg/P6l2u+X3rZhOd5GQCh8fQ=; b=XXJbGPwYR8q68ivscPdGk85y+0xr9fuB7WtOMNGQfrU08jSMsF4EOQ4WwOXcN25DBL1dqPxdb62zVQNvpxkmAu/47e39n28yVw5+U3j5oxYOwiV+m0bkr1eIeZ6U982q0/HDRxUyLM6Rc/hriEZTp7GpEaQzuZ4al+j1PrJLbqo= 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:17 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 20 Nov 2017 19:50:59 +0300 Message-Id: <1511196664-85304-3-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: bb9f5e98-bc3e-4598-ab82-08d53036eb84 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:PEXHhn3ptoSsdwaKagBEBXBoQZj+tBFEkNOwJR5BjxXfB9+zZknLBzLKLBjga+J7itrQGIjafUxazsRKGaZbdoRB+AWvFBUR7PjaMeST4CaWq5Iv2WkRvPaKrkbT3ZTFX1/Td+j3Rhun31tPphGJ1tSWqarLHbHGwDcm7m3/IDch52z0YE2OqP7wEamj04LOylamXY2rVsmoVHh0qBqFzt6ktW7h25+cM1DGrh385msvvhRMcEwWPw01LuxUOeTL; 25:UFpvttjuJ4uNxN1lgU4+Q/IT2bfIAqc1HuK5awOsUpUnS4+eDv+C9ExCC0vV12VaA5Ci4pljMEyfHBzWZykA9hT/dfFBuF/aBo35Z3NUoEQXTJeqBTE9cZ7aKz1R1DEDS9qdZZr8uUkeAEpK1Dk6SOShFBQoLoW75a9p88wXpoeQk+DJ15Z7eKG0KxiGKRGhze7b5QwGTmQD5x47niFZSqdKlfL1FRlR2zNbYuVzo3sC8Tz1FvInXCNndlOdygmjEx5XNHN/I+uNpSYeKlGQkCw3ojajwuVTrdtCm2Mv475BjoVA9gKjMzrcefJ/HffENxNy0GpcMfecVM3yRMlVwg==; 31:CqoJjl8/nfLC3w1jEm5Wzj78oUYXPj+U5Ud9drD6wQldXdgNW9DGX/R58sfhLr89EGjoErp1RA83/a0u17zoFUvUmxUuh7mo2CmCjBj1x0zY5iJ5lM55ql1V3CXk359twHRxQGAo3gqyjfAENuxhC6Etr868pj+PM/RdT9raItoArxhEr9BWUiHPjgOQRaApFw6TsaLsQ7wjY9FXBd2ZGCeH9AOou1ivgtyHD8slpzI= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1988: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:igzvnrSKYVtqED+TNJ4kgLBAwQbLeW0VHyXhB2emhqTTSMCeeWRU8/B35LKzQQYWpRwDT5nqPSLHcMbC3bkCeThMsvHQvVtSdusi5+RnNuujPd+l9Mpc8dGGU6D8gYb8GF8kGg/O3XNjJv3RGmGf2hyjnM9lPbmWEhPNKLaojzLaaEyn7NKSFSpgnwerXq8wbuJn5LZhkwhuQeMcyd3sS0HU8GivHU0YZJIJoVYNmulot2VKtKF+O23B4e/SKxzBnq/h6T9AKKDa80Sor2LSVJ4Jq4/VGEFeQJtGyafY95vyUG9vsoUsYFyk2858DebUqbNF2fZ6eauNiyl8zsIhbe0sNVYXgamYYU59aGuKzstfVh/UO/SLu6ItJFSEGkcKRqbMKpA4T+UxPY3seHWO7A+j05szd4z2N3SRB0SrWaU=; 4:4KnZCZahLGtADV1RhlhbYJdl41PeiCz5YFEIDcC8NOpFgu4kJG7XzwW6R7BETOTrxrOqPigg4McSmnSoRSTlZr2fuCN4IMZHfyaRyKGT0ATd5+Einw4PPN+iczaXFuKUkVWVZOWlnUmIgWsiJf1iXrLUIbzJNG7sCgcBm2Z3agxoODHn/YTKkVwFtQNNE61Y0xfYGzJ4vlMEL+uukw7920Muq7Hde2n8rAY1AdvwUOrmTjTy7ulbIBCnkJ/ZE9qoEpoUPX67y72O03FiyJwPCA== 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)(6486002)(25786009)(189998001)(6512007)(16586007)(86362001)(50226002)(478600001)(575784001)(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:umBdByuV1CXZ+fIoU1u1UuSfB3zwUD54XT+nRWL?= =?us-ascii?Q?3JeKmsoH1xkhLr0L5mxB+lGzyof0XL01nB5KgHfjIScB8bMQJBKtpDGlDwrL?= =?us-ascii?Q?O3t/Ew0mkuQEmauHaxTIq+BuzhotNQQD14FjdobK+JBMDf8RUwnrlBJJxGkn?= =?us-ascii?Q?3dnYW9PgLMc8xxnl3mib8S7jiHgk6IxBouGoM1PIno4BKWWr8rrITlzbaf88?= =?us-ascii?Q?y9wbMAwbI+GSE10ZlytUchO9htZa+0InvBSJb2CIHyTFnQQZv1Zcb1n3B9zI?= =?us-ascii?Q?qJt+07PeZOtQAXf5yZr2xx0Vu5JBCtdtiNBBUMpSSt89bbhoV0PN/tUzubRD?= =?us-ascii?Q?hR6qZ9R6E93yDaQlDvzIoa52JVR/DDHWv+faWI+u59VFFDcBEj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SwBzU3eLJ296wh4J+D8MXHIKGrNmrN1JzMrl4xu3idHt2o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2017 16:51:17.3625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb9f5e98-bc3e-4598-ab82-08d53036eb84 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.93 Subject: [Qemu-devel] [PATCH 2/7] ide: account UNMAP (TRIM) 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 Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/ide/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ide/core.c b/hw/ide/core.c index 471d0c9..2e4dea7 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -389,6 +389,7 @@ typedef struct TrimAIOCB { QEMUIOVector *qiov; BlockAIOCB *aiocb; int i, j; + BlockAcctCookie acct; } TrimAIOCB; static void trim_aio_cancel(BlockAIOCB *acb) @@ -426,6 +427,14 @@ static void ide_trim_bh_cb(void *opaque) static void ide_issue_trim_cb(void *opaque, int ret) { TrimAIOCB *iocb = opaque; + if (iocb->i >= 0) { + if (ret >= 0) { + block_acct_done(blk_get_stats(iocb->blk), &iocb->acct); + } else { + block_acct_failed(blk_get_stats(iocb->blk), &iocb->acct); + } + } + if (ret >= 0) { while (iocb->j < iocb->qiov->niov) { int j = iocb->j; @@ -442,6 +451,9 @@ static void ide_issue_trim_cb(void *opaque, int ret) continue; } + block_acct_start(blk_get_stats(iocb->blk), &iocb->acct, + count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP); + /* Got an entry! Submit and exit. */ iocb->aiocb = blk_aio_pdiscard(iocb->blk, sector << BDRV_SECTOR_BITS,