From patchwork Tue Aug 21 09:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10571307 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 E6599921 for ; Tue, 21 Aug 2018 09:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D337229CF5 for ; Tue, 21 Aug 2018 09:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74A929D40; Tue, 21 Aug 2018 09:55:24 +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 5C3C829CF5 for ; Tue, 21 Aug 2018 09:55:24 +0000 (UTC) Received: from localhost ([::1]:52020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3Nj-0003is-PH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Aug 2018 05:55:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3FY-0003vK-K9 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 1fs3FU-00081y-7I for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:46:56 -0400 Received: from mail-eopbgr40109.outbound.protection.outlook.com ([40.107.4.109]:38080 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 1fs3FT-0007zQ-JK; Tue, 21 Aug 2018 05:46:51 -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=Oqe+veYbdZmKrWQKNt9HKoG7uKVm4+LBza0JZDHCSDw=; b=aRg63OQuvw+2P6lLPL5zGk3cJUaMh1n9nSDCKfcJ1F3JvjCT63bGSC+EtSjlR7BZWy7H0nXO7eIdnlJ6bXVFM5yvlSN6LCZsX7hUD/7gCfGKnO+67w+RZM7TkvG/IJmTRqg5xWnB/eAcTUn+SHV18y0VLPdBlqc+RCwzI/Zx/e0= 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:48 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 12:46:16 +0300 Message-Id: <1534844779-118784-6-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: 14558802-7d1d-471b-6774-08d6074b045b 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:NVzQPut0BwRng1HWW2RYVYENThrF2Qooic947PNIrY0an0UZlEZVZ68JNJ7YvC3ayEksmbYXHncnhDJsj4KuiTzixAjQSsY2XJMHjPAORKDFalZMtriu4dAAlapAcFVh0WsVm5p83L2HOhb3Mafo9Sfp3MyG0EZsl+HqPD2C5wAz2Q/9QJnqiDzeTtO9Kw+/B3cTwgB3NTpD6q1RaoWPb4W3CZz9+UxQPm2LyPp4oH5c4uqnYTGOG1Tg4UDyXcKM; 25:BwCpzuR9NfNpbWhrW5ro8MB8DWHID8GZ+C5vDUWNO465tSoigtw8Y/wJjDeScrVg+tctcAiRCzaDJ7QVBR5ubnZegQVgm1gmvTOHkH4ACxWPXMPSz7aYjNLQ0OSJMyJnKdDy9JUKsbrOBDs7K/JR4p42tknP+5MsRY58/sGUjuEzSXyuDusoNA96Rrmn4Yft/S2kroKq2Sf+Jh9pC42IQ+tTx/9s2LWpMu5HJHJHL7sOApY1loO2lN8r2xUv/uZ4a56ib+itThMNQaLT80IvCePrffl8Nf4+ZI6Xv6GsTmp2Ml8bmIe6Msf67adO9VE3Mw+F/niv8RsrEBuJUihCQw==; 31:unHi3pFqNT8EwkVxzijfiz9UT9Ye0m+qfSh3i+dJ3yWntnRNqXtO1OkiJUMGO7uTAZqKN8entkqrIndLOyHA/E2bjJtQLdx3rOj6/F+4DPIuaYVtBba8YZJ7T18xTz5b1usahhZ2iO8iQkQrDa4zVNZe6f6xLtFBSBvJRQCSSqg0zEnWppaTVpGmIma23JW8oBtun0rKyRNrDRNS98VFew47nP5mfWsHTIlbPjxSAuI= X-MS-TrafficTypeDiagnostic: AM0PR08MB3347: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:YHDaDb8nlJemQAuSuqtf4DzzNNNIjBuIS49hPqddfgtRAwtbtjFP5mdVuRdN9+l5x7yPGGs/GhGmx3wNf9/LOdxssx8letmdr+2F2Q+TJwFb2bDQDDnoN+BPRcBrZhpwUFQ80S5H+aRk3mHmUQ+lgYqp9VS9pSwieMcF0b+C/R5N7HNxuXf5qNcDG3NHMtSwOywJc8LQcYKw68xisIjTmqXK0RTQdPJ3u5BQHtfSCn981UtCR4gN6ljsbvSm52Mw493KLIDtdVVnF0sEdK7AePY+XzjgMPv5dkGzDce1ejtX0aKwKThGhlwPARRLfoh32HIOdRwIeiSoV8vDs62oYuUGLvmtrrz8fuVrRQbJaY6yJX2FZCKqzUKab9Eq//vXFbXcPQN6hwuSbybAZWqRWF0bzRHED1MJpewF07F/Zdq8j8knmfcX6RMmo7Jjb3vQhIVAeD7/sidyn4FbFl1wVUGmgYiaZ86SjzOJKIVKcdXiu20ArEr7dmyBDa/3FCRd; 4:NeHgyqMnJODzhEQ/XR70PFj9cgDf3YSU2uwDWLjXAi0s2LgVz0nK4CUpN2NG+D0avSGCLTgSjyZ0bSvppF13/Bx7JwfQritNVRztL6M16SOdJWW53vNVSFFz/7J94Wk+/oHh0jWs3oLSJoHF2RRkM9TYuOWDUIbl6x4DDwyBwErJSLq/MtkIviPQm7n5T5Omug0n8oW69tXNk6E/oCZmKaBgzHcqVNKFL/ok65JQiwRj87eRuJGCGs0rDjVWVOUFqazYBBvKI6ycvUSPUdIICQ== 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:VzgLfSNovwcuFnqsLNQoJdyxYZ4IZQ5Ic3oCC4Pqu?= HcYE5RZh4bY7hZ4PrfYNpo764psNTyNMQ8jOHgMluXb9WIBGzPHhasUBsahZnaikgbFelS+XdESfgEksd/ZUgoAD70D0bjULFcCuaiCe1V03yzX5CC8RKmSmGWtvWFjewD2PpowlNMvS4ILbWoGrDqBl7qsu24yCiVO/tN6dGEW4pGSx0vsWY2frbnvzpfp3redNu+cgH5KGY0eWr3Oeu+gV5EBp/64R+ED5HVusCYrQrMYrq+YwRMEfp9gE67OaIZTkunbJOXFUVoqVYbZAlRZZgzIMtHzOOMMiQNxTVijqPDc5byVt+wyOpFH97GFXcpx4e/dwN4AIu7RuuWZNMAV+7PrJhN0Sll04zoF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YnWg6IYeqHk6JTUpYevetAyYBSoi9G1oNBh8K0FL56etjQdcjbmRhHb1x5XDvh1xN3pnXWNqLuHOm+0HNnzeD9kkM/v9O92nEHOT1SkUIblFrNvZJEa8CSF2N4EQHbUp/Ba SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:Xj8Hcyu1TkHCqzOynL7NmvysP9Y9cSIVBI3NIGt4asHbjxez92DWd9d3B/1MqMXhrjXUEzQvq9Bo57ejlxLsMCRcYD6ftC68jmZE8HckdkOave4v4QrEMQlj6ZwWkASLvjJ7SquyuCgr+C6LtTlkAh4GMwDhq6TQ8FFUcVKONZU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 09:46:48.5606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14558802-7d1d-471b-6774-08d6074b045b 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.109 Subject: [Qemu-devel] [PATCH v4 5/8] scsi: move unmap error checking to the complete callback 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 This will help to account the operation in the following commit. The difference is that we don't call scsi_disk_req_check_error() before the 1st discard iteration anymore. That function also checks if the request is cancelled, however it shouldn't get canceled until it yields in blk_aio() functions anyway. Same approach is already used for emulate_write_same. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- hw/scsi/scsi-disk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index d41eea1..9d10daf 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1655,9 +1655,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); assert(r->req.aiocb == NULL); - if (scsi_disk_req_check_error(r, ret, false)) { - goto done; - } if (data->count > 0) { r->sector = ldq_be_p(&data->inbuf[0]); @@ -1693,7 +1690,12 @@ static void scsi_unmap_complete(void *opaque, int ret) r->req.aiocb = NULL; aio_context_acquire(blk_get_aio_context(s->qdev.conf.blk)); - scsi_unmap_complete_noio(data, ret); + if (scsi_disk_req_check_error(r, ret, false)) { + scsi_req_unref(&r->req); + g_free(data); + } else { + scsi_unmap_complete_noio(data, ret); + } aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); }