From patchwork Tue Aug 21 09:46:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10571291 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 9D59E139B for ; Tue, 21 Aug 2018 09:48:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B69829BF5 for ; Tue, 21 Aug 2018 09:48:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F8E929CCC; Tue, 21 Aug 2018 09:48:35 +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 1958929BF5 for ; Tue, 21 Aug 2018 09:48:35 +0000 (UTC) Received: from localhost ([::1]:51977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3H8-00051i-CY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Aug 2018 05:48:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3Fa-0003wv-6H for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:46:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fs3FV-00083J-RI for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:46:58 -0400 Received: from mail-eopbgr40110.outbound.protection.outlook.com ([40.107.4.110]:27088 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 1fs3FV-00082E-Ak; Tue, 21 Aug 2018 05:46:53 -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=vOU88Oka1D2yVSVUtxriWIINI7lzCqCbGl54mhPxUd0=; b=FsXDbTCh9U0thwA/G6tBZXtfZCbf5VjPdTakV/tiW5Ql0tIQD95xH+xAHlmrVntK0zykiojoJROSmzOZCeJKhpSnNb/2M+DY+8goj5pNZxaAlTGWxqjHOZJULBhLJbYgAQcgAYXtXIcmWGyZff6/V3uhuNfYUXlyZd8MZUvd0t0= 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:50 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 12:46:17 +0300 Message-Id: <1534844779-118784-7-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: dc01c90e-d33a-4c3b-bee3-08d6074b0574 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:D8z5wYLUpxDQT3DS2BwaDP225IlViyUqmBnuuCUkVKRgnCuLOuDQ3H9vnSDXMwR1cVgMA2YO1e40iO6K01JvEEidixKkAeRfthcY5b6mIaqsWZsoWqsKXMzmEDnHilWuSSWG/fA4EGZHFT4nMJx2FG1z4JwBA5KSNAEeZBcYUHDj+R/Od68z++1+sYUlQpmODXweqnqmcW0PNrumgb4sC5wZSkCWb66oA739YY7KNdeZhtjYEH5AeMciKbPfbEqJ; 25:ZuKgEfxMwhhpkTXWDjXTN1ZcukW+qnQZzijQDRO5ucTKUq5jApvs5pMvqD6IKSi1abp3y6PPTRp1QS8hNqCObdgFlVRUUnkL1z9Th2QAhOnfRcQTp9wJCgj/yTUxdA1Tw0/rT45yRyUpEBnbd+DTQlOvoaA1WyElSbNJ8WASUHjdxST2pLvpJu37zdg+etpMcKd3ZHN7mZANfAFDeTgGuOjtnSU6rhh7Hd8jB53Y/MY24uaiQ6gj7v1wPmblo0oCFKtwRhgPNdqyksdErV+srmFKSkbmL+TeSxMVGQIaZk5boXo5yd/QvfAATdZbOBI0GEdpcTCUxiYcBsXCXP93xA==; 31:M3pTvjxoXYwYXWIzgqCwUsDc/4FJqGqyQD692zmO8cGaPn1G3/06LdbzvPvNHp9Tr0Kp900fTrPKWcVaaTJDtPRrodAJfqRLF18D11aZ4GLGNwfLRJeHkmnR76WYltxJSDqCFbxeMAaX737HjCYK2dc4YjeWdLjHXFxJpY7rg5bE21aSSC6Bs56evLBcV+IKc/AdsOlwBS6zHYknP/mA3L456c0rZqktlnQW9ITASvQ= X-MS-TrafficTypeDiagnostic: AM0PR08MB3347: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:ZZOp1RKccay1j/MyUnrO0n6nRd08cXaVKWWnz+qU/eC/svzqHajnYR5l/usoC7VdbLnlP7KlyzoyonKNMUMObnY28JQcRBER9eofEwMzJ1kPEGKCNUHgKj43zYiS7sPj/J8TYwr1El2NaqiLmu2hXjoBnl+Xwombi1dishNWV2jkfT3oZ6eEiI8G16jBe0tkqSLaZUZwF5jVobUeV/R3TYbCV8MI6rL/sVoO1cIv3ry2Dh0zLo5Vh0xYLPs1CYDLxB7MBZwlAQr//egXjXD6E9MCSTP86YkNLQM1uxAa3swLMiGrugLS13fxtJpTvdRftgiqn79PMB1Pj+4SpgsvHN7LLks4EAag82e6XYcmnBwExUHlPb7msdg8mxzBjCh2rjWuNzhbSz9+mTEhObNRdN2DvLVHqnXRT2AY/R9DfKmlX4lGqKUlQAtpKBAK1WJwkTElIrFQLl6FUtDtvvu3pWv8bL7ttDLJEUuAWWVU331XAPX9QyAzvyq0FrVagwyn; 4:D0hY3RP2wi/OrRJv7CeFH7i+7HU08lcLyrZgw86P+DTPsQTxtlUysiqnaDNcV+GvjKW/2SOVyG0DGAf9Oqsc7OJz/JRRWpuTNia+AN6ju+gIbq9cjV5sijIFYhw5wsaGuCBQzW8I9q4Lp8uEUysV49DUlYvh/evVHihjrG2SOrOiHj947PRixPvrKE4aDwEYhnMtaj9XRmRYWpI22kepXG8Zkch7fvjRv011nTvOO1EjqCHxaLZcHffCX9lo6yDZaxGSUaRWHv1WNY1zT7lh1g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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:ypl9PjeJ4xGVmFiYnjmpSRdEqX+/ymVeXiD5S/jqT?= FAHuLhCkyJDkD2J1UNbRXdhcMycgdj446cux4X/vMHFVw0xO6XjvH07ThPz3mp6FFoCry6YF7K9byTZVOVvLmyM6DgeWz0klLq7KSnL0Va3pja6MgIXYlvJK4zgg3+onrDb1P+WP/otDiSV1myCKetuN3DgLvBSlDUASMSEBOmQT3VCeWlpNvK2xG2+pN9toy5FL1qoECIFpvB+xDD89y2Vp8LDA4y5l/7Kwa2KvU9vNMGiJHMrfBGkL7dt40Tfv3ZNCLlf9r6QFTEetHz5Gg5RUzxuWY4qDq7qgW3HgxTWTxQAhvzKdKJXsX676MLuPgVnu+fTv+lVP1yKF3LGgS8/P8FM2QTMqPk4CLxrGWnjimky9rVQF4f6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Ov8eGnlixcN/IuweThhx/V4BEs9vtBNGcukD5dMhgDAMZ6ZGf+xU8jOtCb1+bVqNcxhhklXi+CshEeUrAa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:r490F9LzHVV8Fw2RCjCNyIwWT/6obPZelzXUbPmm5L1pRfdU4iPeh2U6uZ0itA/tcVIUXoztMV0kkCSG8Q+Ga7RHWgR3lwzetXKqBUEHhkqrQgl9iBPTAKIsJf7mPB8bLWWBm6mqGy/wWbpS+A833aZ0T3tTef3SA6kBEVx24VM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 09:46:50.4044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc01c90e-d33a-4c3b-bee3-08d6074b0574 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.110 Subject: [Qemu-devel] [PATCH v4 6/8] 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 , 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 Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- 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 9d10daf..0aac137 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1664,6 +1664,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, @@ -1690,10 +1694,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)); @@ -1740,10 +1745,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)); }