From patchwork Fri Jan 19 12:50:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10175203 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 61DE360392 for ; Fri, 19 Jan 2018 12:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 504F828685 for ; Fri, 19 Jan 2018 12:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41E7928696; Fri, 19 Jan 2018 12:55:01 +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 AD2212868D for ; Fri, 19 Jan 2018 12:55:00 +0000 (UTC) Received: from localhost ([::1]:47468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecWCB-0002IO-Us for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 07:54:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecW7t-0006q7-4H for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecW7s-000393-BE for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:33 -0500 Received: from mail-db5eur01on0700.outbound.protection.outlook.com ([2a01:111:f400:fe02::700]:5568 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 1ecW7s-00038e-0b; Fri, 19 Jan 2018 07:50:32 -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=xUqmIyLbqxxYhTGIlS+MpppviaJ6yfZ5RAnIam+R1tw=; b=GfdVBfzac7sVOZQGZ+nwFN2KsjymiA3A9zq5/ao/1UMvLcQOZewlfPe5GKrLoV46mN1j0fGOCGvOOKeM8xlVdqCCh89Cj30hginBAQrDGwQvbe/iII9kW0MHLvkYgNLN6bfeCr8U5Ntnl9BNjI+3K3XqCbmquQ5JQAhL1YyCdGY= 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:29 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:50:04 +0300 Message-Id: <1516366207-109842-6-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: 8b3c0bd0-8f61-4620-298f-08d55f3b38b2 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:Zipk8VKtQoDwGwP6U2v9I3jR1D0z357xE1YXc4seJcNSwJqxJUv8GjvmG0Im6gnrHG4L8y1KdOtSbP3fPw9N1FQt1FbwWiMweyOOE3UqF51j6BGNXt+f1kwBPOaIo5dEt14UtX/0NBgpbFa0YK6slkgtQuPwjaV4OuFkfNTAAOupwEsPkXyVtssJMGjx/ybRmV5t7rByxIlwG8OlHQfcG3+IEAs45MsCPudpqTCFzwPxpYY9Kcz+VjOkLdfvti/T; 25:DYQixVEN5bJEN1rQ0YrINXDgbzfwD8r2sD0M4aa8JnB+Q0U0Ea+7ssEuSLyMXEcU1wSMoouIl3WbfD1uDoU2iz4bBKP8vA2gP6dDSz45EL5gZBrUpP2IEdCy8BpiP378gu6CbL4BcD7JJiLLczdw0aqD46OCjmhhFG6DphKRX7+TOcQTeMqhOeoZWk0y2TVNcb8T7OgttQYak02QjazpvVJGgJajHoCuun3VRi52Z0M+52Txogg3uY8U5tSd5aSzmNYUHRpHQBecYkwu9YZ82lPz3Fj33hjmA9xvnT1cI8qSxuO8Rg4wlybOdDHw5V86ab6S28cwVd4dJDmHrJs4ww==; 31:3hJic4u4nH3XCqLIx7QSVqRvWqsIzEh++V9+kadkBbg83Upn9gQlNELj96YNZ2z0RDm3+tP52a68aYOuXWJ0Z6Ysb3tMs4qzepgbZnQG62GnpJ5NAgZtPLAghXiKLKhcZJdrRhwTb7gdd9/hGq7UDzoGS9c2t7HBphnW9kxpVU5wk3vqBXVwgSQvgfAL9p+KiSUdxo4kn54nwUbp3Fbbn50Q3hwAJL3jpljruFogOBw= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 20:+i9iwkhGqEvpkIwmTweyheN58rCjCYXMlhXifQ/oRU2p0RIrVNCeuGVF+dlXdaRG+G5WjX4bfLwNwGMlddfmFH4+ZMaC8xAm5f5mLDc5BrOy1fIfcjgVrgCjQQVIayba6ENgO3QvdyrqdIrtekGVmf21K7LzPj7cQniKl4LGBf+At0kmOa1rVRs/1/tiLG/Aznn9QCp93XfOLR/T0KVXbVdORGJqv5carWLmlWTPgTpPr+UEC1l2z9TqQeXqq5Oj3WeJl54VFbeLcvrWp3Nt8u1FM99vcLX84xGYGOkJd9nDpHtY2kqzC9paysp83pRrh4uo5gGnw/9awh2EZz/Yp3hMyR2nVR1Z47BMxjKLAv8dnCRg+QFDwIz9YfQ07r+I+aeD/1c/VglgW+Qhq2QdWb0SaWiM7oJalO053hqt86g=; 4:AvgtlrzSK//uHlpr95fIcAI553EgVFuvqb7eYqF2DGwlYC0hdiQst/cN37UkobmZjUId/n/uFNC8TUjykGfumjK4I7Mmg2SDW+NYZxWBVohzVx+acb/pxeeC08dPg+RRP8V268AuhNxta0HMLQVb3MoMuJ3gR3KFe2HfkG3lTi4tZUjSQO81Ujt5D9BAd4/fe2kVfQlwuAQJ7+LhAGpd2I8POnHObdQBSzlgKcMet3XT5Gmri9KGnfoHbj3gu3Bj/LAbIA6ikZiHx/NoiQxqGA== 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)(575784001)(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:RoO6dypXhI2wWOscrVRX5cmN1hRfkgX0pjntlcn?= =?us-ascii?Q?SWzMgLvamGbGZYqm2srI4bONiAM3i0uX46JskYEHd3jbhincAShrRgcjeXzO?= =?us-ascii?Q?WCuVg3bFNgmbqmmqjQX47aPpbqAb7vdKLtMEmwrBWzNllmTr1qPLXzeWNDAe?= =?us-ascii?Q?LryY61q/rRIdWLllKYCs1P0JvRvGBQ/MVpgtTPEXN3SYWef0MuJxBjyhCzE8?= =?us-ascii?Q?pkbgfgj+ICBdZPT7UnCpjcvZtqEi/EVR4A4zyDHrfPF94LidMEd1TK/lc4Qy?= =?us-ascii?Q?AjUVTijpk/V/GS3DgfbkKPiemvmrKs1JuoqmjqGmxr1Luv/rxjCO9lmAjkP2?= =?us-ascii?Q?8/BrAbn0QBuQLSakBl5DAFu5YDMHMz9YsHatX2geHofSVM0eOUh6WIlSf9bn?= =?us-ascii?Q?1Y8qJlGhdajCkbfXQIQEDGNcW3bl8NRdqKTyNwBXP3oXTSkR2sSeCMIkmsBK?= =?us-ascii?Q?cRB8QMHKea0eB581G7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riginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 12:50:29.0296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b3c0bd0-8f61-4620-298f-08d55f3b38b2 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::700 Subject: [Qemu-devel] [PATCH v2 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 , 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 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 7b8e0ed..693a754 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1627,9 +1627,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]); @@ -1665,7 +1662,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)); }