From patchwork Fri Jan 19 12:50: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: 10175215 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 5F76860392 for ; Fri, 19 Jan 2018 12:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F77828685 for ; Fri, 19 Jan 2018 12:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43DFB28696; Fri, 19 Jan 2018 12:56:46 +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 9D51F28685 for ; Fri, 19 Jan 2018 12:56:45 +0000 (UTC) Received: from localhost ([::1]:47531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecWDs-0003iC-U2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 07:56:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecW7x-0006uP-6L for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecW7t-00039n-VB for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:37 -0500 Received: from mail-db5eur01on071f.outbound.protection.outlook.com ([2a01:111:f400:fe02::71f]:63680 helo=EUR01-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 1ecW7t-000399-LE; Fri, 19 Jan 2018 07:50:33 -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=qHjx21Xud7LXKXXYcSOhmImJqU58yDYu8pnLiEF3qmo=; b=KGEn4GxA0/kEKTu3232wkd4Jfz8JJKjl8a9jEQQT6gZWt52zwPLAicnb5c3eUt+zmOIPBeDQfiLNhYS8NLitI2sqDvjxif4OOGTvtvTg0CL+9ca/XIKJtL4kf79ch8L4JmQlbBK9cWnxm7N77CRYNUdcuW+OO522Ks+N0vi+2Qc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 19 Jan 2018 12:50:30 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:50:05 +0300 Message-Id: <1516366207-109842-7-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516366207-109842-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1516366207-109842-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:4:29::18) To VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 265332bb-bb39-49d6-f630-08d55f3b39c1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 3:tuBKl6Hm2tOAtw0fAAwtk3riVTNJQz6+jbdhK0HlVMox6YKBTL8021b/+npvHcMjsWTgtNZkf2yUO7SbJfUhQ/TvSTYNSC+cT9l8EI0jK1/pSLMTiK9xsxDNX3JOPF6kZMscgYPBdVqXymUSAahZwoJ+tMl6p7owR1aNBb5yviOunk4udA9vMkcNo4wYrc7yFXNidFjAfk8ZimEcJ1a39zbXxtSBTmXpAJTlZW+61bTwH4bR65Fbh32axIzR1Ao4; 25:hhwCWuJ/cbJHW8sglN4AI45wtJhfomiw9voyDrYIpB6V73BzqY3E74zxOmSBBufUcK12Ch92BMYDOn74lOznjH1JhbOwhYNukZ3VR8B+M27T+KyDjOywojI1IACv02BFS8nN1xb7KeZ3/+2SpnufVGzcj7JtnLMlmIOmoLnYVHJRSMrMXejmlP2VGQUpnQngHAEqipty5+xEdK5Bdb8sM2br2YYIiV2PNzC80kK8021l0uR6p+9PTMhXRBFcZPDYRzdN3TwnCBdp/f6lG/SJM8ypk4vzlMioXWDVlGmHKrbZbe/W0BjeOvAR0P48WFLZZ/VKdxqGhe+hEot9tbh82A==; 31:gxXY4sDwiwIMJCUa1RFJ3GMeusCGrIdLOp+HHuWoia+TG3tEhzvUdgsuiYaurrY+qfNzSloXuRAiOoHXYLgBdqMRF0/QkE2fOaHQ2/lOzJCeLFp1d+KBL9QTfVtBfSNBGIS6YT5PGBuS1nxz3Fx9tJ1EX9SF3Tv4iHhqOkPR+M7cbBeIbPPPA2bvJrDVVNYfDxdakJ6PzB3oNNQpvNYLTfH8AQBDsQC4eQlh40ZRgZk= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 20:2WtVz+45F3GxU19uwwg1UidslW+Q2rMG4qNqc3B+PJPAS1NAvBgJBoqGVWCqYImtmLkwiyjwz5Lbxi3PxiFETJPnRUvRMGDYqigE1x5PSGL9IHSdRCau6nWfSRhBSlkvmXyzqV55T9yo04nrfP6QwpJUOyBHP4WsJRDHsNq7tAkxKJUq4DZuYIlR5Fp8gZXK0X01klHRwkLNEdV7Dv2VOyEMrPqXFOCm0Gul1MvDZxxsj9SpMZEDimO9ysZ5DKO16k1s1QlL9OyCeOdiqD+X7v+KphY6pB2XITIPvnDplXpBVN1FQ+6nyfH94MfHsEYWu4tkvNNf0yyjyHKjVtGJ64bIvq2ZVimkzAdMFTv7jJlt65Zt6Da/Yh9wTzDuG4BOxmhcqfh/xukJfecIqJXvFdT0n3mbvytZHPFACQUbGQI=; 4:B2byciuPc4vWpwMKC7rGMqbnztrCujFTprayVP4uvuONFYOLGIcHAJ9yA5662PMOz4IUbBnUOFawhLaIlKdjHIfXkJs5axRB9y8dFHv+bhbJJA0PNTuw9e840bLtjd3koWzeRLOs0fx8KGm+OIrhYoiH+C+AxT5VtTNSeyf+ezTQlmOpFGcoEhXSWolKV7pBAmmqiGllVUfiy/b8/vBvyrRaYfc/JZKHblOnWtoBUZwPfZDCPuAe/xWG8XCFDEfbECEfpOtrI/7N304nueSoeQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231023)(2400077)(944501161)(10201501046)(6041268)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:VI1PR0801MB1999; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR0801MB1999; X-Forefront-PRVS: 0557CBAD84 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(346002)(39850400004)(376002)(396003)(39380400002)(189003)(199004)(16586007)(5660300001)(53936002)(6666003)(6916009)(6512007)(36756003)(2950100002)(53416004)(6116002)(69596002)(105586002)(6486002)(50466002)(48376002)(2361001)(3846002)(52116002)(81166006)(106356001)(2351001)(66066001)(305945005)(47776003)(107886003)(59450400001)(7736002)(81156014)(86362001)(6506007)(478600001)(8676002)(386003)(316002)(2906002)(16526018)(76176011)(4326008)(25786009)(50226002)(68736007)(51416003)(26005)(97736004)(8936002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1999; 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; VI1PR0801MB1999; 23:360Zv7HB/9G43GodCgApJVJ37myayOThUce4cB5?= =?us-ascii?Q?4u6THaB+yIvm7WHQIaPLfm4K6+FxRwfOrbPVVAe14gGfGbkGVaNDDYyQa333?= =?us-ascii?Q?UInFoTcUATjQyyeFsEQ7lYxcbZcGXU77Ux3YKvKIxLh0hJ2tV/lOW4/oDi6P?= =?us-ascii?Q?+p8HfQFoHM8SONMPq9w9Y8bKuiJsArM3Fk4WfFcKoEqO4M3KmGXZ6ygxHRon?= =?us-ascii?Q?LXRGHFf/hvwkRPmX1GIP3MQeQsFA8B6p03Q5x+f+KA5odcs3R9NsK79Di63f?= =?us-ascii?Q?3k+YWqRVMeXjW8VXiBCxaqnL4K/3RIzOHPhEAs76O/FNQHicRczTAlsX8cnr?= =?us-ascii?Q?JE8O1KffJcfTo0t+5aMvHpXUxfy/Srcc2dghQ7BV0zvn0FWxN3ZxvV9Pc7vW?= =?us-ascii?Q?vjRFHBFXq/lXOULcMSPyB7fzbplA5UvQnzc52fGKRoUBRbyUFy0hL5mxRF1p?= =?us-ascii?Q?myg5SwLNFk++c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c40ZXc0vxj6+dGqqdf/5cV+5IX8dabSsU5iHQx8bJCqVJz8UnINOSwP1RpFYSpw2lPR6PtYVE1dZyY0A7RA/4bxyoGQ9aJGopIM75tQ6MUuHQzjg702Bw0q7algHCeVaKf4L/k1U4wcEdZxjJFKbgxo5LbihtRX9oNUEQGfa5hJVj6p/eW+eXjl1rkZcDztKhur31fIFmmvgHqUmg201RmjkMVECMAc+oPvtbhV00DBi3YY=; 5:plUgMLgP8YNpcRbcv7GSjgnrBSrGanRb6t4llJX+eNNlLg4Bs+BlP1YdRLjuolyWtGetLKOv1/JNx0A4K2H2tF2e2hv9REaik4QEhbBMPCd/NHgHERVlM8VCyIV/+KNCh0jkeEVZcBB39o/c3Q6qpxJGrB9TBCF6pf6VsiCU22Y=; 24:QswJfzQ7ZqCI/WKpa8Of8/iUwnDAJMQr5WI1Yp4Vvq7EvTeHQOhYclqR4WUu/KenThDyy7RxA5K21mUGZJ/rDB6z6xmvlOqMADWAN8sdNqg=; 7:Fntz7LOEG+BZ3ECiCSpvPpxC1GtIOj7nv5ISpeObplLl1DKXbpmaLlnYM0pANzkvbd1HiSpKXMuS0sVs1DFCoLgR04HA84PyhwN8ZqdbuaFAFPmnmw3Ca2ba0U9caKJROXc/KlcfyfC+b3URS2X0yUESSSDzQRrSNriPRAn47auI0z6JWZrpBaPgcgd7KYTXOvCU3PktfOTPO6iRuyYjMWFy8RncSYf67KcIT61332JLyDX/oOuRPe26SVLzJtu2 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 20:4OWbqPeDNqI+fFzdKrtwo9Ruj3ZEBtWGyrxfl6seHBeSBc0IyYRQssc+Q/tJCARIQ1pjcgEViBrFUWwgc9NJtcJXOXmEpzcSkjxr9f0zH5BanHmYgqLYAmpophex6cNQsZL8UUFkk1XDPzac0mrEsa6yxmpIycLn1maO/BN7BjA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 12:50:30.7952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 265332bb-bb39-49d6-f630-08d55f3b39c1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1999 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe02::71f Subject: [Qemu-devel] [PATCH v2 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 , den@virtuozzo.com, qemu-block@nongnu.org, 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 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 693a754..6881664 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)); }