From nobody Sat Jul 25 08:54:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784720844; cv=none; d=zohomail.com; s=zohoarc; b=SNK5Sdt+3n91OM1rlt5FQEQ+2hhzomhrkEB8vzXeCdpM+/lfprfOfgcj8ih5T8T55YsAEWYlx7JvmgbKZstrzLoltB4qIHUSQpIjfsm6zS817I001u+JiFir2xOulyXEPW8h15aNGZkfixDlRfcVoru0JMGMsTriysxwFsihTWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784720844; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k4yK7lDliBq/8FU36kdREjJRsf5raunpvsSFKyNur14=; b=hQTls6i9XdbFFRPPHY6IKCAXg92q7bwFvk4/ELd9tepKrTLuckyYTMy8hzvYNVWKNtZeSxxWPUPO1OOcMyJhBxjrJ+EuccPZpiVqACZT2nfGzcFEjaPsYOtjp/TYHtXX92Ja79e9zDwtmoAJFfPbkM52ozc16BdCSzdSRdhcYsk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784720844864228.83190986755767; Wed, 22 Jul 2026 04:47:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmVPA-0004VM-6C; Wed, 22 Jul 2026 07:46:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmLN0-00009C-NZ for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:34 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wmLMy-0002gA-96 for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:34 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-c197eaaab00so434154166b.0 for ; Tue, 21 Jul 2026 18:03:31 -0700 (PDT) Received: from Arc ([109.245.172.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebac95sm32694066b.47.2026.07.21.18.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 18:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784682211; x=1785287011; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=k4yK7lDliBq/8FU36kdREjJRsf5raunpvsSFKyNur14=; b=Yr66Nc4+wi4NDDYmkdcgn559/eD92A8LiDfx4fuBU31QzbyJDoLAaQnXPzMH4uTcz5 xZsXyRigAvTWaxEc3ru6mHcUo+aVwTAFTc252sMwrwKky0lc/nLPdNoux7RaPIZmv5Tn lDkZVEOpazUFF4A6S4POKJcxHCP0V4f34ukWsqzYfYyK0MksNcdq04YJamdN9s42AfDC XXfnkbHzxUMMo21uLJdBljHzzTlFK2IWK1O2N1kWyouck8dfK3N5az/kZD2GxjI2JtML UhY/GuRw2WwGpP4TibQfeVfPI+QmaV/IjGYaVSQO0d2ERt0o5rczog/VQ7VgRFSz8QWo /HQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784682211; x=1785287011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=k4yK7lDliBq/8FU36kdREjJRsf5raunpvsSFKyNur14=; b=KXnushHE0x5Dks0Gf+WLaCfhTFQvQ9uZ4GSGzTWs7fj55wPL9g4HHJStRMONMGnW1K v5rEWFW8QIlEk9soP9LtUQGX14lz0+LebIm7c0L8hWhw+mZKeLZ82NxsT6big7ALRaVS y7DfF5JITO6XfAgG6kZFVx/MrLg9vQVj/pDWaeQEA0LUdtmpyPCvJ5Nky3KEx8ZxtQvC 2LmNl+LNVY6DsQ0ad1/jG9h/CcINnZV9dlmKSFxXFcBD8LHLjkNld/D6y2+NOrDc3HrL RgxZBXa4DuFfGU9DeuRX7SLSv3HqUGjx3mb3wvzbqKF5GsicwCpHmQXQuoZ7IRGzSURr +wkA== X-Gm-Message-State: AOJu0YxPyYFZQCzuVJHeIhAlTtiNO1XbuJ1sCQqx/tW1SvEPRd4FXPUJ 8XuVlhJkmROVV2jcmk8dzk4NGGpWJAjUh6I6zQEaq0SyMiOFLQDju1s7jnfWv+yoZdc= X-Gm-Gg: AR+sD13R3Yzd3Te/XJqXy09ae4Kcz4sRmdYvoLpe+p3KUeAKn+TcaUi/JS8yoEM6jMm YQ+2mnI8+MBRK0gJVrIHCxkh5eOTinHjupT7KHPc+/pY8T3kFe58RfDqq4ICzlfR+toCn89iWD+ lzHkT+CPXStUvamfjXWU50RbRGNq03Sk4fVf6nMTDy+gOjK62DiEeA06wNvNfoxsTVP1VhYeoco hcE3NrAIxh4C98DKOHy2o2Q0hqoPwUsXZymhUNcBegn4gxDsiMHEpD23fJ4fhIR+53HX1NSrUyW o0AE253BI/W3WOxv8jWPga9oUhdrCO8G+4R5+1pB7/waljBbQs/XjupAiJx34P5LZBtzATZgjxY S5hCe+ufgo7p5rJCOGgmeQypEztxiUSyDoE9ARS7+NCBb/W0WcxBTywPfW+TRjbwfaA== X-Received: by 2002:a17:907:1ca4:b0:c16:19fc:9976 with SMTP id a640c23a62f3a-c16b48ed368mr834040966b.53.1784682210508; Tue, 21 Jul 2026 18:03:30 -0700 (PDT) From: Konstantin Nigmatullin To: qemu-devel@nongnu.org Cc: Konstantin Nigmatullin , qemu-block@nongnu.org, Paolo Bonzini , Peter Lieven , Kevin Wolf , Hanna Reitz Subject: [PATCH 1/5] iscsi: detect dead iSCSI sessions via local NOP failure counting Date: Wed, 22 Jul 2026 03:02:50 +0200 Message-ID: <20260722010254.424820-2-rangolit@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260722010254.424820-1-rangolit@gmail.com> References: <20260722010254.424820-1-rangolit@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=rangolit@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 22 Jul 2026 07:46:12 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784720845602158500 Content-Type: text/plain; charset="utf-8" libiscsi nops_in_flight stayed at 0 on a dead TCP session, so QEMU never noticed the target had vanished when command timeout was disabled. See: https://gitlab.com/qemu-project/qemu/-/work_items/3067 Signed-off-by: Konstantin Nigmatullin --- block/iscsi.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 7d6bf185ea..bf74b4cb65 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -103,6 +103,8 @@ typedef struct IscsiLun { bool dpofua; bool has_write_same; bool request_timed_out; + /* Consecutive NOP-Outs without a successful NOP-In reply. */ + int nop_failures; } IscsiLun; =20 typedef struct IscsiTask { @@ -1398,17 +1400,37 @@ static char *get_initiator_name(QemuOpts *opts) return iscsi_name; } =20 +static void iscsi_nop_cb(struct iscsi_context *iscsi, int status, + void *command_data, void *opaque) +{ + IscsiLun *iscsilun =3D opaque; + + if (status =3D=3D SCSI_STATUS_GOOD) { + iscsilun->nop_failures =3D 0; + } +} + static void iscsi_nop_timed_event(void *opaque) { IscsiLun *iscsilun =3D opaque; =20 QEMU_LOCK_GUARD(&iscsilun->mutex); - if (iscsi_get_nops_in_flight(iscsilun->iscsi) >=3D MAX_NOP_FAILURES) { + /* + * Prefer libiscsi's counter when it works; also track locally because + * some libiscsi builds leave nops_in_flight at 0 across a dead TCP + * session, which disabled disconnect detection entirely. + */ + if (iscsilun->nop_failures >=3D MAX_NOP_FAILURES || + iscsi_get_nops_in_flight(iscsilun->iscsi) >=3D MAX_NOP_FAILURES) { error_report("iSCSI: NOP timeout. Reconnecting..."); iscsilun->request_timed_out =3D true; - } else if (iscsi_nop_out_async(iscsilun->iscsi, NULL, NULL, 0, NULL) != =3D 0) { + iscsilun->nop_failures =3D 0; + } else if (iscsi_nop_out_async(iscsilun->iscsi, iscsi_nop_cb, NULL, 0, + iscsilun) !=3D 0) { error_report("iSCSI: failed to sent NOP-Out. Disabling NOP message= s."); return; + } else { + iscsilun->nop_failures++; } =20 timer_mod(iscsilun->nop_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) = + NOP_INTERVAL); --=20 2.53.0 From nobody Sat Jul 25 08:54:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784720811; cv=none; d=zohomail.com; s=zohoarc; b=SSpCuZaPqHCLR6gpDdZQjX8uAE16x22/QyrRPbpuiKgQq18md/2IocOfjle1zC8NrtFwWohcp7ko+DMPElP9lQdED8f55bvORnDSerJ/vNxLZ3L+k7NqjyYJqrSrTDDurqqS8ut2n/E6ygpf/Ny6qJoHxtU5btmCs5SVEI0JCGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784720811; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zdT93fDs6UB1uSpu3Au/OcyMYvv7vHTYp3jSGdCEpFU=; b=WgCmUcg1sbokkG52QFNg0Xnwu//2pq3tApLc6iJ3+hAAkzt0ZOYQBwK2v9HxbRdvpuJi3Ab8HxAGcPdxB8iAZHPH3dzvMSDB9lh1U/YeOnU/rwEqoUspGaTgIF957I1MaCgpc5TpYTba3Xuhfd8mte6+IxxNztGWWG3tKWianjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784720811021291.7574191259041; Wed, 22 Jul 2026 04:46:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmVOx-0004F3-6H; Wed, 22 Jul 2026 07:46:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmLN9-0000AR-3s for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:44 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wmLN3-0002gj-3m for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:42 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-69e8ea2783aso5412719a12.3 for ; Tue, 21 Jul 2026 18:03:36 -0700 (PDT) Received: from Arc ([109.245.172.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebac95sm32694066b.47.2026.07.21.18.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 18:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784682216; x=1785287016; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zdT93fDs6UB1uSpu3Au/OcyMYvv7vHTYp3jSGdCEpFU=; b=IFPH2cHdodoLTJSG2GP4eNzlAbO2PV54bX1GhQ85KzIQmGBqGprd1x1GPZz1vFA2VX XE3jh6sfg5phRkJVrrO7JmJGinjBOuOI/lpw7shiGptM6fs/wEe8lTZHp+lGHTee6Bxy 8bsT+HsTk+x9idBZvMYm66RBg4iP6lHMBUPMjlpxRuWeG8enM+ef7ak21tkvjIdM3fL+ vah0D0ZMwTDclJJLTK193rk2BmuF30oMs7FTVetf+Mc8GMv9KHxePzJGIGgvtU/7okMt LbJYhLcoaPX8By57fbyfx9Kj3wwYnCuTJXGMA5Yji3JM0JvjMQSljJwGZwllwawm6joX hpWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784682216; x=1785287016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=zdT93fDs6UB1uSpu3Au/OcyMYvv7vHTYp3jSGdCEpFU=; b=cjE8OhtapjZhYkSEds84IkqNN0kkMbGwazAb77L/AzdPPCUQkfJf2lN/2pXuyHhlDX 8mCxYJin0/5pKK6Q990UaGCOtyGr+X92V7ASgdgotYJK5IOhuri8dY47GspO2c+Iu3kq KdWmFYL1DF0SXdxwOL7O+/J0LH6YIQlpSKFZoRSpYeVBrTdYHBfgMqQ2jDaKLKW+rjR3 2o16RP6O9sVysvqixWX+c7SLTkg4cZBi4+g/fcEuQI9pytc19IJmVEKaEMQXhtSR98OM FaleJDJbf/aQaRqMg8NKaExky/e0Sq/k08EZN2bGCpUaQhhJviZVByinBWt7b0xAAPNa o+qQ== X-Gm-Message-State: AOJu0YzCpOah3rmfWdRPXJ/KOjK+Z5HkaHzfa9D1nvPlhzwpkuW7f98S fPyyldCqNKXaj0I4VM4RhDl4hBYljauyKdmDDXKRLTFy3LAQW/GXc2qzhnB2jjCZ1zs= X-Gm-Gg: AR+sD100b8aFIBikhbMgJG6wPls+3BN9rCw5mhY5RVPmlgAQrLaBq87xBpe23/eCjZX tLVyomkGTRDng8E7DEgy119jTAKA2dnNFY+ECP6xmEBgvUk1XFvRCw1EvLMJCiZ/KBhaLzxTj10 8kUZFcKu3KrYa2Gg4srhhZcx5t7Q8Fo5cSAo+21Fs+lGJZ5m9hACirW9DjcXvoGJStzw4UOCk1s lYSID/B/QXgu7sZYQWgg9lYWdEDTTsXnTldLde+VF5Qv4iFc22ibFqzuIHb16bDiidYJ6gL30TJ 0AYc4mSmcemfmsRlgBhhjJOOpaRQnmE8U7XueIVbKSOOQ/pxhCetr6Im5jyz9i8FaCp6N0Gx5RO c5MPhQViZA5F/N4MVXgO8Ibt5yuwLQ0g8fAnXQP8gjPUgtEOKC8GLdG9iABpfYk+a7jQqkIyTNf x4 X-Received: by 2002:a17:907:d22:b0:c1c:254c:16c1 with SMTP id a640c23a62f3a-c1c254c27bcmr158104566b.0.1784682215539; Tue, 21 Jul 2026 18:03:35 -0700 (PDT) From: Konstantin Nigmatullin To: qemu-devel@nongnu.org Cc: Konstantin Nigmatullin , qemu-block@nongnu.org, Paolo Bonzini , Peter Lieven , Kevin Wolf , Hanna Reitz Subject: [PATCH 2/5] iscsi: stop retrying timed-out iSCSI commands Date: Wed, 22 Jul 2026 03:02:51 +0200 Message-ID: <20260722010254.424820-3-rangolit@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260722010254.424820-1-rangolit@gmail.com> References: <20260722010254.424820-1-rangolit@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=rangolit@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 22 Jul 2026 07:46:12 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784720813307158501 Content-Type: text/plain; charset="utf-8" Retrying SCSI_STATUS_TIMEOUT up to seven times kept drain and shutdown blocked for minutes after the target was already gone. See: https://gitlab.com/qemu-project/qemu/-/work_items/3067 Signed-off-by: Konstantin Nigmatullin --- block/iscsi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index bf74b4cb65..e7f2d54986 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -240,19 +240,21 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int = status, =20 if (status !=3D SCSI_STATUS_GOOD) { iTask->err_code =3D -EIO; - if (iTask->retries++ < ISCSI_CMD_RETRIES) { + if (status =3D=3D SCSI_STATUS_TIMEOUT) { + /* + * Do not retry timed-out commands. Retries keep in-flight I/O + * alive across a dead session and can block blk_drain_all() + * (and thus QEMU exit) for minutes or indefinitely. Kick + * reconnect and fail this request. + */ + error_report("iSCSI timed out: %s", iscsi_get_error(iscsi)); + iscsilun->request_timed_out =3D true; + } else if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status =3D=3D SCSI_STATUS_BUSY || - status =3D=3D SCSI_STATUS_TIMEOUT || status =3D=3D SCSI_STATUS_TASK_SET_FULL) { unsigned retry_time =3D exp_random(iscsi_retry_times[iTask->retries - 1]); - if (status =3D=3D SCSI_STATUS_TIMEOUT) { - /* make sure the request is rescheduled AFTER the - * reconnect is initiated */ - retry_time =3D EVENT_INTERVAL * 2; - iTask->iscsilun->request_timed_out =3D true; - } - error_report("iSCSI Busy/TaskSetFull/TimeOut" + error_report("iSCSI Busy/TaskSetFull" " (retry #%u in %u ms): %s", iTask->retries, retry_time, iscsi_get_error(iscsi)); --=20 2.53.0 From nobody Sat Jul 25 08:54:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784720851; cv=none; d=zohomail.com; s=zohoarc; b=cMPVnJtHSexpE7qhCx9Q9I6AjjNd5cgM4pnu2cS0GNCc7a917ToyHJXBb+h5gNo/oitLiVPWZbf0klCH+mE8rLe323vFLZVmNKSY8BjE4yg2mQff7WWNrw1hxp8Liybt7xnQAYNeCsPUUr0FMWEbIqm1b7+avZ67wwVz1RAcYsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784720851; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ED8ZNuacLaQvPx2m8uKBXJmG6gJ49gu9pZqGBkx0woU=; b=bH9PYGiKoWq0VStiw/6+/sQysqHuG5F33CR01hLu1p5vctNAFMCFsMAY2DFYUDV0zrHlqudmjKEx0LtAb8KHQdE5r0sgnzFasSNpOS2VhTWXpHIndhfIiDiZHk5A7pF9SQB8jNvt7zzUEWx3eIUC6WDTfMKxMBjR8bEAfRuLM/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784720851448465.8933956211521; Wed, 22 Jul 2026 04:47:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmVP8-0004Lm-57; Wed, 22 Jul 2026 07:46:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmLNA-0000Aa-GF for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:46 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wmLN8-0002gw-H4 for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:44 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-c197e7e4e94so451762466b.2 for ; Tue, 21 Jul 2026 18:03:39 -0700 (PDT) Received: from Arc ([109.245.172.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebac95sm32694066b.47.2026.07.21.18.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 18:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784682218; x=1785287018; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ED8ZNuacLaQvPx2m8uKBXJmG6gJ49gu9pZqGBkx0woU=; b=GpY8zogXYHnTBvfEOBxBjcEzjINNwZLBKGSNQaW0LhE8R1hFhZJMAazfRBYBBKSCNq IO1xuxBRnIX0RMyqevh850uY+Y/79wCE4Cx8UrEch7+PSe93tuuQIn2F9wAx3acTGX4a BHUSiwFPR5rNL4GbSINrmgTrT1TeUbXwSGNYy+s7T733683s4NpA/F6TCb7KrTiwLBZK l+G7ZHzOR31XMFiA+12nHQvCDKtDZIhG6/aqEdDf/RYC3GCOpcDo5Fx7gyZNA3T5xRNr kzdrU2Dc8T0YESVbH9zZxVuC/VqdpwsW+Rpja5RQle8q8g017U/DjRwypqzpq4hHgo+0 i68Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784682218; x=1785287018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ED8ZNuacLaQvPx2m8uKBXJmG6gJ49gu9pZqGBkx0woU=; b=nzvcobQ6HI8tqkmDYVFXVAH4ctkIhFbfgEmN75FpcV1WdHpSIZE1pDevh6qhezWqIC YkdvzWJNyjKeXLUlFjmvpJkR2bltuAC1EexGI30+r+mWZh50+wuMkoMiqbtnx3Hw2Ya8 o4MJfIGyN/yaMiSHmitj8K8uJEHPhV0A83dNV9aIbMI15ZLrwVXwgYvyLHQuigrdGlBx 5z+EXTSe8WKrexigqgpW/BL8gsrS6Bqz8MIbNfpMKFYDUTj1QBq2oMtQ33a7AmVfcREZ P5+1f9B3ScDPdMntgZ77YDGi2CP8RvVQJEZkMoOMJgam0h8OpuiU309We/MGkUsg5uEb gq8w== X-Gm-Message-State: AOJu0Yz9WsCcKuoRrvS5eeKj7mNPYPAWtn5mDMf8KFBLCRS8trzkNzn0 PBCLzVXus4oJhIVWMpfqXA22Zq+LPR7nVYhqdIpn6VHlnPbGvdBuUUVXdfOovks37OM= X-Gm-Gg: AfdE7clOKQTCFeJUbiKBzQNmvMR2/9sfKbBCpRsUBwftOlWMIeBbuSJvUJD2SgZ+5yx Y+tGSjW7aO6WWYAYRMW7TBlz8cmBSvE/lnWxXs6nXpjgvFTbM3Otu2aeyhla6F9awtgG9309r1/ l7HkmzIf2LkvblilRwcF71WOer1jfItxUHr4/uUTNHglPawRGS49g486Hwkgu1bKxYi8Cp/AWx4 rMEQnpupV5mDeEZclb/trvu695PtTAV1GQfbxzB2NtnC41FWpUITwog4mW85YH5KDR6kpglWn+g 7ooq0aFkz83SBJEiFulCsvUERy+e9cIQ7uUawvB+Mwkug1CQwFIjSf0sgdD9So6Sdv5nIbvIKC5 egLQwjMzuoWvslqioZLx3a5VLkfoQyNXJJHi8kji6aHAhwv615YQPeeEuAO7TmSigLg== X-Received: by 2002:a17:907:74a:b0:c15:cee4:5244 with SMTP id a640c23a62f3a-c16b46f30abmr925111566b.21.1784682218221; Tue, 21 Jul 2026 18:03:38 -0700 (PDT) From: Konstantin Nigmatullin To: qemu-devel@nongnu.org Cc: Konstantin Nigmatullin , qemu-block@nongnu.org, Paolo Bonzini , Peter Lieven , Kevin Wolf , Hanna Reitz Subject: [PATCH 3/5] iscsi: cancel in-flight iSCSI tasks when the session dies Date: Wed, 22 Jul 2026 03:02:52 +0200 Message-ID: <20260722010254.424820-4-rangolit@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260722010254.424820-1-rangolit@gmail.com> References: <20260722010254.424820-1-rangolit@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=rangolit@gmail.com; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 22 Jul 2026 07:46:12 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784720853331158500 Content-Type: text/plain; charset="utf-8" Coroutines waiting on a dead target never woke, so blk_drain_all could not finish and QEMU would not exit. See: https://gitlab.com/qemu-project/qemu/-/work_items/3067 Signed-off-by: Konstantin Nigmatullin --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index e7f2d54986..330f17e08b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -381,6 +381,12 @@ static void iscsi_timed_check_events(void *opaque) =20 if (iscsilun->request_timed_out) { iscsilun->request_timed_out =3D false; + /* + * Drop local in-flight tasks so coroutines waiting on a dead + * session wake with CANCELLED instead of blocking drain forev= er + * (especially when command timeout is disabled). + */ + iscsi_scsi_cancel_all_tasks(iscsilun->iscsi); iscsi_reconnect(iscsilun->iscsi); } =20 @@ -1427,6 +1433,7 @@ static void iscsi_nop_timed_event(void *opaque) error_report("iSCSI: NOP timeout. Reconnecting..."); iscsilun->request_timed_out =3D true; iscsilun->nop_failures =3D 0; + iscsi_scsi_cancel_all_tasks(iscsilun->iscsi); } else if (iscsi_nop_out_async(iscsilun->iscsi, iscsi_nop_cb, NULL, 0, iscsilun) !=3D 0) { error_report("iSCSI: failed to sent NOP-Out. Disabling NOP message= s."); --=20 2.53.0 From nobody Sat Jul 25 08:54:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784720833; cv=none; d=zohomail.com; s=zohoarc; b=dSY1i1PdIwWdNojgTym9uqscjPYqsNC1/ItgbQmlDyWOp2tokVcZXtGp3FSzWy48zVr49cSSi6dZEMb0DhMfFflKmgdg8zRMowyc/sbm342s8MCZpR54hPvcKY5Bd8AWPVrskAx6OJNPtI0tdzkpoWLE4XK6iBUIbPQSt+hwlAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784720833; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Erq1uqG60FGH82vJJ5aDBApZSrpA1rGh49YRLXOpd+0=; b=h4FyUjV4dFk8UaydgZy1oobI5BlFcHPG2tV18BmVwHi7EydMI8TC24uaFlHJAFJ7pNeTg48lYCUNqT2LRVyVbq01X5tnFMDXI0XvGVt6eAdRvZDgeM9pnQkWkS2W0jlKM1dE3uhnQz9b3JCAHgBTfYhqZ7aAMw0rRZb/p3zCHFQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784720833387336.0747110449969; Wed, 22 Jul 2026 04:47:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmVPA-0004XY-RR; Wed, 22 Jul 2026 07:46:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmLNC-0000Aj-3F for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:46 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wmLN9-0002hA-4o for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:45 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-c15d3cd51b2so1369095266b.3 for ; Tue, 21 Jul 2026 18:03:42 -0700 (PDT) Received: from Arc ([109.245.172.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebac95sm32694066b.47.2026.07.21.18.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 18:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784682222; x=1785287022; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Erq1uqG60FGH82vJJ5aDBApZSrpA1rGh49YRLXOpd+0=; b=Oc9EeDhG7Rggt+7SmRenTzZUmMY82AlQ8lHG4Xvk0TS70tjoVaRxBH1D9Sr+TBxLXP tJ53w7iKh9XTXJ0O9bhEtGvHlsOc9lnWdUvx9XcX7EjNOWMqzdIga6iC0hNStWGaIWlB ER7hlMfTZHSlswmQ5fmTCkVoIetc0WOPFFKf2Ol6U/TIMjQWwoHu7Bu06qze/iVFbk5o m+OdHqhFjsg76eAoAUgrocgnKJHTJvUuLA+ERyV9+lhAT8hgeI3SMeiiA+dZRY+uuwst WMJLv9t5dTZ7aox+4kVEC483DcNfDZttgVvIFrTrHm5zxqZq0jXROMoGHaRJTJDAjg3m EH7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784682222; x=1785287022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Erq1uqG60FGH82vJJ5aDBApZSrpA1rGh49YRLXOpd+0=; b=eQmvLmN+i8BMnG18ROWxPllEWwTIxvEyLMI18sgUcyuUHGvfh7QdP3HCamsBzye1e0 BxjAC+bRCgMEMCKq/wx0fAb7CASM3U7yNW3wRy5qwZzh2gMlL1id4BI2jLzOMfvJSGKK Bvdktl0KOevwuQzbqpVxs08l/muISPNCN/1esh/GKe5iWb5sXmWbByb88ga5JOCKBSvR 4CoU/sL8Wyn08DuJzzD6wb18zr2uWU+DnJFRWSFygQrn0YFRjD2jwHI8z2RZlY6cFyXN 8y0leetofEMCa9lBDGpvtZw9qTgE7m0C7BEqRIJor0LtaDn+mLetXBghHxOAeB8NzBFq lRRg== X-Gm-Message-State: AOJu0YxoNlLJZpU6YN7d6z5G68RdU02C1XXwWUmottKYk8PnuJt83zDM LhaJPQGO+71MNXaNcTz5NrWa8uuMo4p6BzQ66oatNOc0S7EKghu6570jrZ8v+jt5yFw= X-Gm-Gg: AR+sD128e+GFqDxnYrtXDy71R1hBvKiJr7iHE2LsVNZf+yztp51OAqZ1z6v9U4VGjoX zmCN9rTYgkgznnt3V8Sj0UUX88RIq67VtjKH+/ZlpRCL1unLZ1cnLA3jlGjgaKmItbU0BwDmDMO xNEU+nyyaqK/Li2o+J2WXhActkm6wBM8Xx+KSK+6cTMvStlCp48ykCVeLI4DRDY6u6Y/MK4HyaF WyAGhwL9cJeLXaXQVy21XBesXgqKl49s/1ztVkzQiWenUMcN9RyAVF7990pHwdn3tqwfQ3RWxlG 6wmeGxEOpJxFgioMpI2ovWCO4Wjf7HJhluTaVIFBulv4Uyy3tKpFtWKs8ryEU+E7u2/VO6yZEhk ZhRRGWSEMePNYrPlc1uxKk2pXzNMYaFNSmnPv/7z5ZEqjSjB27qHBZR4lYG7Jnf+X+g== X-Received: by 2002:a17:907:3e1d:b0:c12:34ed:e100 with SMTP id a640c23a62f3a-c16b489328cmr952031866b.62.1784682221400; Tue, 21 Jul 2026 18:03:41 -0700 (PDT) From: Konstantin Nigmatullin To: qemu-devel@nongnu.org Cc: Konstantin Nigmatullin , qemu-block@nongnu.org, Paolo Bonzini , Peter Lieven , Kevin Wolf , Hanna Reitz Subject: [PATCH 4/5] iscsi: fail new iSCSI I/O while the transport is known down Date: Wed, 22 Jul 2026 03:02:53 +0200 Message-ID: <20260722010254.424820-5-rangolit@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260722010254.424820-1-rangolit@gmail.com> References: <20260722010254.424820-1-rangolit@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=rangolit@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 22 Jul 2026 07:46:12 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784720835464158500 Content-Type: text/plain; charset="utf-8" After the first disconnect failure, queued requests kept restarting long waits so blk_drain_all never stayed idle and QEMU could not exit. See: https://gitlab.com/qemu-project/qemu/-/work_items/3067 Signed-off-by: Konstantin Nigmatullin --- block/iscsi.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 330f17e08b..b6207d03e5 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -103,6 +103,12 @@ typedef struct IscsiLun { bool dpofua; bool has_write_same; bool request_timed_out; + /* + * Set when the transport is known to be down (command or NOP timeout). + * New I/O fails immediately until libiscsi reports logged-in again af= ter + * reconnect. Prevents drain/shutdown from waiting forever on a dead t= arget. + */ + bool fail_io; /* Consecutive NOP-Outs without a successful NOP-In reply. */ int nop_failures; } IscsiLun; @@ -245,10 +251,12 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int = status, * Do not retry timed-out commands. Retries keep in-flight I/O * alive across a dead session and can block blk_drain_all() * (and thus QEMU exit) for minutes or indefinitely. Kick - * reconnect and fail this request. + * reconnect and fail this request; further I/O is rejected via + * fail_io until the session is logged in again. */ error_report("iSCSI timed out: %s", iscsi_get_error(iscsi)); iscsilun->request_timed_out =3D true; + iscsilun->fail_io =3D true; } else if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status =3D=3D SCSI_STATUS_BUSY || status =3D=3D SCSI_STATUS_TASK_SET_FULL) { @@ -277,6 +285,9 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int st= atus, } } } + } else { + iscsilun->fail_io =3D false; + iscsilun->nop_failures =3D 0; } =20 /* @@ -379,6 +390,10 @@ static void iscsi_timed_check_events(void *opaque) /* check for timed out requests */ iscsi_service(iscsilun->iscsi, 0); =20 + if (iscsilun->fail_io && iscsi_is_logged_in(iscsilun->iscsi)) { + iscsilun->fail_io =3D false; + } + if (iscsilun->request_timed_out) { iscsilun->request_timed_out =3D false; /* @@ -604,6 +619,15 @@ static void coroutine_fn iscsi_co_wait_for_task(IscsiT= ask *iTask, qemu_mutex_lock(&iscsilun->mutex); } =20 +/* Called with iscsilun->mutex held. */ +static int iscsi_co_reject_if_failing(IscsiLun *iscsilun) +{ + if (iscsilun->fail_io) { + return -EIO; + } + return 0; +} + static int coroutine_fn iscsi_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov, int flags) @@ -631,6 +655,10 @@ iscsi_co_writev(BlockDriverState *bs, int64_t sector_n= um, int nb_sectors, iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + r =3D -EIO; + goto out_unlock; + } if (iscsilun->use_16_for_rw) { #if LIBISCSI_API_VERSION >=3D (20160603) iTask.task =3D iscsi_write16_iov_task(iscsilun->iscsi, iscsilun->l= un, lba, @@ -730,6 +758,10 @@ static int coroutine_fn iscsi_co_block_status(BlockDri= verState *bs, =20 qemu_mutex_lock(&iscsilun->mutex); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + ret =3D -EIO; + goto out_unlock; + } if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, lba, 8 + 16, iscsi_co_generic_cb, &iTask) =3D=3D NULL) { @@ -861,6 +893,10 @@ static int coroutine_fn iscsi_co_readv(BlockDriverStat= e *bs, iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + qemu_mutex_unlock(&iscsilun->mutex); + return -EIO; + } if (iscsilun->use_16_for_rw) { #if LIBISCSI_API_VERSION >=3D (20160603) iTask.task =3D iscsi_read16_iov_task(iscsilun->iscsi, iscsilun->lu= n, lba, @@ -927,6 +963,10 @@ static int coroutine_fn iscsi_co_flush(BlockDriverStat= e *bs) iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + qemu_mutex_unlock(&iscsilun->mutex); + return -EIO; + } if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0= , 0, 0, iscsi_co_generic_cb, &iTask) =3D= =3D NULL) { qemu_mutex_unlock(&iscsilun->mutex); @@ -1170,6 +1210,10 @@ coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs,= int64_t offset, iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + r =3D -EIO; + goto out_unlock; + } if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1, iscsi_co_generic_cb, &iTask) =3D=3D NULL) { r =3D -ENOMEM; @@ -1255,6 +1299,10 @@ coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState= *bs, int64_t offset, qemu_mutex_lock(&iscsilun->mutex); iscsi_co_init_iscsitask(iscsilun, &iTask); retry: + if (iscsi_co_reject_if_failing(iscsilun)) { + qemu_mutex_unlock(&iscsilun->mutex); + return -EIO; + } if (use_16_for_ws) { /* * iscsi_writesame16_task num_blocks argument is uint32_t. We rely= here @@ -1423,6 +1471,10 @@ static void iscsi_nop_timed_event(void *opaque) IscsiLun *iscsilun =3D opaque; =20 QEMU_LOCK_GUARD(&iscsilun->mutex); + if (iscsilun->fail_io && iscsi_is_logged_in(iscsilun->iscsi)) { + iscsilun->fail_io =3D false; + } + /* * Prefer libiscsi's counter when it works; also track locally because * some libiscsi builds leave nops_in_flight at 0 across a dead TCP @@ -1432,6 +1484,7 @@ static void iscsi_nop_timed_event(void *opaque) iscsi_get_nops_in_flight(iscsilun->iscsi) >=3D MAX_NOP_FAILURES) { error_report("iSCSI: NOP timeout. Reconnecting..."); iscsilun->request_timed_out =3D true; + iscsilun->fail_io =3D true; iscsilun->nop_failures =3D 0; iscsi_scsi_cancel_all_tasks(iscsilun->iscsi); } else if (iscsi_nop_out_async(iscsilun->iscsi, iscsi_nop_cb, NULL, 0, @@ -2398,6 +2451,10 @@ iscsi_co_copy_range_to(BlockDriverState *bs, qemu_mutex_lock(&dst_lun->mutex); iscsi_task.task =3D iscsi_xcopy_task(data.size); retry: + if (iscsi_co_reject_if_failing(dst_lun)) { + r =3D -EIO; + goto out_unlock; + } if (iscsi_scsi_command_async(dst_lun->iscsi, dst_lun->lun, iscsi_task.task, iscsi_co_generic_cb, &data, --=20 2.53.0 From nobody Sat Jul 25 08:54:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784720853; cv=none; d=zohomail.com; s=zohoarc; b=ehDLdSStesfg43xk2YssdqIJaUV9RnM1dzJdPD17CmilRRGzHErOl1u2PVhq/nTmszUE27mc73D+QGfEgp+yBYILRf105O7MI80/xl1vjDzUFWsI/73uuqFLWH8LbQbeX50sHlHXveqpiVkvUYhozsxvaxuNwCYxXnx4Tz3gX40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784720853; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ydxv0Q4bD+qLHCya35AjaRVSkKhuKwlB7W4JrVReJxs=; b=JVkE4S+p37v90fQp3TM4rEZ7tPJu0vUAS8kqMGmRkA4HWkEiUrnXwL1sm5cCbTcYU/lu4WJw6TmEANrcwzlfKReaLcTsC6PoIUtexANjNEzH54ZFRiZ6M6Xox6Y12oReCniXNT7o/7UfZeWBoiY2jbjednb+RuJ5Uft38kPM05s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784720853937189.5381008741084; Wed, 22 Jul 2026 04:47:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmVP8-0004PR-OM; Wed, 22 Jul 2026 07:46:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmLNE-0000Bd-3G for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:48 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wmLNC-0002hf-KI for qemu-devel@nongnu.org; Tue, 21 Jul 2026 21:03:47 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-c1c26d7e951so190285866b.0 for ; Tue, 21 Jul 2026 18:03:46 -0700 (PDT) Received: from Arc ([109.245.172.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebac95sm32694066b.47.2026.07.21.18.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 18:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784682225; x=1785287025; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ydxv0Q4bD+qLHCya35AjaRVSkKhuKwlB7W4JrVReJxs=; b=Vaop/T9a/iMJ2yvWBzxrwFm9+2xbXrHBs4Syw/K85UpIcsVdaOEwr4zACALHa4nCP7 JUR16Erz62zN5B3anLiLTaKX865DBmyzXpGxMMoEwWgfF2SRLgEqKHw0SrisNbWNJAC6 o4U/8d1llLAVVUSmwidDv72rTkCIzX0Vr045mpvMx6v25TvGCdV6u+510nITMae063WS s2P69Be7QZm/ITNnoky1zfuN6pNGS6FEy40WG8OSxwiRBw6c/JEAkzV2nXiXvt0TdMPO bH+cxs5hr+GeOQEDilLJ47mbT1k/jnRbhFyTKZ2GgvhdYBrRFVysYqtSh2++OYpFBVq8 Wl5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784682225; x=1785287025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Ydxv0Q4bD+qLHCya35AjaRVSkKhuKwlB7W4JrVReJxs=; b=MupiJOd7yjgez9ZULz/w2Xn9OOkWlaDEUS95gUvjN1yJC/45IuXFP8leOgYG50Sd/p vlYwf8oMXi4mkampz5JcMsLrxByH4nMVvm6bsSe3CQYwxDjstOrL5flL74bXtO1eylcF r93zdIvGsIFEJfXgO48FY0JFNI4mGnQRWon/SdjO+4iLBREsHy0DgXpS3aaThh+IpnPH h4CqhOh3C1oH15k+1UQVqTSRAMekzrEzy82bVd8nunLk9pSOMFhy8iPef8/bRLJ04REt OeQGTya75VvJ1OAk1nKVeTF49OMDDCcqWFFY2c6rwk2VlKOxhFmpVbu4TTwij6R1zwH5 jCEQ== X-Gm-Message-State: AOJu0Yz4/ZdRh4JuVhXZz7HYVF8aZl6zYoJcGmWsSZ5mkWYMmvhu/CDG LzGnezUAi1JdNzDPC57AuHCCBDSjJ/p0VwfYbP5fAmrl0ct4gVDTplHM5Oop0DNbeQE= X-Gm-Gg: AR+sD13w9B+9S5xkSmUj6KDZOI+zbA46St0HQ1BqdsbB9mJjCURncoL60QyPPV6fjvb bFUBO/1Y1BC/UdbgFzElDITpl53ti4VcmS/z+qWeZnMghkSPjNQv8JPqyM8f1PvVWSvIFFaQYxN W3DMFI6lAipNtLuhTiwCea5o5mi+b9NOA8IQNIB2kZHp0G+cUvCv87rnnH5Z19Cjyk8yB3Q5r6+ JsUht1bMYJBxlF/fgwTVUrbEepV/zcdtDiloDEJUXc02YVqnxI1/elYN26i0yRza5Y5kSXuQah7 X+9BOCCN8ma4qQbQlqKgkvsaSDZjNWxLIOFMYhpu/DR3KFnxzWSyvPWhppJcV7FGXxo1aJVkx3y GWPXOMGGM2T3cI8cXHBb1mzYB5Sw2QLgeNErDelieRWftWMGCKuKEeHgkT+I1FV8rvw== X-Received: by 2002:a17:907:c70c:b0:c12:67d2:3d6b with SMTP id a640c23a62f3a-c16b4572384mr863768366b.11.1784682224602; Tue, 21 Jul 2026 18:03:44 -0700 (PDT) From: Konstantin Nigmatullin To: qemu-devel@nongnu.org Cc: Konstantin Nigmatullin , qemu-block@nongnu.org, Paolo Bonzini , Peter Lieven , Kevin Wolf , Hanna Reitz Subject: [PATCH 5/5] iscsi: avoid null iSCSI error strings after cancel or timeout Date: Wed, 22 Jul 2026 03:02:54 +0200 Message-ID: <20260722010254.424820-6-rangolit@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260722010254.424820-1-rangolit@gmail.com> References: <20260722010254.424820-1-rangolit@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=rangolit@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 22 Jul 2026 07:46:12 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784720855344158500 Content-Type: text/plain; charset="utf-8" Cancelled and timed-out tasks often left err_str unset, so logs printed "(null)" instead of a useful reason. See: https://gitlab.com/qemu-project/qemu/-/work_items/3067 Signed-off-by: Konstantin Nigmatullin --- block/iscsi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index b6207d03e5..0ab12987b8 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -290,6 +290,20 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int s= tatus, iscsilun->nop_failures =3D 0; } =20 + if (status !=3D SCSI_STATUS_GOOD && !iTask->do_retry && !iTask->err_st= r) { + const char *e =3D iscsi_get_error(iscsi); + + if (e && e[0]) { + iTask->err_str =3D g_strdup(e); + } else if (status =3D=3D SCSI_STATUS_CANCELLED) { + iTask->err_str =3D g_strdup("task cancelled"); + } else if (status =3D=3D SCSI_STATUS_TIMEOUT) { + iTask->err_str =3D g_strdup("command timed out"); + } else { + iTask->err_str =3D g_strdup("I/O error"); + } + } + /* * aio_co_wake() is safe to call: iscsi_service(), which called us, is= only * run from the event_timer and/or the FD handlers, never from the req= uest --=20 2.53.0