From nobody Fri Nov 7 00:49:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544628708304188.847104373133; Wed, 12 Dec 2018 07:31:48 -0800 (PST) Received: from localhost ([::1]:45602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6UA-0007DI-72 for importer@patchew.org; Wed, 12 Dec 2018 10:31:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6MZ-0000py-6b for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX6MX-0000Ee-B6 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:50 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:55390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gX6MW-0008Vd-Vo for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:49 -0500 Received: by mail-wm1-x330.google.com with SMTP id y139so6132645wmc.5 for ; Wed, 12 Dec 2018 07:23:36 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id u10sm15878859wrr.33.2018.12.12.07.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 07:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uPaT0p8VJsvqef3cLGXCD9zDoUfQqofW9BxFkZ06I6g=; b=o4L/fDodRSn8j/eyJaIja6P6CobQwB9Qn1tLBc/TK8CTVaQiGrXfRju1uNQYQp03an Kr7110ndlWXqw+WdU+F2dYcJ581EzRxwSXv4FcOtuze7MqVaXTxhjBc09thiV4/vUii8 aPnPWiDenrzGbPmxfy6I1QkMMia7TVh59rdH3toq9YG3tZKW/EBJ1M5VEQxw52KZC8UN Eyb7j6xDiVpGYXEmcYXAKBsXI/CZKWopz7opj5djUtFX3lij+83mmNmirg8NDzLpH/pi 8LyFTT9lASbw+Kg+OEcOsC7PJIQ9CY+jaSjISEf1AKXeIlvDMAPBMdLqOwS4oCHpm7+E UYxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uPaT0p8VJsvqef3cLGXCD9zDoUfQqofW9BxFkZ06I6g=; b=cyv4wD9EC4aP0UpothiZiYm1wwdlvtFrs7v1AnuCx/7Wffs2/rFBAhbU3Qa1MYa08J c023pkBQn2eSXhlsLI1wSdTRVlYOypOYyBVEy43uaOj+TgQl7DgmwVgX4hz9Jok6xHwz 8ARja+BKpaPlgTJqN3QEMQndvNd6AXEpp+G7Yrpqw5R+PgKRfKwmU6fZu4l/vddU7ukT SMAI7/ugZBq7VHga2P1AMzUidiWTQrmGIYThH6jKBSxVyBSFrFFNn0zNIqs6jIE7L2xg zbnRl0Fjhkg6LCHCh4D89A7tm7woGTq+4wR5/LNpg1jypodgAWTo6BGDgO6qlu0q6nFC FR1Q== X-Gm-Message-State: AA+aEWbQVpOknUzGkReMUsyCfEe4m727XdJa5UHk65y1rokoccVu4nyE qBaRlQVPdPlXhI9TN0Qq9UAKwzGt X-Google-Smtp-Source: AFSGD/XAoL18wxrqartSHfvQlqiJmibpvxg6lG8lAkLB0CgDm77vSefMT9/Hq0hSoKBA6VJdWPP+Tg== X-Received: by 2002:a1c:8acf:: with SMTP id m198mr7140746wmd.143.1544628215115; Wed, 12 Dec 2018 07:23:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2018 16:22:36 +0100 Message-Id: <1544628195-37728-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544628195-37728-1-git-send-email-pbonzini@redhat.com> References: <1544628195-37728-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 15/54] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes 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: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The libiscsi iscsi_task_mgmt_async() API documentation says: abort_task will also cancel the scsi task. The callback for the scsi task will be invoked with SCSI_STATUS_CANCELLED The libiscsi implementation does not fulfil this promise. The task's callback is not invoked and its struct iscsi_pdu remains in the internal list (effectively leaked). This patch invokes the libiscsi iscsi_scsi_cancel_task() API to force the task's callback to be invoked with SCSI_STATUS_CANCELLED when the ABORT TASK TMF completes and the task's callback hasn't been invoked yet. Signed-off-by: Stefan Hajnoczi Message-Id: <20180215111526.2464-1-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- block/iscsi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index abb872d..a7e8c1f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -295,8 +295,12 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int s= tatus, void *command_data, { IscsiAIOCB *acb =3D private_data; =20 - acb->status =3D -ECANCELED; - iscsi_schedule_bh(acb); + /* If the command callback hasn't been called yet, drop the task */ + if (!acb->bh) { + /* Call iscsi_aio_ioctl_cb() with SCSI_STATUS_CANCELLED */ + iscsi_scsi_cancel_task(iscsi, acb->task); + } + qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */ } =20 @@ -947,6 +951,14 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int st= atus, { IscsiAIOCB *acb =3D opaque; =20 + if (status =3D=3D SCSI_STATUS_CANCELLED) { + if (!acb->bh) { + acb->status =3D -ECANCELED; + iscsi_schedule_bh(acb); + } + return; + } + acb->status =3D 0; if (status < 0) { error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s", --=20 1.8.3.1