This is a note to let you know that I've just added the patch titled scsi: iscsi: Fix iSCSI cls conn state to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: scsi-iscsi-fix-iscsi-cls-conn-state.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Thu Jul 15 01:10:15 PM CEST 2021 From: Hanjun Guo <guohanjun@xxxxxxxxxx> Date: Tue, 13 Jul 2021 17:18:37 +0800 Subject: scsi: iscsi: Fix iSCSI cls conn state To: <stable@xxxxxxxxxxxxxxx> Cc: <linux-kernel@xxxxxxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Sasha Levin <sashal@xxxxxxxxxx>, Mike Christie <michael.christie@xxxxxxxxxx>, Gulam Mohamed <gulam.mohamed@xxxxxxxxxx>, "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>, Hanjun Guo <guohanjun@xxxxxxxxxx> Message-ID: <1626167917-11972-8-git-send-email-guohanjun@xxxxxxxxxx> From: Mike Christie <michael.christie@xxxxxxxxxx> commit 0dcf8febcb7b9d42bec98bc068e01d1a6ea578b8 upstream. In commit 9e67600ed6b8 ("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@xxxxxxxxxx Fixes: 9e67600ed6b8 ("scsi: iscsi: Fix race condition between login and sync thread") Cc: Gulam Mohamed <gulam.mohamed@xxxxxxxxxx> Signed-off-by: Mike Christie <michael.christie@xxxxxxxxxx> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Signed-off-by: Hanjun Guo <guohanjun@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/scsi/libiscsi.c | 26 +++----------------------- drivers/scsi/scsi_transport_iscsi.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 26 deletions(-) --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -3089,9 +3089,10 @@ fail_mgmt_tasks(struct iscsi_session *se } } -static void iscsi_start_session_recovery(struct iscsi_session *session, - struct iscsi_conn *conn, int flag) +void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) { + struct iscsi_conn *conn = cls_conn->dd_data; + struct iscsi_session *session = conn->session; int old_stop_stage; mutex_lock(&session->eh_mutex); @@ -3149,27 +3150,6 @@ static void iscsi_start_session_recovery spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); } - -void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) -{ - struct iscsi_conn *conn = cls_conn->dd_data; - struct iscsi_session *session = conn->session; - - switch (flag) { - case STOP_CONN_RECOVER: - cls_conn->state = ISCSI_CONN_FAILED; - break; - case STOP_CONN_TERM: - cls_conn->state = ISCSI_CONN_DOWN; - break; - default: - iscsi_conn_printk(KERN_ERR, conn, - "invalid stop flag %d\n", flag); - return; - } - - iscsi_start_session_recovery(session, conn, flag); -} EXPORT_SYMBOL_GPL(iscsi_conn_stop); int iscsi_conn_bind(struct iscsi_cls_session *cls_session, --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2479,10 +2479,22 @@ static void iscsi_if_stop_conn(struct is * it works. */ mutex_lock(&conn_mutex); + switch (flag) { + case STOP_CONN_RECOVER: + conn->state = ISCSI_CONN_FAILED; + break; + case STOP_CONN_TERM: + conn->state = ISCSI_CONN_DOWN; + break; + default: + iscsi_cls_conn_printk(KERN_ERR, conn, + "invalid stop flag %d\n", flag); + goto unlock; + } + conn->transport->stop_conn(conn, flag); - conn->state = ISCSI_CONN_DOWN; +unlock: mutex_unlock(&conn_mutex); - } static void stop_conn_work_fn(struct work_struct *work) @@ -2973,7 +2985,7 @@ static int iscsi_if_ep_disconnect(struct mutex_lock(&conn->ep_mutex); conn->ep = NULL; mutex_unlock(&conn->ep_mutex); - conn->state = ISCSI_CONN_DOWN; + conn->state = ISCSI_CONN_FAILED; } transport->ep_disconnect(ep); Patches currently in stable-queue which might be from guohanjun@xxxxxxxxxx are queue-5.10/io_uring-simplify-io_remove_personalities.patch queue-5.10/io_uring-convert-personality_idr-to-xarray.patch queue-5.10/loop-fix-i-o-error-on-fsync-in-detached-loop-devices.patch queue-5.10/io_uring-convert-io_buffer_idr-to-xarray.patch queue-5.10/mm-hwpoison-return-ebusy-when-migration-fails.patch queue-5.10/scsi-iscsi-fix-iscsi-cls-conn-state.patch queue-5.10/scsi-iscsi-fix-race-condition-between-login-and-sync-thread.patch