Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4475941ybz; Tue, 28 Apr 2020 11:57:17 -0700 (PDT) X-Google-Smtp-Source: APiQypLtEjHPNHhnPrKPSQ+8kiVTl+rtoA/pPNyrdLXq84NVEyQNeCx3mcJikcdSeg0SbvcdQz+N X-Received: by 2002:a50:baa6:: with SMTP id x35mr24755624ede.54.1588100237507; Tue, 28 Apr 2020 11:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588100237; cv=none; d=google.com; s=arc-20160816; b=GPGqjoXpIhkmYZNLw7eIbpPor1unA3zz2ZmUWNfeCWUbQtLHL0fSPcaU56NWw9USsM SmlvzYcQdB4xbAcTIxniPYUoU+8Sp6mqrPBzibsCYhgE1hq37WhvvhnPGtJW6HhXsoLs DA37BvplgH40uSy7qdEXjBoOfIwtJLmecTDWS1yhknDs80Htq9+1HnAHVlN7BP3qHWvI 8fS63lrXSrGe4Ku9K8ndBV+lO5OA1UlnIrEnoRchZagTlLqisXk7tPW7wmcK+xyvyz+f a4EjlbgULQsOn7VZ8O3hLBsJ2lbmVcEj1Bod7iIyrh4RDk+FwFLOqd9WkgPjO1mnxjaY cx8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wovx1rfLb39v9HLVAictmr0GxTmvEMp3pdIwhqt0VjA=; b=ESZoKF8P1kNKeEqDxKIcatbVgj61nurIN7AxIwqHd7wxwo+n6Uw+7IXL0LPJwjULKT jEBsggT7e0su5eLBPqPwxZnEMIOMb729objvKTCgRcQFXHxZ4l4bjzqTyYEgWNNRE9RM WcV6hcN1i4sNA6KQ0lJFk86IQmJ01SdGQEaqAFBbDpV1vDOviFkp7eLw7uicvpYwBino ZMMTI9IPWThiXf2JxcR1kGLRs0SWhsZM3g+Vl+u1LZHZTSiMRodavn+bXuzt9JYtYep2 kQR/B7hK2sWO2Q42brT2YmOoVGdC4jVO83ThBBZI01md3oKO/fx9kOa4tNemqz5jWgt8 +iEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nlretlg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si2498319ejd.315.2020.04.28.11.56.52; Tue, 28 Apr 2020 11:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nlretlg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729960AbgD1Sde (ORCPT + 99 others); Tue, 28 Apr 2020 14:33:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729191AbgD1Sdc (ORCPT ); Tue, 28 Apr 2020 14:33:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B85D521775; Tue, 28 Apr 2020 18:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098810; bh=jLQjo7sVMrW78vbiNqRpHkEm3YVGC3+qwmWujhDT2RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlretlg7sbUkaCnaIfbRanFdnq4N031mBLnQnzxxIwyi4lGO/0gs/9y87SkB3mj1t 3rg0HF+wQLxWcJvDV78F+zKd3frCODtrruKWzJ2aNNbJuWp++KWIJ/SiVdDRgmZfxo 0AEfGR4l/1pULNeZTDAzwkBmBo4l0qkzJSa9Ig3U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Duncan , Wu Bo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 018/168] scsi: iscsi: Report unbind session event when the target has been removed Date: Tue, 28 Apr 2020 20:23:12 +0200 Message-Id: <20200428182233.994916559@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wu Bo [ Upstream commit 13e60d3ba287d96eeaf1deaadba51f71578119a3 ] If the daemon is restarted or crashes while logging out of a session, the unbind session event sent by the kernel is not processed and is lost. When the daemon starts again, the session can't be unbound because the daemon is waiting for the event message. However, the kernel has already logged out and the event will not be resent. When iscsid restart is complete, logout session reports error: Logging out of session [sid: 6, target: iqn.xxxxx, portal: xx.xx.xx.xx,3260] iscsiadm: Could not logout of [sid: 6, target: iscsiadm -m node iqn.xxxxx, portal: xx.xx.xx.xx,3260]. iscsiadm: initiator reported error (9 - internal error) iscsiadm: Could not logout of all requested sessions Make sure the unbind event is emitted. [mkp: commit desc and applied by hand since patch was mangled] Link: https://lore.kernel.org/r/4eab1771-2cb3-8e79-b31c-923652340e99@huawei.com Reviewed-by: Lee Duncan Signed-off-by: Wu Bo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_transport_iscsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 271afea654e2b..a5c78b38d3022 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2012,7 +2012,7 @@ static void __iscsi_unbind_session(struct work_struct *work) if (session->target_id == ISCSI_MAX_TARGET) { spin_unlock_irqrestore(&session->lock, flags); mutex_unlock(&ihost->mutex); - return; + goto unbind_session_exit; } target_id = session->target_id; @@ -2024,6 +2024,8 @@ static void __iscsi_unbind_session(struct work_struct *work) ida_simple_remove(&iscsi_sess_ida, target_id); scsi_remove_target(&session->dev); + +unbind_session_exit: iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n"); } -- 2.20.1