[PATCH] iscsi:report unbind session event when the target has been removed

20 views
Skip to first unread message

Wu Bo

unread,
Mar 24, 2020, 3:59:16 AM3/24/20
to Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, liuzhiqiang, linfe...@huawei.com
The daemon is restarted or crashed while logging out of a session.
The unbind session event sent by the kernel is not be processed or be lost.
When the daemon runs again, the session will never be able to logout.

After executing the logout again, the daemon is waiting for the unbind
event message.
The kernel status has been logged out and the event will not be sent again.

#iscsiadm -m node iqn.xxx -p xx.xx.xx.xx -u &
#service iscsid restart

when iscsid restart done. logout session again report error:
#iscsiadm -m node iqn.xxxxx -p xx.xx.xx.xx -u
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

Signed-off-by: Wu Bo <wub...@huawei.com>
---
 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 dfc726f..443ace0 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");
 }
--
1.8.3.1

Martin K. Petersen

unread,
Mar 31, 2020, 9:52:49 PM3/31/20
to Wu Bo, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, liuzhiqiang, linfe...@huawei.com

Wu,

> The daemon is restarted or crashed while logging out of a session.
> The unbind session event sent by the kernel is not be processed or be
> lost. When the daemon runs again, the session will never be able to
> logout.

I had to apply this by hand as the patch was completely mangled. Please
use git send-email to submit patches in the future! Thanks!

Applied to 5.7/scsi-queue.

--
Martin K. Petersen Oracle Linux Engineering
Reply all
Reply to author
Forward
0 new messages