Skip to content

Commit

Permalink
initiator: Avoid stopping one connection more than one time
Browse files Browse the repository at this point in the history
Once receive ISCSI_KEVENT_UNBIND_SESSION, ctldev_handle() would trigger
an EV_CONN_STOP event, this event would calling iscsi_stop() to perform
connection stop operations.

While we can not guarantee only one ISCSI_KEVENT_UNBIND_SESSION is
received(actually in current mainline kernel design, kernel would always send
ISCSI_KEVENT_UNBIND_SESSION twice).

So we must check connection's state at the begining of iscsi_stop() to
avoid the stop operations performed more than one time.

This issue only happened with async destroy session.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
  • Loading branch information
Wenchao Hao committed Aug 1, 2022
1 parent b965a83 commit c6cf8e1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions usr/initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,18 @@ static void iscsi_stop(void *data)

iscsi_ev_context_put(ev_context);

/*
* Once receive ISCSI_KEVENT_UNBIND_SESSION, ctldev_handle() would
* trigger an EV_CONN_STOP event, this event would call iscsi_stop()
* to perform connection stop operations.
* When using async destroy session and older kernels we might
* get more than one session unbind events. If we are already in
* the IN_LOGOUT state then we know we've already got one, so we can
* ignore the session unbind events
*/
if (conn->state == ISCSI_CONN_STATE_IN_LOGOUT)
return;

if (!(conn->session->t->caps & CAP_LOGIN_OFFLOAD)) {
rc = iscsi_send_logout(conn);
if (!rc)
Expand Down

0 comments on commit c6cf8e1

Please sign in to comment.