From patchwork Mon Nov 20 16:51:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10066771 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 EDC01603FA for ; Mon, 20 Nov 2017 16:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E02FB2943E for ; Mon, 20 Nov 2017 16:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4EDD29441; Mon, 20 Nov 2017 16:56: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 68FDB29440 for ; Mon, 20 Nov 2017 16:56:01 +0000 (UTC) Received: from localhost ([::1]:58250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpMW-0006hS-JA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 11:56:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGpI6-0002h0-7t for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGpI1-0003qb-S9 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 11:51:26 -0500 Received: from mail-eopbgr20123.outbound.protection.outlook.com ([40.107.2.123]:50533 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 1eGpI1-0003qB-K2; Mon, 20 Nov 2017 11:51:21 -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=PNyBDxRyfIWURA89ji/z4Fh2TNLG2MKvpCMAOW7AqZo=; b=fxbTvK0Uzg+xt4wh/OPDvuFRfLZcQIjIUO1JFVj8fok7LdesM54eSdxU/+IKDUlkFpr+5/vrzUVFHEqyaoG2tB/u5P06WMVSGk07xKEjR9PQO/2TsiDKhljpLH9g0pRh6MRW9EPNBn7E8TAnz8th7UI8sPugwLF9bZuW7pEUK/4= 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:19 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 20 Nov 2017 19:51:01 +0300 Message-Id: <1511196664-85304-5-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: 39a3c481-8d0a-4627-edc7-08d53036eca9 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:3d/+AWlv6qNa/q9Xxj6w9Ho066OpIw2UvQjYjrhacggNVEuXMVppojx1ihbCOPBsPfdKrdb0f3QLsIHMEJfR6BOMCAvCf5h4Zj7Fn5dEc3t90mbH/q026iiQa5GdtmxaCRKr4F9U8NkkKFsHL+Sqz7xbvj1f4j98rL2uwcDUAi/6IVP3k+BJvPXTDtYb+WGA+HxA5QWgjTQX9S8K4Jy/u0rUYz/2mRQK2bkmJ8Kjy/sBwVnnlUS+nUlVVaBi10Ep; 25:/zCBfO7jGSW3uTsc9QgwSzPbfiY5TjPlQoiv/FPkZKDBCfCLYW3BaiXxU7mZ/Fjpq81pVxHKcErDij6CfOfBTP3LaQ5ED5XHL/WC+eZczs32AcwvuG2sJ+nxmju4KbIUgQVAW1JaOGq3vqKGoZO6V1oM+FrvOjeObFjEYep4rS35/7zFw+pPv+7I//mI7HPI1LNOIdQMXUEG1Bra9rraVBsba5ITX+Ui0GzdzPiBjbSnjMsJdFbtYpyPoMSjD/B5TDQEsskDqDUIS/Og68l2gdwaSBDB98yoMVyTbq3elSTnXlXIv0DcrRx/ATuySN89BDYojYKus5n78x2woNbkiA==; 31:AzGg0So3hbsWg3HPRwx40KolXQrt1RXPT0rbPHKRgHGdUUhRvu7FVZ8dIdDiD3QAG9ereuzMCKqrDxQNiYlARVMupdBWEGajUb3s/QtO7XduB7LSjbRirIpyw5AzSeZ27spCxeJ6jezu/kV153T1rUJJF58WhauYb6nkH/N1gulckFfiVJg7V2Q1mAfUTe0fgY7m/FRmGJoBWwmT+JfXKioduAxbTH+2E1+pS9JPEdI= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1988: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:3UARo2scmpVgiB2cRqgwlVISgOqphezuvYngCBs6yoCHujCVQMQcxJ7VsN/GHqO1jwYA9yVv692E/pCcAIxD/S6N/FBj00oYpVcxiLNF0+2Lsf9bx1R38eOFVZjR+sHzhhsSZUMWLcziP8JdMRL49/cDw4CB8n9bDTfkMVzmdwYccoXR3MT56sOgk8F7OBuaBwMlojHsRFTqcXRF38YNN8QsU6Hpb9tY48v5QTZ1xQd1XVvSC2E3U+TYRkAmkbBhR3hukoXeZQFItTeNL1mxxto40P+zi1Opm0dIpky1NRtOZ36AfuIa9KSFKgJDbZKFbJ4EHWihD336DbYTEw70HdtsCuntN2aW+RR7iIUR+brK5RKvwCVxBDY1saXc7F3pp7j10iIEzYTqEXWmmiNbVUF6JkUwSGa6Cvh37vWkpnM=; 4:x9X0geacMDw3sp/rBiIsQQNP+8v7bc+Z1CrgRlXUj83MUql1MhLDus5i5MZoD6qNi+HTzLnu0Wm/wg7VbNQZoN6qJSiqzqCd34CiDsHo8sHRXRDlKq5HYbyWzrW7pybehn/a3Sct/r10kYw7Ys55SiljAn29BD5Z3MExVDzi9s0co8r8yut7mwFIq3ueVEmmoGz9JCoB70XClboBmXGzkF+59md10qoiG5ws150oBUVjd5YCd7TR94bQeEKJuMwr7Bn+RBb/W/An+5c1FMkkAQ== 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)(979002)(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)(969003)(989001)(999001)(1009001)(1019001); 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:IaF7RLDajTiYk6cexgJSNh6IFg8c37z03GjAhKc?= =?us-ascii?Q?ow5bdwMpMHXk8fMgA5Vp0Fqu++BioehErudhRqrQTG5Mx9J59XJHodmsNNz6?= =?us-ascii?Q?IOcjq1J2IHlBuVcjC53sRUjNv99v08bhEaozX5Bi6lTkPSLPIJdUStnfPb6P?= =?us-ascii?Q?LkTCwzO0UuLc2trti34wX4lAcerd7SJzlVRpN1QOwQNIyJLo9qgMkZPkpjne?= =?us-ascii?Q?Fb3fj3FPCP71OOYC9cWyE3tXjowkYqbfSLKUsFuf+J8yK6sGKmKdCCTKP+nc?= =?us-ascii?Q?NLajysonsqMC26ALYFEahXFEs3EzrJgaimilw5Qtj3CU9+WESDRWnXL1oJed?= =?us-ascii?Q?ikj70U9/k7vCw4/wBWCNlnFsak6Ig9ByJ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ft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 6:CDluoD5Ukj7v0uNI/MJwgVJ6K1wMEvKTpM/lbFvYCY6IN+cv/qTMTNbkMTGAj/AndXZcvt6iHKS4Hc/nDJcz5VOb5aFBGBmV2DQ7+INFi9Lf+yYfxnTOuvPmRLrubvN1oVT39nFBmywRF3aoAdcVtlH4qVhSZai04A2WWSgfpF/BTHF7O+nhbPMNIpS7icpSWm2DpczA/W431hrHiwyKvxHkI4dgREItWhmp4PDAY/b2UGvUnuvmYOntBThUNh67FQLHrmZEqcrDD7WuKtm84sUZevygHtYlN+gAx89PmyReDXb1OMxYrOg5URJPsfni3eXSGrIEZSEHQFZyB4yoELdhHg2JxNT6ChhtvKw7hDM=; 5:c7AICN4DS5XwAN79WVal8X1SReFxyu5Y3VdNn+xK4NtszxwKbnTLUFoE99/+7ZRWtFcoZOelHcMTY6ytz8EDwzCDwfm8NrzGP34jKQ46UF3/RU31laVOyZWT5skY0HaGvy5gXvnkM3QOdYV0pkYYzdRIEpuDnaTGKqBlSrKpmnY=; 24:06dJqO4+NArhfjCOz21BhcrCgiSp78i6me8V37Bqc8xTJY2omGHw6YWZKEKF9PpyOY8xl9poicVflU+sMZvaen4oPISdHpgXpZswM2vF4To=; 7:D8pBLMrraM8M5lkBJPnHLW+4ZXt4cniitVFKlktuu3t4aHqcFJBdQEgvyXlniYmPHJsA5bR+iavDitLUa2bcAXTSCkQ34XukZvUaTEviEkmHjTldgbagfCM3x7r7yCINd83xlyMoAKpD6v4Su4xWuI0NtctYT67ULzN1XFJ6yPnJwzFm76sn43Q5o/InyzmXmZ5TjdTAduTHWMeQERQttJeXs5wrlQCNy9g3zKLII4pV0b49NVr/If/HhDuF96Pu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1988; 20:WcLPl6vG83l+BbTUZ8KVwS2QhQG/StTFLlxfhcrO4r60XoS8qPzrqjtB4+TD1XWgMoW2usP4H7Z42/8FreUm2UQ9Vso5/XprJiSqud/Rae8SLf/xrekTVNcXks2nJBPH2QtXsf0pJGqShUt/wQnM2kIdC/WjteBrvnROj2MCVKQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2017 16:51:19.2844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39a3c481-8d0a-4627-edc7-08d53036eca9 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.123 Subject: [Qemu-devel] [PATCH 4/7] 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, 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 --- 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 3882052..eca6a15 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)); }