From patchwork Mon Nov 20 16:51:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10066769 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 45CC4603FA for ; Mon, 20 Nov 2017 16:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38A9E29435 for ; Mon, 20 Nov 2017 16:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24B142943F; Mon, 20 Nov 2017 16:55:54 +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 AAC1A29435 for ; Mon, 20 Nov 2017 16:55:53 +0000 (UTC) Received: from localhost ([::1]:58248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpMO-0006ac-VX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 11:55:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpI8-0002hP-6Y 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 1eGpI3-0003rt-LH 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-AR; Mon, 20 Nov 2017 11:51:23 -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=fPNDgOPGxcgl0+yuHBr+ylRA4gtiXgM8LUXum+Fe+lA=; b=ZamN/RjGN8zxyua2RbFtSyQXaXjWWOwNL+uxZaEMUQjnXKh+LZfnxoM9Xmg1h4bYp0lKwbzkfoQ/ht2QldZIuKZZ6PdlRodpSVdNIzIuNKGUVr8+Up6/xh4TwiBoJD6SVOSQ38Hhs+IsUYKMytWdpHSw30C+0yjE0auIDt7vRak= 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:20 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 20 Nov 2017 19:51:02 +0300 Message-Id: <1511196664-85304-6-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: aa80ee06-9976-45ec-c013-08d53036ed3d 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:UaGF4hHbJKDq5VKl7hUPShBgQyUDsK+7i/Krapn2Nc6vjE8DWkVNm85mNwHSPnJK4xgwpDMPmkg2CTRjkhw9Vf31eX4p22/PVRk3dXCOOKywyHLORvdkZpdlBFS8u1dmjfQScHzoNHYRWNKhDByxRdXFfKTuACwdQJD+skF0BD7X1VQHw9r6mK/Ht4fPPIEHPobxod8uVyApH7Mz9CMhjRPleAZ5DOBf+FXyUdrUfXMidFm2U8vHddp+ulqrc+tR; 25:nNNli7cFVIKfmRmSW3rRSsbZanXvAmAk7C4ahzChNEbdF3k7tzegM+dl3gzajjRmSwtJmDl84+0jOpTvpDUgJTP2frOHF79lw7Q4G1Ccr8/i+aIxGuK3nZZOI8cnMLrw18zb7VeU1NazSOTtuFXKDSb7sqlMDxBdVQyHY9RVIJvV5mk6RHbv2awpenMjgI/z1W7I9Q/RBw4J8S92Ef6Pl2AK3qzqvWsD1PH6jvS10tBpeQG1nLheOgu/ZQt354R3H/OT+TVuiGEfZJ5KhwFmTSQyo76YvPL8AklW3hpFnsg82eqLEQoTFp6Hh05PYUqxchvuG3d5zTvxjzEuGqM5vQ==; 31:0THVBLhf96T6NNr95Ujqi9oqY2CZG0vi4lsYfEthBC/1VV9IUhaMSl3JducyclD4501meYUmOyamAh+pAU7DZK0hd8ebviFVdbYM204dZEy+NPO+oNQ138DUqT44euJigUydSY/zpGe8CPYO61JkjzWshfgkO5HFYrwbJc/qQz0wa+jDSZmDeyrVzDMnS4w7aaw1xtHynHkRVX79Hrf2Dk0B+5j+Shl+QyENskIaLIQ= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1988: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:/CZw80XHUSLBZ7gU8zjcTMHU7UplfkHyv7vt11GzUKAKRtaCaepIq07FckFxdULmaOnL4JNNSS2SL0GjmMFxp/7mV97Wj9uYonlt7Mqiebdt0YtMXtPQu5LNEMHIIyy+NOoYb2UPIiokG+6D5xMW7f07zCrZUOQ0jhfvYb0NMrPZsV4h2WuJ0eG9zN8uUKmrh6SP5DP1QrglSS2aVBmTsQrAIjcDhNKuqi90OWgviXb7xdLszn7LcRmCsCIaKdqvl2LvFtWlddjNDrZeLAey2CJksfSyZUexLS1AwWBmQelakOK2SmWkxoUgMnQo5l/PEyIYYIRcDkziznQBkYC+zdUIBhY7irDmtGLP3h4UunVg5OINu8yXXAm0+f6rSFlGJ3YRfN8fcVMOOcoQPhWtgwlK4vh101Q0wx8S5sLoCFI=; 4:AvPSAWHxs1WMCJAGh34Jk/y1+0/wAnt74932m1PpA7RMybfMknZDiBy/MsuMljgabgTrEUaJPRDLz+ba5GnvTkQTL7O/O1TVVyp5WkT/+jz1THLdFC4ldWNfB5/oRwP8RE9ZN3BoBUjIKHPfpCi+B7o2Su7A2Wyl37wlQrqerrBCScLHs187lihz+d5qDiNkZ4EMj0qmJESIib8sXAyIiiUrGPDJ1VHYdhOI361OZhemo3QfHu4662YCGNlvJc7B7f0nj0P7cFb9efV1iKP+VA== 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)(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:5OxXHb8OgLMChlr/LjPEHo6xdxPSthY27UppT26?= =?us-ascii?Q?/u/ICLR1IWpmsAFgIdYaRPNZkg1YGzmvbaW6qFA/b2/UM2EyDMGwqpHsmwry?= =?us-ascii?Q?Wjrh6KE3clco7AnBM+tKrwrntCpcnxyefsdtbsClTif73D/0+AzpXqI/HZ3K?= =?us-ascii?Q?jl+SOxrty6uEW0ywDkmlJete/Q9L27f5QaRyKsRm60YonZhGoUAOgpmqVfKW?= =?us-ascii?Q?4NsZGB2qJzSQd/ILsFksFKJ4HEfZy9p31AqEEXEWy7bxZuLsYbHlM0iBCjgV?= =?us-ascii?Q?J+VzdpSzUyZjs2r10Ui3erqpfuY7H1LKmf/TsOKh3oc17tNEUGnA2gXizQTa?= =?us-ascii?Q?QYsbU+nxEZ1c2tWO4KmAUeNBZUBBMmh4tR7/3LMDg70/cm9F+z58pbD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cDhlnWn46y921R5jd6BUiuCJOJwF1WeP3it+9us7EDUMD22T3lAF9fObMLCT6me4wr6tMSF+p4j5DGfQU959f28Vsp4ymGBJHAuASJ76zx/FAoiBsIab4KcEv/l4YxmfXjRftodBzsq8gqGYux0wcWVqrkImsWIJ0WtFmpcl6kOoX4TQ0DrLsqQ/A8tRvpTheAdfjvZBwKv2ml9+60kS8b0PcvohTARfZJG9lTgaXdGaeneX8mc7SFk=; 5:ifcDWezFmbFMO2eGX+YQ0ihkvSS1+qGIOYaYDxNage9rxoZA1hK+1+0TGpkklVDpbSRRhxflj7/t6XWwzjtsnYG3vKk8BWCIksPj50UJgqTLFUOiobIQ+0V/zqh7q82a2QHYncViw6+WlUVybI63umMQj+uq7d8d58mqQs4wflQ=; 24:MkMexpwFliDjhJH9lpcHWyitFltph8tHwVaeAG5wnf2izoTDJ5bU3/1khW9DtOCy/6zqzdvL4JhQEeeGsKOD41w1ayzF6SjtTlsK+NifGwg=; 7:NLyOrmNaoJCzN5NpyTgq1GAOepzXIYxR5lbaknT6vAuVwAFvus5XKF34ekYNWqWwWMWUpV9m2oUrmLeRwyB6SdooyNG1W5ixXDfkCfXb5EbH7BmWuwUroUwUEuqBQNzHkz7WrWAPysK8df7LvP5nMdP9O6qNYORdbJSkD/qXeRKalfcqVz0euw5vXPv/aMoYE8X/7n+ExN+PRRXNaq42N6S6LEiAWBPTF154eywMpYVhwpaWY+jO6xAhpJxew2iC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:xaYNG9ScBOHSJpdVYtSSYMB7AEJvc8GSDUoH+UVwAUyH4pstNbYSo3xERvXTTzyRZBr/SKD7JWOYxZppn5iiM6K1Gv9ud1RFU4IT+CISxTB1ujEpS/trjlL2RShAa5/Fa4OO9Jr3mganJ2AfKNOmDmd/2PGboZw4Nyf4X11Wfww= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2017 16:51:20.2532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa80ee06-9976-45ec-c013-08d53036ed3d 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 5/7] scsi: account unmap 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/scsi/scsi-disk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index eca6a15..6c33418 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1636,6 +1636,10 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) goto done; } + block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, + r->sector_count * s->qdev.blocksize, + BLOCK_ACCT_UNMAP); + r->req.aiocb = blk_aio_pdiscard(s->qdev.conf.blk, r->sector * s->qdev.blocksize, r->sector_count * s->qdev.blocksize, @@ -1662,10 +1666,11 @@ static void scsi_unmap_complete(void *opaque, int ret) r->req.aiocb = NULL; aio_context_acquire(blk_get_aio_context(s->qdev.conf.blk)); - if (scsi_disk_req_check_error(r, ret, false)) { + if (scsi_disk_req_check_error(r, ret, true)) { scsi_req_unref(&r->req); g_free(data); } else { + block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct); scsi_unmap_complete_noio(data, ret); } aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); @@ -1712,10 +1717,12 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf) return; invalid_param_len: + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); return; invalid_field: + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); }