From patchwork Fri Sep 6 16:01:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 11135637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 453CD1395 for ; Fri, 6 Sep 2019 16:13:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 254652070C for ; Fri, 6 Sep 2019 16:13:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 254652070C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GrC-0005yk-A7 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 12:13:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgI-0002S0-Q6 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgH-00059h-4O for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:37910) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgD-000529-Sr; Fri, 06 Sep 2019 12:01:46 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgC-0005vz-LQ; Fri, 06 Sep 2019 19:01:44 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:17 +0300 Message-Id: <20190906160120.70239-7-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 6/9] scsi: move unmap error checking to the complete callback 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: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.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 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 *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]) @@ -1650,7 +1647,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)); }