From patchwork Wed Oct 31 11:34:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991358 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="f0HcZeOC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRK811v1z9s1c for ; Wed, 31 Oct 2018 22:42:36 +1100 (AEDT) Received: from localhost ([::1]:58765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHotN-0001bX-Jf for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:42:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHoml-0003tR-9u for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomg-0002L3-Nj for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:43 -0400 Received: from mail-eopbgr00117.outbound.protection.outlook.com ([40.107.0.117]:4800 helo=EUR02-AM5-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 1gHomc-0001Pq-Sj; Wed, 31 Oct 2018 07:35:36 -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=mSXjC80FX+5zNt7wKAXpE3bWf7CKk3s5dS53dqGHe1w=; b=f0HcZeOCHNLETbR7vZU6SiAvOJp03nWAeExIcRXkSP+kW4q8fTJWkHoYZqg681vgYq/RmIauokRt+XkWeBBxGgR+hzhW390kbvyfXtwH9ARJDhu9gU+R9XplUJgrR0XFZobxcOAn9ai0b3a5tV6gezG+Fc2D8g+UKYANArP2h1E= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3007.eurprd08.prod.outlook.com (52.133.14.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:34:57 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:57 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 6/9] scsi: move unmap error checking to the complete callback Thread-Index: AQHUcQ2/+ZWUvGjQA0CS+vVEk2lOkQ== Date: Wed, 31 Oct 2018 11:34:56 +0000 Message-ID: <20181031113418.29796-7-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3007; 20:cpCEIkKYNheyce9eerIAjbHLSd/rAsI99QJcx3EBmYN97CHcuL1CWcg4Pwe91c/16Ycyc324oRBS3ualjs3cI9xleGxuyxigXURqG8YaDeIpQsg7NhH6y/9O1rGbGsyIbrCxJfgsuNAAGXFnGv2f8JU9/gadP4Ee4OLnbKfFygA= x-ms-office365-filtering-correlation-id: b32f542c-073d-428b-7318-08d63f24e223 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3007; x-ms-traffictypediagnostic: VI1PR08MB3007: 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)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3007; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(136003)(39850400004)(346002)(189003)(199004)(256004)(7416002)(5640700003)(6486002)(2900100001)(446003)(11346002)(53936002)(2906002)(14454004)(316002)(68736007)(36756003)(5250100002)(66066001)(86362001)(99286004)(6436002)(54906003)(14444005)(2501003)(5660300001)(2351001)(1076002)(102836004)(106356001)(44832011)(81166006)(81156014)(6916009)(97736004)(8676002)(25786009)(4326008)(52116002)(8936002)(2616005)(6512007)(476003)(26005)(3846002)(386003)(6116002)(486006)(107886003)(7736002)(76176011)(105586002)(6506007)(478600001)(305945005)(71190400001)(71200400001)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3007; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: hy/dS6iju5ZT9MF+jiaICOoGLcjV9OeF/utd+kbN8qzHT7f75AHXkyjCtDm32bx2cFc0leRXO745d8jKY4VMDmFm1BRGVRxraxN8fVBB8FxCey1uhi09wG1tiPAsxIm/2psq0aGqtS7ksQsz9ol6RBz/PloNZ0rfu8tRPrPZ2fo0vQ9Rv6xqcp/Z3M2k7OhxbPGL8vZi6Zi8Du/E94y9DwRBqiYnVa3d2kxoF9VgQsWrCnZ0x29zfvLXaXjSw9XtGKTqrwiELziLWKT1P63BkaOKdXuwwUbSSwIqOkbd6fJVQrKu8nv/XRMqHlAL6CGIVwEnHereypAfGdGb8SwfhqS1OjQD0aWykbjhZEN+6D4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b32f542c-073d-428b-7318-08d63f24e223 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:56.8973 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3007 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.117 Subject: [Qemu-devel] [PATCH v5 6/9] 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 661228b569..e132504913 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1658,9 +1658,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]); @@ -1696,7 +1693,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)); }