Skip to content

Commit 0dcf8fe

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: iscsi: Fix iSCSI cls conn state
In commit 9e67600 ("scsi: iscsi: Fix race condition between login and sync thread") I missed that libiscsi was now setting the iSCSI class state, and that patch ended up resetting the state during conn stoppage and using the wrong state value during ep_disconnect. This patch moves the setting of the class state to the class module and then fixes the two issues above. Link: https://lore.kernel.org/r/20210406171746.5016-1-michael.christie@oracle.com Fixes: 9e67600 ("scsi: iscsi: Fix race condition between login and sync thread") Cc: Gulam Mohamed <gulam.mohamed@oracle.com> Signed-off-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5cd0f6f commit 0dcf8fe

2 files changed

Lines changed: 18 additions & 26 deletions

File tree

drivers/scsi/libiscsi.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,9 +3179,10 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn)
31793179
}
31803180
}
31813181

3182-
static void iscsi_start_session_recovery(struct iscsi_session *session,
3183-
struct iscsi_conn *conn, int flag)
3182+
void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
31843183
{
3184+
struct iscsi_conn *conn = cls_conn->dd_data;
3185+
struct iscsi_session *session = conn->session;
31853186
int old_stop_stage;
31863187

31873188
mutex_lock(&session->eh_mutex);
@@ -3239,27 +3240,6 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
32393240
spin_unlock_bh(&session->frwd_lock);
32403241
mutex_unlock(&session->eh_mutex);
32413242
}
3242-
3243-
void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
3244-
{
3245-
struct iscsi_conn *conn = cls_conn->dd_data;
3246-
struct iscsi_session *session = conn->session;
3247-
3248-
switch (flag) {
3249-
case STOP_CONN_RECOVER:
3250-
cls_conn->state = ISCSI_CONN_FAILED;
3251-
break;
3252-
case STOP_CONN_TERM:
3253-
cls_conn->state = ISCSI_CONN_DOWN;
3254-
break;
3255-
default:
3256-
iscsi_conn_printk(KERN_ERR, conn,
3257-
"invalid stop flag %d\n", flag);
3258-
return;
3259-
}
3260-
3261-
iscsi_start_session_recovery(session, conn, flag);
3262-
}
32633243
EXPORT_SYMBOL_GPL(iscsi_conn_stop);
32643244

32653245
int iscsi_conn_bind(struct iscsi_cls_session *cls_session,

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,10 +2470,22 @@ static void iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag)
24702470
* it works.
24712471
*/
24722472
mutex_lock(&conn_mutex);
2473+
switch (flag) {
2474+
case STOP_CONN_RECOVER:
2475+
conn->state = ISCSI_CONN_FAILED;
2476+
break;
2477+
case STOP_CONN_TERM:
2478+
conn->state = ISCSI_CONN_DOWN;
2479+
break;
2480+
default:
2481+
iscsi_cls_conn_printk(KERN_ERR, conn,
2482+
"invalid stop flag %d\n", flag);
2483+
goto unlock;
2484+
}
2485+
24732486
conn->transport->stop_conn(conn, flag);
2474-
conn->state = ISCSI_CONN_DOWN;
2487+
unlock:
24752488
mutex_unlock(&conn_mutex);
2476-
24772489
}
24782490

24792491
static void stop_conn_work_fn(struct work_struct *work)
@@ -2961,7 +2973,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
29612973
mutex_lock(&conn->ep_mutex);
29622974
conn->ep = NULL;
29632975
mutex_unlock(&conn->ep_mutex);
2964-
conn->state = ISCSI_CONN_DOWN;
2976+
conn->state = ISCSI_CONN_FAILED;
29652977
}
29662978

29672979
transport->ep_disconnect(ep);

0 commit comments

Comments
 (0)