From nobody Tue Apr 15 21:45:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570710397; cv=none; d=zoho.com; s=zohoarc; b=LwWvVxo62l0yBOTFPaKPr2yNsriQaS8iCmU4ky3bsYZNb2WabUvrZ3X4CYcNaCpQcKwXjCpBOftVOHdbhFJgWSqBw/94tTjOZHd5XhZMERnM9bGB7/aDT9x47g/ULqB1Q5ua1ME6MVSOI6UAAPCucUZoASRFqTv4T089HrXj8D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570710397; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8IsWWpufp+6TpFF4mbYDY+iVbrc3/I25tcr7RLQT1n8=; b=N1+aUd0O+3PyTtrQpM7P4de1pdH2Ld27nHxp8LwWHyxNoRd2T23p+ZO6y7g01UP/HMVbJIoP9D3WEZmbhd/dwnmQqlGRN/hB378DWaDEYlIoQNp0i7puyePiziEhcyDsZXaCGpmLwNM0FOmTpcdM/inMx/wlYgklsXyStMo+zJY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570710397465177.84166331510983; Thu, 10 Oct 2019 05:26:37 -0700 (PDT) Received: from localhost ([::1]:37180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIXWd-0005lK-TV for importer@patchew.org; Thu, 10 Oct 2019 08:26:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52080) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIWrL-000709-Lg for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIWrK-0008KL-Gr for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIWrI-0008JV-5d; Thu, 10 Oct 2019 07:43:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67F4E87638; Thu, 10 Oct 2019 11:43:51 +0000 (UTC) Received: from localhost (unknown [10.36.118.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E4C460BE1; Thu, 10 Oct 2019 11:43:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 22/36] scsi: move unmap error checking to the complete callback Date: Thu, 10 Oct 2019 13:42:46 +0200 Message-Id: <20191010114300.7746-23-mreitz@redhat.com> In-Reply-To: <20191010114300.7746-1-mreitz@redhat.com> References: <20191010114300.7746-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 10 Oct 2019 11:43:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Anton Nefedov 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 Message-id: 20190923121737.83281-7-anton.nefedov@virtuozzo.com Signed-off-by: Max Reitz --- 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 b3dd21800d..a002fdabe8 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1610,9 +1610,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *dat= a, int ret) SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); =20 assert(r->req.aiocb =3D=3D NULL); - if (scsi_disk_req_check_error(r, ret, false)) { - goto done; - } =20 if (data->count > 0) { r->sector =3D ldq_be_p(&data->inbuf[0]) @@ -1650,7 +1647,12 @@ static void scsi_unmap_complete(void *opaque, int re= t) r->req.aiocb =3D NULL; =20 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)); } =20 --=20 2.21.0