diff mbox series

[01/13] scsi: iscsi: revert Perform connection failure entirely in kernel space

Message ID 20210410184016.21603-2-michael.christie@oracle.com
State New
Headers show
Series : qedi tmf fixes | expand

Commit Message

Mike Christie April 10, 2021, 6:40 p.m. UTC
The patch 0ab710458da1 ("scsi: iscsi: Perform connection failure entirely
in kernel space") has the following regressions or bugs:

1. It can return cmds to upper layers like dm-multipath where that can
retry them. After they are successful the fs/app can send new IO to the
same sectors, but we've left the cmds running in FW or in the net layer.
We need to be calling ep_disconnect.

And for iscsi_tcp which does not have a ep_disconnect we need one to
close the socket so IO is not still retransmitting in the net layer
when the upper layers are now retrying the cmd and sending new IO.

2. The drivers that implement ep_disconnect expect that it's called
before conn_stop. Besides crashes, if the cleanup_task callout is called
before ep_disconnect it might free up driver/card resources for session1
then they could be allocated for session2. But because the driver's
ep_disconnect is not called it has not cleaned up the firmware so the
card is still using the resources for the original cmd.

3. The system shutdown case does not work for the eh path. Passing
stop_conn STOP_CONN_TERM will never block the session and start the
recovery timer, because for that flag userspace will do the unbind
and destroy events which would remove the devices and wake up and kill
the eh. We should be using STOP_CONN_RECOVER.

4. The stop_conn_work_fn can run after userspace has done it's
recovery and we are happily using the session. We will then end up
with various bugs depending on what is going on at the time.

When we add ep_disconnect we need to make sure they only exec once
and exec in order.

5. returning -EAGAIN in iscsi_if_destroy_conn if we haven't yet run
the in kernel stop_conn function is breaking userspace. We should have
been doing this for the caller.

This patch fixes the following issues by just reverting the patch
because I'm worried about the possible data corruption vs how long it
will take to fix all the bugs. If reverting the patch is ok, then we
should look into doing this properly and maybe redoing the interface
because there seem to be several issues with it.

Fixes: 0ab710458da1 ("scsi: iscsi: Perform connection failure entirely
in kernel space")
Signed-off-by: Mike Christie <michael.christie@oracle.com>

 drivers/scsi/scsi_transport_iscsi.c | 55 -----------------------------
 include/scsi/scsi_transport_iscsi.h |  1 -
 2 files changed, 56 deletions(-)
diff mbox series


diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index f4bf62b007a0..2821cd3ddbde 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -86,12 +86,6 @@  struct iscsi_internal {
 	struct transport_container session_cont;
-/* Worker to perform connection failure on unresponsive connections
- * completely in kernel space.
- */
-static void stop_conn_work_fn(struct work_struct *work);
-static DECLARE_WORK(stop_conn_work, stop_conn_work_fn);
 static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
 static struct workqueue_struct *iscsi_eh_timer_workq;
@@ -1629,7 +1623,6 @@  static DEFINE_MUTEX(conn_mutex);
 static LIST_HEAD(sesslist);
 static DEFINE_SPINLOCK(sesslock);
 static LIST_HEAD(connlist);
-static LIST_HEAD(connlist_err);
 static DEFINE_SPINLOCK(connlock);
 static uint32_t iscsi_conn_get_sid(struct iscsi_cls_conn *conn)
@@ -2281,7 +2274,6 @@  iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
-	INIT_LIST_HEAD(&conn->conn_list_err);
 	conn->transport = transport;
 	conn->cid = cid;
 	conn->state = ISCSI_CONN_DOWN;
@@ -2338,7 +2330,6 @@  int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
 	spin_lock_irqsave(&connlock, flags);
-	list_del(&conn->conn_list_err);
 	spin_unlock_irqrestore(&connlock, flags);
@@ -2480,38 +2471,6 @@  static void iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag)
-static void stop_conn_work_fn(struct work_struct *work)
-	struct iscsi_cls_conn *conn, *tmp;
-	unsigned long flags;
-	LIST_HEAD(recovery_list);
-	spin_lock_irqsave(&connlock, flags);
-	if (list_empty(&connlist_err)) {
-		spin_unlock_irqrestore(&connlock, flags);
-		return;
-	}
-	list_splice_init(&connlist_err, &recovery_list);
-	spin_unlock_irqrestore(&connlock, flags);
-	list_for_each_entry_safe(conn, tmp, &recovery_list, conn_list_err) {
-		uint32_t sid = iscsi_conn_get_sid(conn);
-		struct iscsi_cls_session *session;
-		session = iscsi_session_lookup(sid);
-		if (session) {
-			if (system_state != SYSTEM_RUNNING) {
-				session->recovery_tmo = 0;
-				iscsi_if_stop_conn(conn, STOP_CONN_TERM);
-			} else {
-				iscsi_if_stop_conn(conn, STOP_CONN_RECOVER);
-			}
-		}
-		list_del_init(&conn->conn_list_err);
-	}
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 	struct nlmsghdr	*nlh;
@@ -2519,12 +2478,6 @@  void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 	struct iscsi_uevent *ev;
 	struct iscsi_internal *priv;
 	int len = nlmsg_total_size(sizeof(*ev));
-	unsigned long flags;
-	spin_lock_irqsave(&connlock, flags);
-	list_add(&conn->conn_list_err, &connlist_err);
-	spin_unlock_irqrestore(&connlock, flags);
-	queue_work(system_unbound_wq, &stop_conn_work);
 	priv = iscsi_if_transport_lookup(conn->transport);
 	if (!priv)
@@ -2854,19 +2807,11 @@  static int
 iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
 	struct iscsi_cls_conn *conn;
-	unsigned long flags;
 	conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid);
 	if (!conn)
 		return -EINVAL;
-	spin_lock_irqsave(&connlock, flags);
-	if (!list_empty(&conn->conn_list_err)) {
-		spin_unlock_irqrestore(&connlock, flags);
-		return -EAGAIN;
-	}
-	spin_unlock_irqrestore(&connlock, flags);
 	ISCSI_DBG_TRANS_CONN(conn, "Destroying transport conn\n");
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index fc5a39839b4b..36e2c1dcb059 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -198,7 +198,6 @@  enum iscsi_connection_state {
 struct iscsi_cls_conn {
 	struct list_head conn_list;	/* item in connlist */
-	struct list_head conn_list_err;	/* item in connlist_err */
 	void *dd_data;			/* LLD private data */
 	struct iscsi_transport *transport;
 	uint32_t cid;			/* connection id */