All of lore.kernel.org
 help / color / mirror / Atom feed
* [[PATCH 00/12] misc iscsi patches
@ 2022-03-08  0:27 Mike Christie
  2022-03-08  0:27 ` [PATCH 01/12] scsi: iscsi: Merge suspend fields Mike Christie
                   ` (11 more replies)
  0 siblings, 12 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb

The following patches were made over Martin's staging branch which
contain Bart's SCptr cleanup and the iscsi class workqueue patches.

They are mix of minor fixes and perf improvements and cleanups.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 01/12] scsi: iscsi: Merge suspend fields
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-08 18:47   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work Mike Christie
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

Move the tx and rx suspend fields into one flags field.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  2 +-
 drivers/scsi/cxgbi/libcxgbi.c    |  6 +++---
 drivers/scsi/libiscsi.c          | 20 ++++++++++----------
 drivers/scsi/libiscsi_tcp.c      |  2 +-
 include/scsi/libiscsi.h          |  9 +++++----
 6 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 5521469ce678..e16327a4b4c9 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1977,7 +1977,7 @@ static int bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
 			break;
 
-		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
+		if (unlikely(test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
 			if (nopin->op_code == ISCSI_OP_NOOP_IN &&
 			    nopin->itt == (u16) RESERVED_ITT) {
 				printk(KERN_ALERT "bnx2i: Unsolicited "
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index e21b053b4f3e..a592ca8602f9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1721,7 +1721,7 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 			struct iscsi_conn *conn = ep->conn->cls_conn->dd_data;
 
 			/* Must suspend all rx queue activity for this ep */
-			set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+			set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
 		}
 		/* CONN_DISCONNECT timeout may or may not be an issue depending
 		 * on what transcribed in TCP layer, different targets behave
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 8c7d4dda4cf2..4365d52c6430 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -1634,11 +1634,11 @@ void cxgbi_conn_pdu_ready(struct cxgbi_sock *csk)
 	log_debug(1 << CXGBI_DBG_PDU_RX,
 		"csk 0x%p, conn 0x%p.\n", csk, conn);
 
-	if (unlikely(!conn || conn->suspend_rx)) {
+	if (unlikely(!conn || test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
 		log_debug(1 << CXGBI_DBG_PDU_RX,
-			"csk 0x%p, conn 0x%p, id %d, suspend_rx %lu!\n",
+			"csk 0x%p, conn 0x%p, id %d, conn flags 0x%lx!\n",
 			csk, conn, conn ? conn->id : 0xFF,
-			conn ? conn->suspend_rx : 0xFF);
+			conn ? conn->flags : 0xFF);
 		return;
 	}
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index a75b85f0a189..14f5737429cf 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1392,8 +1392,8 @@ static bool iscsi_set_conn_failed(struct iscsi_conn *conn)
 	if (conn->stop_stage == 0)
 		session->state = ISCSI_STATE_FAILED;
 
-	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
-	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
+	set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
 	return true;
 }
 
@@ -1454,7 +1454,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 	 * Do this after dropping the extra ref because if this was a requeue
 	 * it's removed from that list and cleanup_queued_task would miss it.
 	 */
-	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
+	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
 		/*
 		 * Save the task and ref in case we weren't cleaning up this
 		 * task and get woken up again.
@@ -1532,7 +1532,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
 	int rc = 0;
 
 	spin_lock_bh(&conn->session->frwd_lock);
-	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
+	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
 		ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n");
 		spin_unlock_bh(&conn->session->frwd_lock);
 		return -ENODATA;
@@ -1746,7 +1746,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
 		goto fault;
 	}
 
-	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
+	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
 		reason = FAILURE_SESSION_IN_RECOVERY;
 		sc->result = DID_REQUEUE << 16;
 		goto fault;
@@ -1935,7 +1935,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
 void iscsi_suspend_queue(struct iscsi_conn *conn)
 {
 	spin_lock_bh(&conn->session->frwd_lock);
-	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
 	spin_unlock_bh(&conn->session->frwd_lock);
 }
 EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
@@ -1953,7 +1953,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn)
 	struct Scsi_Host *shost = conn->session->host;
 	struct iscsi_host *ihost = shost_priv(shost);
 
-	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
 	if (ihost->workq)
 		flush_workqueue(ihost->workq);
 }
@@ -1961,7 +1961,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
 
 static void iscsi_start_tx(struct iscsi_conn *conn)
 {
-	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
 	iscsi_conn_queue_work(conn);
 }
 
@@ -3321,8 +3321,8 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
 	/*
 	 * Unblock xmitworker(), Login Phase will pass through.
 	 */
-	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
-	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+	clear_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
+	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(iscsi_conn_bind);
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 2e9ffe3d1a55..883005757ddb 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -927,7 +927,7 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
 	 */
 	conn->last_recv = jiffies;
 
-	if (unlikely(conn->suspend_rx)) {
+	if (unlikely(test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
 		ISCSI_DBG_TCP(conn, "Rx suspended!\n");
 		*status = ISCSI_TCP_SUSPENDED;
 		return 0;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 2d85810d1929..10a9b89b7448 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -52,8 +52,10 @@ enum {
 
 #define ISID_SIZE			6
 
-/* Connection suspend "bit" */
-#define ISCSI_SUSPEND_BIT		1
+/* Connection flags */
+#define ISCSI_CONN_FLAG_SUSPEND_TX	BIT(0)
+#define ISCSI_CONN_FLAG_SUSPEND_RX	BIT(1)
+
 
 #define ISCSI_ITT_MASK			0x1fff
 #define ISCSI_TOTAL_CMDS_MAX		4096
@@ -199,8 +201,7 @@ struct iscsi_conn {
 	struct list_head	cmdqueue;	/* data-path cmd queue */
 	struct list_head	requeue;	/* tasks needing another run */
 	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
-	unsigned long		suspend_tx;	/* suspend Tx */
-	unsigned long		suspend_rx;	/* suspend Rx */
+	unsigned long		flags;		/* ISCSI_CONN_FLAGs */
 
 	/* negotiated params */
 	unsigned		max_recv_dlength; /* initiator_max_recv_dsl*/
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
  2022-03-08  0:27 ` [PATCH 01/12] scsi: iscsi: Merge suspend fields Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-08 18:49   ` Lee Duncan
  2022-03-09  0:55   ` Wu Bo
  2022-03-08  0:27 ` [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers Mike Christie
                   ` (9 subsequent siblings)
  11 siblings, 2 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

Rename iscsi_conn_queue_work to iscsi_conn_queue_xmit to reflect it
handles queueing of xmits only.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/cxgbi/libcxgbi.c |  2 +-
 drivers/scsi/iscsi_tcp.c      |  2 +-
 drivers/scsi/libiscsi.c       | 12 ++++++------
 include/scsi/libiscsi.h       |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 4365d52c6430..411b0d386fad 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -1455,7 +1455,7 @@ void cxgbi_conn_tx_open(struct cxgbi_sock *csk)
 	if (conn) {
 		log_debug(1 << CXGBI_DBG_SOCK,
 			"csk 0x%p, cid %d.\n", csk, conn->id);
-		iscsi_conn_queue_work(conn);
+		iscsi_conn_queue_xmit(conn);
 	}
 }
 EXPORT_SYMBOL_GPL(cxgbi_conn_tx_open);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 1bc37593c88f..f274a86d2ec0 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -205,7 +205,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
 	old_write_space(sk);
 
 	ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n");
-	iscsi_conn_queue_work(conn);
+	iscsi_conn_queue_xmit(conn);
 }
 
 static void iscsi_sw_tcp_conn_set_callbacks(struct iscsi_conn *conn)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 14f5737429cf..fa44445dc75f 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -83,7 +83,7 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
 				"%s " dbg_fmt, __func__, ##arg);	\
 	} while (0);
 
-inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
+inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
 {
 	struct Scsi_Host *shost = conn->session->host;
 	struct iscsi_host *ihost = shost_priv(shost);
@@ -91,7 +91,7 @@ inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
 	if (ihost->workq)
 		queue_work(ihost->workq, &conn->xmitwork);
 }
-EXPORT_SYMBOL_GPL(iscsi_conn_queue_work);
+EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit);
 
 static void __iscsi_update_cmdsn(struct iscsi_session *session,
 				 uint32_t exp_cmdsn, uint32_t max_cmdsn)
@@ -764,7 +764,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 			goto free_task;
 	} else {
 		list_add_tail(&task->running, &conn->mgmtqueue);
-		iscsi_conn_queue_work(conn);
+		iscsi_conn_queue_xmit(conn);
 	}
 
 	return task;
@@ -1512,7 +1512,7 @@ void iscsi_requeue_task(struct iscsi_task *task)
 		 */
 		iscsi_put_task(task);
 	}
-	iscsi_conn_queue_work(conn);
+	iscsi_conn_queue_xmit(conn);
 	spin_unlock_bh(&conn->session->frwd_lock);
 }
 EXPORT_SYMBOL_GPL(iscsi_requeue_task);
@@ -1781,7 +1781,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
 		}
 	} else {
 		list_add_tail(&task->running, &conn->cmdqueue);
-		iscsi_conn_queue_work(conn);
+		iscsi_conn_queue_xmit(conn);
 	}
 
 	session->queued_cmdsn++;
@@ -1962,7 +1962,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
 static void iscsi_start_tx(struct iscsi_conn *conn)
 {
 	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
-	iscsi_conn_queue_work(conn);
+	iscsi_conn_queue_xmit(conn);
 }
 
 /*
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 10a9b89b7448..b567ea4700e5 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -441,7 +441,7 @@ extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
 				     enum iscsi_param param, char *buf);
 extern void iscsi_suspend_tx(struct iscsi_conn *conn);
 extern void iscsi_suspend_queue(struct iscsi_conn *conn);
-extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
+extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn);
 
 #define iscsi_conn_printk(prefix, _c, fmt, a...) \
 	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
  2022-03-08  0:27 ` [PATCH 01/12] scsi: iscsi: Merge suspend fields Mike Christie
  2022-03-08  0:27 ` [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-10 22:50   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run Mike Christie
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

Add helpers to allow the drivers to run their recv paths from libiscsi's
workqueue.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 29 +++++++++++++++++++++++++++--
 include/scsi/libiscsi.h |  4 ++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index fa44445dc75f..fec64cbfa4b6 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -93,6 +93,16 @@ inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
 }
 EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit);
 
+inline void iscsi_conn_queue_recv(struct iscsi_conn *conn)
+{
+	struct Scsi_Host *shost = conn->session->host;
+	struct iscsi_host *ihost = shost_priv(shost);
+
+	if (ihost->workq && !test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))
+		queue_work(ihost->workq, &conn->recvwork);
+}
+EXPORT_SYMBOL_GPL(iscsi_conn_queue_recv);
+
 static void __iscsi_update_cmdsn(struct iscsi_session *session,
 				 uint32_t exp_cmdsn, uint32_t max_cmdsn)
 {
@@ -1942,7 +1952,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
 
 /**
  * iscsi_suspend_tx - suspend iscsi_data_xmit
- * @conn: iscsi conn tp stop processing IO on.
+ * @conn: iscsi conn to stop processing IO on.
  *
  * This function sets the suspend bit to prevent iscsi_data_xmit
  * from sending new IO, and if work is queued on the xmit thread
@@ -1955,7 +1965,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn)
 
 	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
 	if (ihost->workq)
-		flush_workqueue(ihost->workq);
+		flush_work(&conn->xmitwork);
 }
 EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
 
@@ -1965,6 +1975,21 @@ static void iscsi_start_tx(struct iscsi_conn *conn)
 	iscsi_conn_queue_xmit(conn);
 }
 
+/**
+ * iscsi_suspend_rx - Prevent recvwork from running again.
+ * @conn: iscsi conn to stop.
+ */
+void iscsi_suspend_rx(struct iscsi_conn *conn)
+{
+	struct Scsi_Host *shost = conn->session->host;
+	struct iscsi_host *ihost = shost_priv(shost);
+
+	set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
+	if (ihost->workq)
+		flush_work(&conn->recvwork);
+}
+EXPORT_SYMBOL_GPL(iscsi_suspend_rx);
+
 /*
  * We want to make sure a ping is in flight. It has timed out.
  * And we are not busy processing a pdu that is making
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index b567ea4700e5..522fd16f1dbb 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -201,6 +201,8 @@ struct iscsi_conn {
 	struct list_head	cmdqueue;	/* data-path cmd queue */
 	struct list_head	requeue;	/* tasks needing another run */
 	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
+	/* recv */
+	struct work_struct	recvwork;
 	unsigned long		flags;		/* ISCSI_CONN_FLAGs */
 
 	/* negotiated params */
@@ -440,8 +442,10 @@ extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
 extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
 				     enum iscsi_param param, char *buf);
 extern void iscsi_suspend_tx(struct iscsi_conn *conn);
+extern void iscsi_suspend_rx(struct iscsi_conn *conn);
 extern void iscsi_suspend_queue(struct iscsi_conn *conn);
 extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn);
+extern void iscsi_conn_queue_recv(struct iscsi_conn *conn);
 
 #define iscsi_conn_printk(prefix, _c, fmt, a...) \
 	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (2 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-08 19:00   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 05/12] scsi: iscsi: Run recv path from workqueue Mike Christie
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

Allow the recv and xmit works to run from different threads if the user
has set it up.

This also removes the __WQ_LEGACY since it was never needed.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index fec64cbfa4b6..0a0076144874 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2824,8 +2824,8 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
 
 	if (xmit_can_sleep) {
 		ihost->workq = alloc_workqueue("iscsi_q_%d",
-			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
-			1, shost->host_no);
+			WQ_SYSFS | WQ_MEM_RECLAIM | WQ_UNBOUND,
+			2, shost->host_no);
 		if (!ihost->workq)
 			goto free_host;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 05/12] scsi: iscsi: Run recv path from workqueue
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (3 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-18 16:45   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header Mike Christie
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

We don't always want to run the recv path from the network softirq
because when we have to have multiple sessions sharing the same CPUs some
sessions can eat up the napi softirq budget and affect other sessions or
users. This patch allows us to queue the recv handling to the iscsi
workqueue so we can have the scheduler/wq code try to balance the work and
CPU use across all sessions's  worker threads.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/iscsi_tcp.c | 62 +++++++++++++++++++++++++++++++---------
 drivers/scsi/iscsi_tcp.h |  2 ++
 2 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index f274a86d2ec0..261599938fc9 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -52,6 +52,10 @@ static struct iscsi_transport iscsi_sw_tcp_transport;
 static unsigned int iscsi_max_lun = ~0;
 module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
 
+static bool iscsi_use_recv_wq;
+module_param_named(use_recv_wq, iscsi_use_recv_wq, bool, 0644);
+MODULE_PARM_DESC(use_recv_wq, "Set to true to read iSCSI data/headers from the iscsi_q workqueue. The default is false which will perform reads from the network softirq context.");
+
 static int iscsi_sw_tcp_dbg;
 module_param_named(debug_iscsi_tcp, iscsi_sw_tcp_dbg, int,
 		   S_IRUGO | S_IWUSR);
@@ -122,20 +126,13 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
 	return 0;
 }
 
-static void iscsi_sw_tcp_data_ready(struct sock *sk)
+static void iscsi_sw_tcp_recv_data(struct iscsi_conn *conn)
 {
-	struct iscsi_conn *conn;
-	struct iscsi_tcp_conn *tcp_conn;
+	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
+	struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
+	struct sock *sk = tcp_sw_conn->sock->sk;
 	read_descriptor_t rd_desc;
 
-	read_lock_bh(&sk->sk_callback_lock);
-	conn = sk->sk_user_data;
-	if (!conn) {
-		read_unlock_bh(&sk->sk_callback_lock);
-		return;
-	}
-	tcp_conn = conn->dd_data;
-
 	/*
 	 * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
 	 * We set count to 1 because we want the network layer to
@@ -144,13 +141,48 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk)
 	 */
 	rd_desc.arg.data = conn;
 	rd_desc.count = 1;
-	tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv);
 
-	iscsi_sw_sk_state_check(sk);
+	tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv);
 
 	/* If we had to (atomically) map a highmem page,
 	 * unmap it now. */
 	iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
+
+	iscsi_sw_sk_state_check(sk);
+}
+
+static void iscsi_sw_tcp_recv_data_work(struct work_struct *work)
+{
+	struct iscsi_conn *conn = container_of(work, struct iscsi_conn,
+					       recvwork);
+	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
+	struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
+	struct sock *sk = tcp_sw_conn->sock->sk;
+
+	lock_sock(sk);
+	iscsi_sw_tcp_recv_data(conn);
+	release_sock(sk);
+}
+
+static void iscsi_sw_tcp_data_ready(struct sock *sk)
+{
+	struct iscsi_sw_tcp_conn *tcp_sw_conn;
+	struct iscsi_tcp_conn *tcp_conn;
+	struct iscsi_conn *conn;
+
+	read_lock_bh(&sk->sk_callback_lock);
+	conn = sk->sk_user_data;
+	if (!conn) {
+		read_unlock_bh(&sk->sk_callback_lock);
+		return;
+	}
+	tcp_conn = conn->dd_data;
+	tcp_sw_conn = tcp_conn->dd_data;
+
+	if (tcp_sw_conn->queue_recv)
+		iscsi_conn_queue_recv(conn);
+	else
+		iscsi_sw_tcp_recv_data(conn);
 	read_unlock_bh(&sk->sk_callback_lock);
 }
 
@@ -557,6 +589,8 @@ iscsi_sw_tcp_conn_create(struct iscsi_cls_session *cls_session,
 	conn = cls_conn->dd_data;
 	tcp_conn = conn->dd_data;
 	tcp_sw_conn = tcp_conn->dd_data;
+	INIT_WORK(&conn->recvwork, iscsi_sw_tcp_recv_data_work);
+	tcp_sw_conn->queue_recv = iscsi_use_recv_wq;
 
 	tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(tfm))
@@ -606,6 +640,8 @@ static void iscsi_sw_tcp_release_conn(struct iscsi_conn *conn)
 	 */
 	kernel_sock_shutdown(sock, SHUT_RDWR);
 
+	iscsi_suspend_rx(conn);
+
 	sock_hold(sock->sk);
 	iscsi_sw_tcp_conn_restore_callbacks(conn);
 	sock_put(sock->sk);
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index 791453195099..850a018aefb9 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -28,6 +28,8 @@ struct iscsi_sw_tcp_send {
 
 struct iscsi_sw_tcp_conn {
 	struct socket		*sock;
+	struct work_struct	recvwork;
+	bool			queue_recv;
 
 	struct iscsi_sw_tcp_send out;
 	/* old values for socket callbacks */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (4 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 05/12] scsi: iscsi: Run recv path from workqueue Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-12 19:42   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use Mike Christie
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

This has us use zero copy the PDU header.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/iscsi_tcp.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 261599938fc9..3bdefc4b6b17 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -306,7 +306,7 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
 		copy = segment->size - offset;
 
 		if (segment->total_copied + segment->size < segment->total_size)
-			flags |= MSG_MORE;
+			flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST;
 
 		/* Use sendpage if we can; else fall back to sendmsg */
 		if (!segment->data) {
@@ -315,13 +315,27 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
 			r = tcp_sw_conn->sendpage(sk, sg_page(sg), offset,
 						  copy, flags);
 		} else {
-			struct msghdr msg = { .msg_flags = flags };
-			struct kvec iov = {
-				.iov_base = segment->data + offset,
-				.iov_len = copy
-			};
-
-			r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
+			void *data = segment->data + offset;
+
+			/*
+			 * Make sure it's ok to send the header using zero
+			 * copy. The case where the sg page can't be zero
+			 * copied will also go down the sendmsg path.
+			 */
+			if (sendpage_ok(data)) {
+				r = tcp_sw_conn->sendpage(sk,
+						virt_to_page(data),
+						offset_in_page(data), copy,
+						flags);
+			} else {
+				struct msghdr msg = { .msg_flags = flags };
+				struct kvec iov = {
+					.iov_base = data,
+					.iov_len = copy,
+				};
+
+				r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
+			}
 		}
 
 		if (r < 0) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (5 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-09  1:31   ` Wu Bo
  2022-03-12 19:43   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 08/12] scsi: iscsi: remove unneeded task state check Mike Christie
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

For software iscsi, we do a session per host so there is no need to set
the target's can_queue since its the same as the host one. It just results
in extra atomic checks in the main IO path.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/iscsi_tcp.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 3bdefc4b6b17..974245eab605 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -1053,7 +1053,6 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
 	.eh_target_reset_handler = iscsi_eh_recover_target,
 	.dma_boundary		= PAGE_SIZE - 1,
 	.slave_configure        = iscsi_sw_tcp_slave_configure,
-	.target_alloc		= iscsi_target_alloc,
 	.proc_name		= "iscsi_tcp",
 	.this_id		= -1,
 	.track_queue_depth	= 1,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 08/12] scsi: iscsi: remove unneeded task state check
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (6 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-09  1:33   ` Wu Bo
  2022-03-14 17:13   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement Mike Christie
                   ` (3 subsequent siblings)
  11 siblings, 2 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

The patch:

commit 5923d64b7ab6 ("scsi: libiscsi: Drop taskqueuelock")

added an extra task->state because for

commit 6f8830f5bbab ("scsi: libiscsi: add lock around task lists to fix
list corruption regression")

we didn't know why we ended up with cmds on the list and thought it
might have been a bad target sending a response while we were still
sending the cmd. We were never able to get a target to send us a response
early, because it turns out the bug was just a race in libiscsi/
libiscsi_tcp where

1. iscsi_tcp_r2t_rsp queues a r2t to tcp_task->r2tqueue.
2. iscsi_tcp_task_xmit runs iscsi_tcp_get_curr_r2t and sees we have a r2t.
It dequeues it and iscsi_tcp_task_xmit starts to process it.
3. iscsi_tcp_r2t_rsp runs iscsi_requeue_task and puts the task on the
requeue list.
4. iscsi_tcp_task_xmit sends the data for r2t. This is the final chunk of
data, so the cmd is done.
5. target sends the response.
6. On a different CPU from #3, iscsi_complete_task processes the response.
Since there was no common lock for the list, the lists/tasks pointers are
not fully in sync, so could end up with list corruption.

Since it was just a race on our side, this patch removes the extra check
and fixes up the comments.

Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 0a0076144874..5c74ab92725f 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -567,16 +567,19 @@ static bool cleanup_queued_task(struct iscsi_task *task)
 	struct iscsi_conn *conn = task->conn;
 	bool early_complete = false;
 
-	/* Bad target might have completed task while it was still running */
+	/*
+	 * We might have raced where we handled a R2T early and got a response
+	 * but have not yet taken the task off the requeue list, then a TMF or
+	 * recovery happened and so we can still see it here.
+	 */
 	if (task->state == ISCSI_TASK_COMPLETED)
 		early_complete = true;
 
 	if (!list_empty(&task->running)) {
 		list_del_init(&task->running);
 		/*
-		 * If it's on a list but still running, this could be from
-		 * a bad target sending a rsp early, cleanup from a TMF, or
-		 * session recovery.
+		 * If it's on a list but still running this could be cleanup
+		 * from a TMF or session recovery.
 		 */
 		if (task->state == ISCSI_TASK_RUNNING ||
 		    task->state == ISCSI_TASK_COMPLETED)
@@ -1484,7 +1487,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 	}
 	/* regular RX path uses back_lock */
 	spin_lock(&conn->session->back_lock);
-	if (rc && task->state == ISCSI_TASK_RUNNING) {
+	if (rc) {
 		/*
 		 * get an extra ref that is released next time we access it
 		 * as conn->task above.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (7 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 08/12] scsi: iscsi: remove unneeded task state check Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-14 17:44   ` Lee Duncan
  2022-03-18 17:31   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path Mike Christie
                   ` (2 subsequent siblings)
  11 siblings, 2 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

We currently require that the back_lock is held when calling the functions
that manipulate the iscsi_task refcount. The only reason for this is to
handle races where we are handing SCSI-ml eh callbacks and the cmd is
completing at the same time the normal completion path is running, and we
can't return from the EH callback until the driver has stopped accessing
the cmd. By holding the back_lock while also accessing the task->state
makes it simple to check that a cmd is completing and also get/put a
refcount at the same time.

The problem is that we don't want to take the back_lock from the xmit path
for normal IO since it causes contention with the completion path if the
user has chosen to try and split those paths on different CPUs (in this
case abusing the CPUs and igoring caching improves perf for some uses).

This patch begins to remove the back_lock requirement for
iscsi_get/put_task by removing the requirement for the get path. Instead
of always holding the back_lock we detect if something has done the last
put and is about to call iscsi_free_task. The next patch will then allow
iscsi code to do the last put on a task and only grab the back_lock if
the refcount is now zero and it's going to call iscsi_free_task.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/be2iscsi/be_main.c | 19 ++++++-
 drivers/scsi/libiscsi.c         | 95 +++++++++++++++++++++++----------
 drivers/scsi/libiscsi_tcp.c     |  5 +-
 include/scsi/libiscsi.h         |  2 +-
 4 files changed, 88 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ab55681145f8..26e5446ac237 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -231,6 +231,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 	cls_session = starget_to_session(scsi_target(sc->device));
 	session = cls_session->dd_data;
 
+completion_check:
 	/* check if we raced, task just got cleaned up under us */
 	spin_lock_bh(&session->back_lock);
 	if (!abrt_task || !abrt_task->sc) {
@@ -238,7 +239,13 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 		return SUCCESS;
 	}
 	/* get a task ref till FW processes the req for the ICD used */
-	__iscsi_get_task(abrt_task);
+	if (!iscsi_get_task(abrt_task)) {
+		spin_unlock(&session->back_lock);
+		/* We are just about to call iscsi_free_task so wait for it. */
+		udelay(5);
+		goto completion_check;
+	}
+
 	abrt_io_task = abrt_task->dd_data;
 	conn = abrt_task->conn;
 	beiscsi_conn = conn->dd_data;
@@ -323,7 +330,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 		}
 
 		/* get a task ref till FW processes the req for the ICD used */
-		__iscsi_get_task(task);
+		if (!iscsi_get_task(task)) {
+			/*
+			 * The task has completed in the driver and is
+			 * completing in libiscsi. Just ignore it here. When we
+			 * call iscsi_eh_device_reset, it will wait for us.
+			 */
+			continue;
+		}
+
 		io_task = task->dd_data;
 		/* mark WRB invalid which have been not processed by FW yet */
 		if (is_chip_be2_be3r(phba)) {
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 5c74ab92725f..a2d0daf5bd60 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -83,6 +83,8 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
 				"%s " dbg_fmt, __func__, ##arg);	\
 	} while (0);
 
+#define ISCSI_CMD_COMPL_WAIT 5
+
 inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
 {
 	struct Scsi_Host *shost = conn->session->host;
@@ -482,11 +484,11 @@ static void iscsi_free_task(struct iscsi_task *task)
 	}
 }
 
-void __iscsi_get_task(struct iscsi_task *task)
+bool iscsi_get_task(struct iscsi_task *task)
 {
-	refcount_inc(&task->refcount);
+	return refcount_inc_not_zero(&task->refcount);
 }
-EXPORT_SYMBOL_GPL(__iscsi_get_task);
+EXPORT_SYMBOL_GPL(iscsi_get_task);
 
 void __iscsi_put_task(struct iscsi_task *task)
 {
@@ -600,20 +602,17 @@ static bool cleanup_queued_task(struct iscsi_task *task)
 }
 
 /*
- * session frwd lock must be held and if not called for a task that is still
- * pending or from the xmit thread, then xmit thread must be suspended
+ * session back and frwd lock must be held and if not called for a task that
+ * is still pending or from the xmit thread, then xmit thread must be suspended
  */
-static void fail_scsi_task(struct iscsi_task *task, int err)
+static void __fail_scsi_task(struct iscsi_task *task, int err)
 {
 	struct iscsi_conn *conn = task->conn;
 	struct scsi_cmnd *sc;
 	int state;
 
-	spin_lock_bh(&conn->session->back_lock);
-	if (cleanup_queued_task(task)) {
-		spin_unlock_bh(&conn->session->back_lock);
+	if (cleanup_queued_task(task))
 		return;
-	}
 
 	if (task->state == ISCSI_TASK_PENDING) {
 		/*
@@ -632,7 +631,15 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
 	sc->result = err << 16;
 	scsi_set_resid(sc, scsi_bufflen(sc));
 	iscsi_complete_task(task, state);
-	spin_unlock_bh(&conn->session->back_lock);
+}
+
+static void fail_scsi_task(struct iscsi_task *task, int err)
+{
+	struct iscsi_session *session = task->conn->session;
+
+	spin_lock_bh(&session->back_lock);
+	__fail_scsi_task(task, err);
+	spin_unlock_bh(&session->back_lock);
 }
 
 static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
@@ -1449,8 +1456,17 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 	spin_lock_bh(&conn->session->back_lock);
 
 	if (!conn->task) {
-		/* Take a ref so we can access it after xmit_task() */
-		__iscsi_get_task(task);
+		/*
+		 * Take a ref so we can access it after xmit_task().
+		 *
+		 * This should never fail because the failure paths will have
+		 * stopped the xmit thread. WARN on move on.
+		 */
+		if (!iscsi_get_task(task)) {
+			spin_unlock_bh(&conn->session->back_lock);
+			WARN_ON_ONCE(1);
+			return 0;
+		}
 	} else {
 		/* Already have a ref from when we failed to send it last call */
 		conn->task = NULL;
@@ -1492,7 +1508,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 		 * get an extra ref that is released next time we access it
 		 * as conn->task above.
 		 */
-		__iscsi_get_task(task);
+		iscsi_get_task(task);
 		conn->task = task;
 	}
 
@@ -1907,6 +1923,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
 	struct iscsi_task *task;
 	int i;
 
+restart_cmd_loop:
 	spin_lock_bh(&session->back_lock);
 	for (i = 0; i < session->cmds_max; i++) {
 		task = session->cmds[i];
@@ -1915,22 +1932,25 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
 
 		if (lun != -1 && lun != task->sc->device->lun)
 			continue;
-
-		__iscsi_get_task(task);
-		spin_unlock_bh(&session->back_lock);
+		/*
+		 * The cmd is completing but if this is called from an eh
+		 * callout path then when we return scsi-ml owns the cmd. Wait
+		 * for the completion path to finish freeing the cmd.
+		 */
+		if (!iscsi_get_task(task)) {
+			spin_unlock_bh(&session->back_lock);
+			spin_unlock_bh(&session->frwd_lock);
+			udelay(ISCSI_CMD_COMPL_WAIT);
+			spin_lock_bh(&session->frwd_lock);
+			goto restart_cmd_loop;
+		}
 
 		ISCSI_DBG_SESSION(session,
 				  "failing sc %p itt 0x%x state %d\n",
 				  task->sc, task->itt, task->state);
-		fail_scsi_task(task, error);
-
-		spin_unlock_bh(&session->frwd_lock);
-		iscsi_put_task(task);
-		spin_lock_bh(&session->frwd_lock);
-
-		spin_lock_bh(&session->back_lock);
+		__fail_scsi_task(task, error);
+		__iscsi_put_task(task);
 	}
-
 	spin_unlock_bh(&session->back_lock);
 }
 
@@ -2035,7 +2055,16 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
 		spin_unlock(&session->back_lock);
 		goto done;
 	}
-	__iscsi_get_task(task);
+	if (!iscsi_get_task(task)) {
+		/*
+		 * Racing with the completion path right now, so give it more
+		 * time so that path can complete it like normal.
+		 */
+		rc = BLK_EH_RESET_TIMER;
+		task = NULL;
+		spin_unlock(&session->back_lock);
+		goto done;
+	}
 	spin_unlock(&session->back_lock);
 
 	if (session->state != ISCSI_STATE_LOGGED_IN) {
@@ -2282,6 +2311,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 
 	ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
 
+completion_check:
 	mutex_lock(&session->eh_mutex);
 	spin_lock_bh(&session->frwd_lock);
 	/*
@@ -2321,13 +2351,20 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 		return SUCCESS;
 	}
 
+	if (!iscsi_get_task(task)) {
+		spin_unlock(&session->back_lock);
+		spin_unlock_bh(&session->frwd_lock);
+		mutex_unlock(&session->eh_mutex);
+		/* We are just about to call iscsi_free_task so wait for it. */
+		udelay(ISCSI_CMD_COMPL_WAIT);
+		goto completion_check;
+	}
+
+	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
 	conn = session->leadconn;
 	iscsi_get_conn(conn->cls_conn);
 	conn->eh_abort_cnt++;
 	age = session->age;
-
-	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
-	__iscsi_get_task(task);
 	spin_unlock(&session->back_lock);
 
 	if (task->state == ISCSI_TASK_PENDING) {
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 883005757ddb..defe08142b75 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -558,7 +558,10 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
 		return 0;
 	}
 	task->last_xfer = jiffies;
-	__iscsi_get_task(task);
+	if (!iscsi_get_task(task)) {
+		/* Let the path that got the early rsp complete it */
+		return 0;
+	}
 
 	tcp_conn = conn->dd_data;
 	rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 522fd16f1dbb..9032a214104c 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -470,7 +470,7 @@ extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
 extern void iscsi_requeue_task(struct iscsi_task *task);
 extern void iscsi_put_task(struct iscsi_task *task);
 extern void __iscsi_put_task(struct iscsi_task *task);
-extern void __iscsi_get_task(struct iscsi_task *task);
+extern bool iscsi_get_task(struct iscsi_task *task);
 extern void iscsi_complete_scsi_task(struct iscsi_task *task,
 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (8 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-18 17:37   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API Mike Christie
  2022-03-08  0:27 ` [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit Mike Christie
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

We need the back lock when freeing a task, so we hold it when calling
__iscsi_put_task from the completion path to make it easier and to avoid
having to retake it in that path. For iscsi_put_task we just grabbed it
while also doing the decrement on the refcount but it's only really needed
if the refcount is zero and we free the task. This modifies iscsi_put_task
to just take the lock when needed then has the xmit path use it. Normally
we will then not take the back lock from the xmit path. It will only be
rare cases where the network is so fast that we get a response right after
we send the header/data.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index a2d0daf5bd60..cde389225059 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -490,6 +490,12 @@ bool iscsi_get_task(struct iscsi_task *task)
 }
 EXPORT_SYMBOL_GPL(iscsi_get_task);
 
+/**
+ * __iscsi_put_task - drop the refcount on a task
+ * @task: iscsi_task to drop the refcount on
+ *
+ * The back_lock must be held when calling in case it frees the task.
+ */
 void __iscsi_put_task(struct iscsi_task *task)
 {
 	if (refcount_dec_and_test(&task->refcount))
@@ -501,10 +507,11 @@ void iscsi_put_task(struct iscsi_task *task)
 {
 	struct iscsi_session *session = task->conn->session;
 
-	/* regular RX path uses back_lock */
-	spin_lock_bh(&session->back_lock);
-	__iscsi_put_task(task);
-	spin_unlock_bh(&session->back_lock);
+	if (refcount_dec_and_test(&task->refcount)) {
+		spin_lock_bh(&session->back_lock);
+		iscsi_free_task(task);
+		spin_unlock_bh(&session->back_lock);
+	}
 }
 EXPORT_SYMBOL_GPL(iscsi_put_task);
 
@@ -1453,8 +1460,6 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 {
 	int rc;
 
-	spin_lock_bh(&conn->session->back_lock);
-
 	if (!conn->task) {
 		/*
 		 * Take a ref so we can access it after xmit_task().
@@ -1463,7 +1468,6 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 		 * stopped the xmit thread. WARN on move on.
 		 */
 		if (!iscsi_get_task(task)) {
-			spin_unlock_bh(&conn->session->back_lock);
 			WARN_ON_ONCE(1);
 			return 0;
 		}
@@ -1477,7 +1481,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 	 * case a bad target sends a cmd rsp before we have handled the task.
 	 */
 	if (was_requeue)
-		__iscsi_put_task(task);
+		iscsi_put_task(task);
 
 	/*
 	 * Do this after dropping the extra ref because if this was a requeue
@@ -1489,10 +1493,8 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 		 * task and get woken up again.
 		 */
 		conn->task = task;
-		spin_unlock_bh(&conn->session->back_lock);
 		return -ENODATA;
 	}
-	spin_unlock_bh(&conn->session->back_lock);
 
 	spin_unlock_bh(&conn->session->frwd_lock);
 	rc = conn->session->tt->xmit_task(task);
@@ -1500,10 +1502,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 	if (!rc) {
 		/* done with this task */
 		task->last_xfer = jiffies;
-	}
-	/* regular RX path uses back_lock */
-	spin_lock(&conn->session->back_lock);
-	if (rc) {
+	} else {
 		/*
 		 * get an extra ref that is released next time we access it
 		 * as conn->task above.
@@ -1512,8 +1511,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
 		conn->task = task;
 	}
 
-	__iscsi_put_task(task);
-	spin_unlock(&conn->session->back_lock);
+	iscsi_put_task(task);
 	return rc;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (9 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-18 16:49   ` Lee Duncan
  2022-03-08  0:27 ` [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit Mike Christie
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

The conn_send_pdu API is evil in that it returns a pointer to a
iscsi_task, but that task might have been freed already so you can't
touch it. This patch splits the task allocation and transmission, so
functions like iscsi_send_nopout can access the task before its sent and
do whatever book keeping is needed before it's sent.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 85 ++++++++++++++++++++++++++++++-----------
 include/scsi/libiscsi.h |  3 --
 2 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index cde389225059..a165d4d10cea 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -695,12 +695,18 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
 	return 0;
 }
 
+/**
+ * iscsi_alloc_mgmt_task - allocate and setup a mgmt task.
+ * @conn: iscsi conn that the task will be sent on.
+ * @hdr: iscsi pdu that will be sent.
+ * @data: buffer for data segment if needed.
+ * @data_size: length of data in bytes.
+ */
 static struct iscsi_task *
-__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
+iscsi_alloc_mgmt_task(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 		      char *data, uint32_t data_size)
 {
 	struct iscsi_session *session = conn->session;
-	struct iscsi_host *ihost = shost_priv(session->host);
 	uint8_t opcode = hdr->opcode & ISCSI_OPCODE_MASK;
 	struct iscsi_task *task;
 	itt_t itt;
@@ -780,28 +786,57 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 						   task->conn->session->age);
 	}
 
-	if (unlikely(READ_ONCE(conn->ping_task) == INVALID_SCSI_TASK))
-		WRITE_ONCE(conn->ping_task, task);
+	return task;
+
+free_task:
+	iscsi_put_task(task);
+	return NULL;
+}
+
+/**
+ * iscsi_send_mgmt_task - Send task created with iscsi_alloc_mgmt_task.
+ * @task: iscsi task to send.
+ *
+ * On failure this returns a non-zero error code, and the driver must free
+ * the task with iscsi_put_task;
+ */
+static int iscsi_send_mgmt_task(struct iscsi_task *task)
+{
+	struct iscsi_conn *conn = task->conn;
+	struct iscsi_session *session = conn->session;
+	struct iscsi_host *ihost = shost_priv(conn->session->host);
+	int rc = 0;
 
 	if (!ihost->workq) {
-		if (iscsi_prep_mgmt_task(conn, task))
-			goto free_task;
+		rc = iscsi_prep_mgmt_task(conn, task);
+		if (rc)
+			return rc;
 
-		if (session->tt->xmit_task(task))
-			goto free_task;
+		rc = session->tt->xmit_task(task);
+		if (rc)
+			return rc;
 	} else {
 		list_add_tail(&task->running, &conn->mgmtqueue);
 		iscsi_conn_queue_xmit(conn);
 	}
 
-	return task;
+	return 0;
+}
 
-free_task:
-	/* regular RX path uses back_lock */
-	spin_lock(&session->back_lock);
-	__iscsi_put_task(task);
-	spin_unlock(&session->back_lock);
-	return NULL;
+static int __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
+				 char *data, uint32_t data_size)
+{
+	struct iscsi_task *task;
+	int rc;
+
+	task = iscsi_alloc_mgmt_task(conn, hdr, data, data_size);
+	if (!task)
+		return -ENOMEM;
+
+	rc = iscsi_send_mgmt_task(task);
+	if (rc)
+		iscsi_put_task(task);
+	return rc;
 }
 
 int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
@@ -812,7 +847,7 @@ int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
 	int err = 0;
 
 	spin_lock_bh(&session->frwd_lock);
-	if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
+	if (__iscsi_conn_send_pdu(conn, hdr, data, data_size))
 		err = -EPERM;
 	spin_unlock_bh(&session->frwd_lock);
 	return err;
@@ -985,7 +1020,6 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 	if (!rhdr) {
 		if (READ_ONCE(conn->ping_task))
 			return -EINVAL;
-		WRITE_ONCE(conn->ping_task, INVALID_SCSI_TASK);
 	}
 
 	memset(&hdr, 0, sizeof(struct iscsi_nopout));
@@ -999,10 +1033,18 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 	} else
 		hdr.ttt = RESERVED_ITT;
 
-	task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
-	if (!task) {
+	task = iscsi_alloc_mgmt_task(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
+	if (!task)
+		return -ENOMEM;
+
+	if (!rhdr)
+		WRITE_ONCE(conn->ping_task, task);
+
+	if (iscsi_send_mgmt_task(task)) {
 		if (!rhdr)
 			WRITE_ONCE(conn->ping_task, NULL);
+		iscsi_put_task(task);
+
 		iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n");
 		return -EIO;
 	} else if (!rhdr) {
@@ -1869,11 +1911,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
 	__must_hold(&session->frwd_lock)
 {
 	struct iscsi_session *session = conn->session;
-	struct iscsi_task *task;
 
-	task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
-				      NULL, 0);
-	if (!task) {
+	if (__iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0)) {
 		spin_unlock_bh(&session->frwd_lock);
 		iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n");
 		iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 9032a214104c..412722f44747 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -134,9 +134,6 @@ struct iscsi_task {
 	void			*dd_data;	/* driver/transport data */
 };
 
-/* invalid scsi_task pointer */
-#define	INVALID_SCSI_TASK	(struct iscsi_task *)-1l
-
 static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
 {
 	return task->unsol_r2t.data_length > task->unsol_r2t.sent;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit.
  2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
                   ` (10 preceding siblings ...)
  2022-03-08  0:27 ` [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API Mike Christie
@ 2022-03-08  0:27 ` Mike Christie
  2022-03-14 17:46   ` Lee Duncan
  11 siblings, 1 reply; 30+ messages in thread
From: Mike Christie @ 2022-03-08  0:27 UTC (permalink / raw)
  To: lduncan, cleech, martin.petersen, linux-scsi, jejb; +Cc: Mike Christie

set_bit doesn't provide a barrier, so we can hit race where we've called
iscsi_suspend_tx and didn't see a work queued, and then a work is queued
and run and doesn't see the suspend bit is set. We will then call into the
driver when they might have already cleaned up their xmit related code.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/libiscsi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index a165d4d10cea..b79739b41b10 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2020,10 +2020,14 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
  */
 void iscsi_suspend_tx(struct iscsi_conn *conn)
 {
-	struct Scsi_Host *shost = conn->session->host;
+	struct iscsi_session *session = conn->session;
+	struct Scsi_Host *shost = session->host;
 	struct iscsi_host *ihost = shost_priv(shost);
 
+	spin_lock_bh(&session->frwd_lock);
 	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
+	spin_unlock_bh(&session->frwd_lock);
+
 	if (ihost->workq)
 		flush_work(&conn->xmitwork);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 01/12] scsi: iscsi: Merge suspend fields
  2022-03-08  0:27 ` [PATCH 01/12] scsi: iscsi: Merge suspend fields Mike Christie
@ 2022-03-08 18:47   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-08 18:47 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> Move the tx and rx suspend fields into one flags field.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_hwi.c   |  2 +-
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |  2 +-
>   drivers/scsi/cxgbi/libcxgbi.c    |  6 +++---
>   drivers/scsi/libiscsi.c          | 20 ++++++++++----------
>   drivers/scsi/libiscsi_tcp.c      |  2 +-
>   include/scsi/libiscsi.h          |  9 +++++----
>   6 files changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 5521469ce678..e16327a4b4c9 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -1977,7 +1977,7 @@ static int bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
>   		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
>   			break;
>   
> -		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
> +		if (unlikely(test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
>   			if (nopin->op_code == ISCSI_OP_NOOP_IN &&
>   			    nopin->itt == (u16) RESERVED_ITT) {
>   				printk(KERN_ALERT "bnx2i: Unsolicited "
> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> index e21b053b4f3e..a592ca8602f9 100644
> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> @@ -1721,7 +1721,7 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
>   			struct iscsi_conn *conn = ep->conn->cls_conn->dd_data;
>   
>   			/* Must suspend all rx queue activity for this ep */
> -			set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
> +			set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
>   		}
>   		/* CONN_DISCONNECT timeout may or may not be an issue depending
>   		 * on what transcribed in TCP layer, different targets behave
> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
> index 8c7d4dda4cf2..4365d52c6430 100644
> --- a/drivers/scsi/cxgbi/libcxgbi.c
> +++ b/drivers/scsi/cxgbi/libcxgbi.c
> @@ -1634,11 +1634,11 @@ void cxgbi_conn_pdu_ready(struct cxgbi_sock *csk)
>   	log_debug(1 << CXGBI_DBG_PDU_RX,
>   		"csk 0x%p, conn 0x%p.\n", csk, conn);
>   
> -	if (unlikely(!conn || conn->suspend_rx)) {
> +	if (unlikely(!conn || test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
>   		log_debug(1 << CXGBI_DBG_PDU_RX,
> -			"csk 0x%p, conn 0x%p, id %d, suspend_rx %lu!\n",
> +			"csk 0x%p, conn 0x%p, id %d, conn flags 0x%lx!\n",
>   			csk, conn, conn ? conn->id : 0xFF,
> -			conn ? conn->suspend_rx : 0xFF);
> +			conn ? conn->flags : 0xFF);
>   		return;
>   	}
>   
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index a75b85f0a189..14f5737429cf 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -1392,8 +1392,8 @@ static bool iscsi_set_conn_failed(struct iscsi_conn *conn)
>   	if (conn->stop_stage == 0)
>   		session->state = ISCSI_STATE_FAILED;
>   
> -	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
> -	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
> +	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
> +	set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
>   	return true;
>   }
>   
> @@ -1454,7 +1454,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	 * Do this after dropping the extra ref because if this was a requeue
>   	 * it's removed from that list and cleanup_queued_task would miss it.
>   	 */
> -	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
> +	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
>   		/*
>   		 * Save the task and ref in case we weren't cleaning up this
>   		 * task and get woken up again.
> @@ -1532,7 +1532,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
>   	int rc = 0;
>   
>   	spin_lock_bh(&conn->session->frwd_lock);
> -	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
> +	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
>   		ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n");
>   		spin_unlock_bh(&conn->session->frwd_lock);
>   		return -ENODATA;
> @@ -1746,7 +1746,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>   		goto fault;
>   	}
>   
> -	if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
> +	if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) {
>   		reason = FAILURE_SESSION_IN_RECOVERY;
>   		sc->result = DID_REQUEUE << 16;
>   		goto fault;
> @@ -1935,7 +1935,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
>   void iscsi_suspend_queue(struct iscsi_conn *conn)
>   {
>   	spin_lock_bh(&conn->session->frwd_lock);
> -	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
> +	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
>   	spin_unlock_bh(&conn->session->frwd_lock);
>   }
>   EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
> @@ -1953,7 +1953,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn)
>   	struct Scsi_Host *shost = conn->session->host;
>   	struct iscsi_host *ihost = shost_priv(shost);
>   
> -	set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
> +	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
>   	if (ihost->workq)
>   		flush_workqueue(ihost->workq);
>   }
> @@ -1961,7 +1961,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
>   
>   static void iscsi_start_tx(struct iscsi_conn *conn)
>   {
> -	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
> +	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
>   	iscsi_conn_queue_work(conn);
>   }
>   
> @@ -3321,8 +3321,8 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
>   	/*
>   	 * Unblock xmitworker(), Login Phase will pass through.
>   	 */
> -	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
> -	clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
> +	clear_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
> +	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
>   	return 0;
>   }
>   EXPORT_SYMBOL_GPL(iscsi_conn_bind);
> diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
> index 2e9ffe3d1a55..883005757ddb 100644
> --- a/drivers/scsi/libiscsi_tcp.c
> +++ b/drivers/scsi/libiscsi_tcp.c
> @@ -927,7 +927,7 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
>   	 */
>   	conn->last_recv = jiffies;
>   
> -	if (unlikely(conn->suspend_rx)) {
> +	if (unlikely(test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) {
>   		ISCSI_DBG_TCP(conn, "Rx suspended!\n");
>   		*status = ISCSI_TCP_SUSPENDED;
>   		return 0;
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 2d85810d1929..10a9b89b7448 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -52,8 +52,10 @@ enum {
>   
>   #define ISID_SIZE			6
>   
> -/* Connection suspend "bit" */
> -#define ISCSI_SUSPEND_BIT		1
> +/* Connection flags */
> +#define ISCSI_CONN_FLAG_SUSPEND_TX	BIT(0)
> +#define ISCSI_CONN_FLAG_SUSPEND_RX	BIT(1)
> +
>   
>   #define ISCSI_ITT_MASK			0x1fff
>   #define ISCSI_TOTAL_CMDS_MAX		4096
> @@ -199,8 +201,7 @@ struct iscsi_conn {
>   	struct list_head	cmdqueue;	/* data-path cmd queue */
>   	struct list_head	requeue;	/* tasks needing another run */
>   	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
> -	unsigned long		suspend_tx;	/* suspend Tx */
> -	unsigned long		suspend_rx;	/* suspend Rx */
> +	unsigned long		flags;		/* ISCSI_CONN_FLAGs */
>   
>   	/* negotiated params */
>   	unsigned		max_recv_dlength; /* initiator_max_recv_dsl*/

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work
  2022-03-08  0:27 ` [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work Mike Christie
@ 2022-03-08 18:49   ` Lee Duncan
  2022-03-09  0:55   ` Wu Bo
  1 sibling, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-08 18:49 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> Rename iscsi_conn_queue_work to iscsi_conn_queue_xmit to reflect it
> handles queueing of xmits only.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/cxgbi/libcxgbi.c |  2 +-
>   drivers/scsi/iscsi_tcp.c      |  2 +-
>   drivers/scsi/libiscsi.c       | 12 ++++++------
>   include/scsi/libiscsi.h       |  2 +-
>   4 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
> index 4365d52c6430..411b0d386fad 100644
> --- a/drivers/scsi/cxgbi/libcxgbi.c
> +++ b/drivers/scsi/cxgbi/libcxgbi.c
> @@ -1455,7 +1455,7 @@ void cxgbi_conn_tx_open(struct cxgbi_sock *csk)
>   	if (conn) {
>   		log_debug(1 << CXGBI_DBG_SOCK,
>   			"csk 0x%p, cid %d.\n", csk, conn->id);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   }
>   EXPORT_SYMBOL_GPL(cxgbi_conn_tx_open);
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 1bc37593c88f..f274a86d2ec0 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -205,7 +205,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
>   	old_write_space(sk);
>   
>   	ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n");
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   }
>   
>   static void iscsi_sw_tcp_conn_set_callbacks(struct iscsi_conn *conn)
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 14f5737429cf..fa44445dc75f 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -83,7 +83,7 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
>   				"%s " dbg_fmt, __func__, ##arg);	\
>   	} while (0);
>   
> -inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
> +inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
>   {
>   	struct Scsi_Host *shost = conn->session->host;
>   	struct iscsi_host *ihost = shost_priv(shost);
> @@ -91,7 +91,7 @@ inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
>   	if (ihost->workq)
>   		queue_work(ihost->workq, &conn->xmitwork);
>   }
> -EXPORT_SYMBOL_GPL(iscsi_conn_queue_work);
> +EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit);
>   
>   static void __iscsi_update_cmdsn(struct iscsi_session *session,
>   				 uint32_t exp_cmdsn, uint32_t max_cmdsn)
> @@ -764,7 +764,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>   			goto free_task;
>   	} else {
>   		list_add_tail(&task->running, &conn->mgmtqueue);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   
>   	return task;
> @@ -1512,7 +1512,7 @@ void iscsi_requeue_task(struct iscsi_task *task)
>   		 */
>   		iscsi_put_task(task);
>   	}
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   	spin_unlock_bh(&conn->session->frwd_lock);
>   }
>   EXPORT_SYMBOL_GPL(iscsi_requeue_task);
> @@ -1781,7 +1781,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>   		}
>   	} else {
>   		list_add_tail(&task->running, &conn->cmdqueue);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   
>   	session->queued_cmdsn++;
> @@ -1962,7 +1962,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
>   static void iscsi_start_tx(struct iscsi_conn *conn)
>   {
>   	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   }
>   
>   /*
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 10a9b89b7448..b567ea4700e5 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -441,7 +441,7 @@ extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
>   				     enum iscsi_param param, char *buf);
>   extern void iscsi_suspend_tx(struct iscsi_conn *conn);
>   extern void iscsi_suspend_queue(struct iscsi_conn *conn);
> -extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
> +extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn);
>   
>   #define iscsi_conn_printk(prefix, _c, fmt, a...) \
>   	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run
  2022-03-08  0:27 ` [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run Mike Christie
@ 2022-03-08 19:00   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-08 19:00 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> Allow the recv and xmit works to run from different threads if the user
> has set it up.
> 
> This also removes the __WQ_LEGACY since it was never needed.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index fec64cbfa4b6..0a0076144874 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -2824,8 +2824,8 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
>   
>   	if (xmit_can_sleep) {
>   		ihost->workq = alloc_workqueue("iscsi_q_%d",
> -			WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND,
> -			1, shost->host_no);
> +			WQ_SYSFS | WQ_MEM_RECLAIM | WQ_UNBOUND,
> +			2, shost->host_no);
>   		if (!ihost->workq)
>   			goto free_host;
>   	}

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work
  2022-03-08  0:27 ` [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work Mike Christie
  2022-03-08 18:49   ` Lee Duncan
@ 2022-03-09  0:55   ` Wu Bo
  1 sibling, 0 replies; 30+ messages in thread
From: Wu Bo @ 2022-03-09  0:55 UTC (permalink / raw)
  To: Mike Christie, lduncan, cleech, martin.petersen, linux-scsi, jejb

On 2022/3/8 8:27, Mike Christie wrote:
> Rename iscsi_conn_queue_work to iscsi_conn_queue_xmit to reflect it
> handles queueing of xmits only.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/cxgbi/libcxgbi.c |  2 +-
>   drivers/scsi/iscsi_tcp.c      |  2 +-
>   drivers/scsi/libiscsi.c       | 12 ++++++------
>   include/scsi/libiscsi.h       |  2 +-
>   4 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
> index 4365d52c6430..411b0d386fad 100644
> --- a/drivers/scsi/cxgbi/libcxgbi.c
> +++ b/drivers/scsi/cxgbi/libcxgbi.c
> @@ -1455,7 +1455,7 @@ void cxgbi_conn_tx_open(struct cxgbi_sock *csk)
>   	if (conn) {
>   		log_debug(1 << CXGBI_DBG_SOCK,
>   			"csk 0x%p, cid %d.\n", csk, conn->id);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   }
>   EXPORT_SYMBOL_GPL(cxgbi_conn_tx_open);
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 1bc37593c88f..f274a86d2ec0 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -205,7 +205,7 @@ static void iscsi_sw_tcp_write_space(struct sock *sk)
>   	old_write_space(sk);
>   
>   	ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n");
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   }
>   
>   static void iscsi_sw_tcp_conn_set_callbacks(struct iscsi_conn *conn)
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 14f5737429cf..fa44445dc75f 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -83,7 +83,7 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
>   				"%s " dbg_fmt, __func__, ##arg);	\
>   	} while (0);
>   
> -inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
> +inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
>   {
>   	struct Scsi_Host *shost = conn->session->host;
>   	struct iscsi_host *ihost = shost_priv(shost);
> @@ -91,7 +91,7 @@ inline void iscsi_conn_queue_work(struct iscsi_conn *conn)
>   	if (ihost->workq)
>   		queue_work(ihost->workq, &conn->xmitwork);
>   }
> -EXPORT_SYMBOL_GPL(iscsi_conn_queue_work);
> +EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit);
>   
>   static void __iscsi_update_cmdsn(struct iscsi_session *session,
>   				 uint32_t exp_cmdsn, uint32_t max_cmdsn)
> @@ -764,7 +764,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>   			goto free_task;
>   	} else {
>   		list_add_tail(&task->running, &conn->mgmtqueue);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   
>   	return task;
> @@ -1512,7 +1512,7 @@ void iscsi_requeue_task(struct iscsi_task *task)
>   		 */
>   		iscsi_put_task(task);
>   	}
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   	spin_unlock_bh(&conn->session->frwd_lock);
>   }
>   EXPORT_SYMBOL_GPL(iscsi_requeue_task);
> @@ -1781,7 +1781,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
>   		}
>   	} else {
>   		list_add_tail(&task->running, &conn->cmdqueue);
> -		iscsi_conn_queue_work(conn);
> +		iscsi_conn_queue_xmit(conn);
>   	}
>   
>   	session->queued_cmdsn++;
> @@ -1962,7 +1962,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
>   static void iscsi_start_tx(struct iscsi_conn *conn)
>   {
>   	clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
> -	iscsi_conn_queue_work(conn);
> +	iscsi_conn_queue_xmit(conn);
>   }
>   
>   /*
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 10a9b89b7448..b567ea4700e5 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -441,7 +441,7 @@ extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
>   				     enum iscsi_param param, char *buf);
>   extern void iscsi_suspend_tx(struct iscsi_conn *conn);
>   extern void iscsi_suspend_queue(struct iscsi_conn *conn);
> -extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
> +extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn);
>   
>   #define iscsi_conn_printk(prefix, _c, fmt, a...) \
>   	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
> 

Reviewed-by: Wu Bo <wubo40@huawei.com>

.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use
  2022-03-08  0:27 ` [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use Mike Christie
@ 2022-03-09  1:31   ` Wu Bo
  2022-03-12 19:43   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Wu Bo @ 2022-03-09  1:31 UTC (permalink / raw)
  To: Mike Christie, lduncan, cleech, martin.petersen, linux-scsi, jejb

On 2022/3/8 8:27, Mike Christie wrote:
> For software iscsi, we do a session per host so there is no need to set
> the target's can_queue since its the same as the host one. It just results
> in extra atomic checks in the main IO path.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/iscsi_tcp.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 3bdefc4b6b17..974245eab605 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -1053,7 +1053,6 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
>   	.eh_target_reset_handler = iscsi_eh_recover_target,
>   	.dma_boundary		= PAGE_SIZE - 1,
>   	.slave_configure        = iscsi_sw_tcp_slave_configure,
> -	.target_alloc		= iscsi_target_alloc,
>   	.proc_name		= "iscsi_tcp",
>   	.this_id		= -1,
>   	.track_queue_depth	= 1,
> 
Reviewed-by: Wu Bo <wubo40@huawei.com>

.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 08/12] scsi: iscsi: remove unneeded task state check
  2022-03-08  0:27 ` [PATCH 08/12] scsi: iscsi: remove unneeded task state check Mike Christie
@ 2022-03-09  1:33   ` Wu Bo
  2022-03-14 17:13   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Wu Bo @ 2022-03-09  1:33 UTC (permalink / raw)
  To: Mike Christie, lduncan, cleech, martin.petersen, linux-scsi, jejb

On 2022/3/8 8:27, Mike Christie wrote:
> The patch:
> 
> commit 5923d64b7ab6 ("scsi: libiscsi: Drop taskqueuelock")
> 
> added an extra task->state because for
> 
> commit 6f8830f5bbab ("scsi: libiscsi: add lock around task lists to fix
> list corruption regression")
> 
> we didn't know why we ended up with cmds on the list and thought it
> might have been a bad target sending a response while we were still
> sending the cmd. We were never able to get a target to send us a response
> early, because it turns out the bug was just a race in libiscsi/
> libiscsi_tcp where
> 
> 1. iscsi_tcp_r2t_rsp queues a r2t to tcp_task->r2tqueue.
> 2. iscsi_tcp_task_xmit runs iscsi_tcp_get_curr_r2t and sees we have a r2t.
> It dequeues it and iscsi_tcp_task_xmit starts to process it.
> 3. iscsi_tcp_r2t_rsp runs iscsi_requeue_task and puts the task on the
> requeue list.
> 4. iscsi_tcp_task_xmit sends the data for r2t. This is the final chunk of
> data, so the cmd is done.
> 5. target sends the response.
> 6. On a different CPU from #3, iscsi_complete_task processes the response.
> Since there was no common lock for the list, the lists/tasks pointers are
> not fully in sync, so could end up with list corruption.
> 
> Since it was just a race on our side, this patch removes the extra check
> and fixes up the comments.
> 
> Reviewed-by: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 0a0076144874..5c74ab92725f 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -567,16 +567,19 @@ static bool cleanup_queued_task(struct iscsi_task *task)
>   	struct iscsi_conn *conn = task->conn;
>   	bool early_complete = false;
>   
> -	/* Bad target might have completed task while it was still running */
> +	/*
> +	 * We might have raced where we handled a R2T early and got a response
> +	 * but have not yet taken the task off the requeue list, then a TMF or
> +	 * recovery happened and so we can still see it here.
> +	 */
>   	if (task->state == ISCSI_TASK_COMPLETED)
>   		early_complete = true;
>   
>   	if (!list_empty(&task->running)) {
>   		list_del_init(&task->running);
>   		/*
> -		 * If it's on a list but still running, this could be from
> -		 * a bad target sending a rsp early, cleanup from a TMF, or
> -		 * session recovery.
> +		 * If it's on a list but still running this could be cleanup
> +		 * from a TMF or session recovery.
>   		 */
>   		if (task->state == ISCSI_TASK_RUNNING ||
>   		    task->state == ISCSI_TASK_COMPLETED)
> @@ -1484,7 +1487,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	}
>   	/* regular RX path uses back_lock */
>   	spin_lock(&conn->session->back_lock);
> -	if (rc && task->state == ISCSI_TASK_RUNNING) {
> +	if (rc) {
>   		/*
>   		 * get an extra ref that is released next time we access it
>   		 * as conn->task above.
> 
Reviewed-by: Wu Bo <wubo40@huawei.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers
  2022-03-08  0:27 ` [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers Mike Christie
@ 2022-03-10 22:50   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-10 22:50 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> Add helpers to allow the drivers to run their recv paths from libiscsi's
> workqueue.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 29 +++++++++++++++++++++++++++--
>   include/scsi/libiscsi.h |  4 ++++
>   2 files changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index fa44445dc75f..fec64cbfa4b6 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -93,6 +93,16 @@ inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
>   }
>   EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit);
>   
> +inline void iscsi_conn_queue_recv(struct iscsi_conn *conn)
> +{
> +	struct Scsi_Host *shost = conn->session->host;
> +	struct iscsi_host *ihost = shost_priv(shost);
> +
> +	if (ihost->workq && !test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))
> +		queue_work(ihost->workq, &conn->recvwork);
> +}
> +EXPORT_SYMBOL_GPL(iscsi_conn_queue_recv);
> +
>   static void __iscsi_update_cmdsn(struct iscsi_session *session,
>   				 uint32_t exp_cmdsn, uint32_t max_cmdsn)
>   {
> @@ -1942,7 +1952,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
>   
>   /**
>    * iscsi_suspend_tx - suspend iscsi_data_xmit
> - * @conn: iscsi conn tp stop processing IO on.
> + * @conn: iscsi conn to stop processing IO on.
>    *
>    * This function sets the suspend bit to prevent iscsi_data_xmit
>    * from sending new IO, and if work is queued on the xmit thread
> @@ -1955,7 +1965,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn)
>   
>   	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
>   	if (ihost->workq)
> -		flush_workqueue(ihost->workq);
> +		flush_work(&conn->xmitwork);
>   }
>   EXPORT_SYMBOL_GPL(iscsi_suspend_tx);
>   
> @@ -1965,6 +1975,21 @@ static void iscsi_start_tx(struct iscsi_conn *conn)
>   	iscsi_conn_queue_xmit(conn);
>   }
>   
> +/**
> + * iscsi_suspend_rx - Prevent recvwork from running again.
> + * @conn: iscsi conn to stop.
> + */
> +void iscsi_suspend_rx(struct iscsi_conn *conn)
> +{
> +	struct Scsi_Host *shost = conn->session->host;
> +	struct iscsi_host *ihost = shost_priv(shost);
> +
> +	set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags);
> +	if (ihost->workq)
> +		flush_work(&conn->recvwork);
> +}
> +EXPORT_SYMBOL_GPL(iscsi_suspend_rx);
> +
>   /*
>    * We want to make sure a ping is in flight. It has timed out.
>    * And we are not busy processing a pdu that is making
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index b567ea4700e5..522fd16f1dbb 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -201,6 +201,8 @@ struct iscsi_conn {
>   	struct list_head	cmdqueue;	/* data-path cmd queue */
>   	struct list_head	requeue;	/* tasks needing another run */
>   	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
> +	/* recv */
> +	struct work_struct	recvwork;
>   	unsigned long		flags;		/* ISCSI_CONN_FLAGs */
>   
>   	/* negotiated params */
> @@ -440,8 +442,10 @@ extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
>   extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
>   				     enum iscsi_param param, char *buf);
>   extern void iscsi_suspend_tx(struct iscsi_conn *conn);
> +extern void iscsi_suspend_rx(struct iscsi_conn *conn);
>   extern void iscsi_suspend_queue(struct iscsi_conn *conn);
>   extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn);
> +extern void iscsi_conn_queue_recv(struct iscsi_conn *conn);
>   
>   #define iscsi_conn_printk(prefix, _c, fmt, a...) \
>   	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header
  2022-03-08  0:27 ` [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header Mike Christie
@ 2022-03-12 19:42   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-12 19:42 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> This has us use zero copy the PDU header.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/iscsi_tcp.c | 30 ++++++++++++++++++++++--------
>   1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 261599938fc9..3bdefc4b6b17 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -306,7 +306,7 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
>   		copy = segment->size - offset;
>   
>   		if (segment->total_copied + segment->size < segment->total_size)
> -			flags |= MSG_MORE;
> +			flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST;
>   
>   		/* Use sendpage if we can; else fall back to sendmsg */
>   		if (!segment->data) {
> @@ -315,13 +315,27 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
>   			r = tcp_sw_conn->sendpage(sk, sg_page(sg), offset,
>   						  copy, flags);
>   		} else {
> -			struct msghdr msg = { .msg_flags = flags };
> -			struct kvec iov = {
> -				.iov_base = segment->data + offset,
> -				.iov_len = copy
> -			};
> -
> -			r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
> +			void *data = segment->data + offset;
> +
> +			/*
> +			 * Make sure it's ok to send the header using zero
> +			 * copy. The case where the sg page can't be zero
> +			 * copied will also go down the sendmsg path.
> +			 */
> +			if (sendpage_ok(data)) {
> +				r = tcp_sw_conn->sendpage(sk,
> +						virt_to_page(data),
> +						offset_in_page(data), copy,
> +						flags);
> +			} else {
> +				struct msghdr msg = { .msg_flags = flags };
> +				struct kvec iov = {
> +					.iov_base = data,
> +					.iov_len = copy,
> +				};
> +
> +				r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
> +			}
>   		}
>   
>   		if (r < 0) {

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use
  2022-03-08  0:27 ` [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use Mike Christie
  2022-03-09  1:31   ` Wu Bo
@ 2022-03-12 19:43   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-12 19:43 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> For software iscsi, we do a session per host so there is no need to set
> the target's can_queue since its the same as the host one. It just results
> in extra atomic checks in the main IO path.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/iscsi_tcp.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 3bdefc4b6b17..974245eab605 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -1053,7 +1053,6 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
>   	.eh_target_reset_handler = iscsi_eh_recover_target,
>   	.dma_boundary		= PAGE_SIZE - 1,
>   	.slave_configure        = iscsi_sw_tcp_slave_configure,
> -	.target_alloc		= iscsi_target_alloc,
>   	.proc_name		= "iscsi_tcp",
>   	.this_id		= -1,
>   	.track_queue_depth	= 1,

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 08/12] scsi: iscsi: remove unneeded task state check
  2022-03-08  0:27 ` [PATCH 08/12] scsi: iscsi: remove unneeded task state check Mike Christie
  2022-03-09  1:33   ` Wu Bo
@ 2022-03-14 17:13   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-14 17:13 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> The patch:
> 
> commit 5923d64b7ab6 ("scsi: libiscsi: Drop taskqueuelock")
> 
> added an extra task->state because for
> 
> commit 6f8830f5bbab ("scsi: libiscsi: add lock around task lists to fix
> list corruption regression")
> 
> we didn't know why we ended up with cmds on the list and thought it
> might have been a bad target sending a response while we were still
> sending the cmd. We were never able to get a target to send us a response
> early, because it turns out the bug was just a race in libiscsi/
> libiscsi_tcp where
> 
> 1. iscsi_tcp_r2t_rsp queues a r2t to tcp_task->r2tqueue.
> 2. iscsi_tcp_task_xmit runs iscsi_tcp_get_curr_r2t and sees we have a r2t.
> It dequeues it and iscsi_tcp_task_xmit starts to process it.
> 3. iscsi_tcp_r2t_rsp runs iscsi_requeue_task and puts the task on the
> requeue list.
> 4. iscsi_tcp_task_xmit sends the data for r2t. This is the final chunk of
> data, so the cmd is done.
> 5. target sends the response.
> 6. On a different CPU from #3, iscsi_complete_task processes the response.
> Since there was no common lock for the list, the lists/tasks pointers are
> not fully in sync, so could end up with list corruption.
> 
> Since it was just a race on our side, this patch removes the extra check
> and fixes up the comments.
> 
> Reviewed-by: Lee Duncan <lduncan@suse.com>
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 0a0076144874..5c74ab92725f 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -567,16 +567,19 @@ static bool cleanup_queued_task(struct iscsi_task *task)
>   	struct iscsi_conn *conn = task->conn;
>   	bool early_complete = false;
>   
> -	/* Bad target might have completed task while it was still running */
> +	/*
> +	 * We might have raced where we handled a R2T early and got a response
> +	 * but have not yet taken the task off the requeue list, then a TMF or
> +	 * recovery happened and so we can still see it here.
> +	 */
>   	if (task->state == ISCSI_TASK_COMPLETED)
>   		early_complete = true;
>   
>   	if (!list_empty(&task->running)) {
>   		list_del_init(&task->running);
>   		/*
> -		 * If it's on a list but still running, this could be from
> -		 * a bad target sending a rsp early, cleanup from a TMF, or
> -		 * session recovery.
> +		 * If it's on a list but still running this could be cleanup
> +		 * from a TMF or session recovery.
>   		 */
>   		if (task->state == ISCSI_TASK_RUNNING ||
>   		    task->state == ISCSI_TASK_COMPLETED)
> @@ -1484,7 +1487,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	}
>   	/* regular RX path uses back_lock */
>   	spin_lock(&conn->session->back_lock);
> -	if (rc && task->state == ISCSI_TASK_RUNNING) {
> +	if (rc) {
>   		/*
>   		 * get an extra ref that is released next time we access it
>   		 * as conn->task above.

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement
  2022-03-08  0:27 ` [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement Mike Christie
@ 2022-03-14 17:44   ` Lee Duncan
  2022-03-18 17:31   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-14 17:44 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> We currently require that the back_lock is held when calling the functions
> that manipulate the iscsi_task refcount. The only reason for this is to
> handle races where we are handing SCSI-ml eh callbacks and the cmd is
> completing at the same time the normal completion path is running, and we
> can't return from the EH callback until the driver has stopped accessing
> the cmd. By holding the back_lock while also accessing the task->state
> makes it simple to check that a cmd is completing and also get/put a
> refcount at the same time.
> 
> The problem is that we don't want to take the back_lock from the xmit path
> for normal IO since it causes contention with the completion path if the
> user has chosen to try and split those paths on different CPUs (in this
> case abusing the CPUs and igoring caching improves perf for some uses).
> 
> This patch begins to remove the back_lock requirement for
> iscsi_get/put_task by removing the requirement for the get path. Instead
> of always holding the back_lock we detect if something has done the last
> put and is about to call iscsi_free_task. The next patch will then allow
> iscsi code to do the last put on a task and only grab the back_lock if
> the refcount is now zero and it's going to call iscsi_free_task.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/be2iscsi/be_main.c | 19 ++++++-
>   drivers/scsi/libiscsi.c         | 95 +++++++++++++++++++++++----------
>   drivers/scsi/libiscsi_tcp.c     |  5 +-
>   include/scsi/libiscsi.h         |  2 +-
>   4 files changed, 88 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index ab55681145f8..26e5446ac237 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -231,6 +231,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
>   	cls_session = starget_to_session(scsi_target(sc->device));
>   	session = cls_session->dd_data;
>   
> +completion_check:
>   	/* check if we raced, task just got cleaned up under us */
>   	spin_lock_bh(&session->back_lock);
>   	if (!abrt_task || !abrt_task->sc) {
> @@ -238,7 +239,13 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
>   		return SUCCESS;
>   	}
>   	/* get a task ref till FW processes the req for the ICD used */
> -	__iscsi_get_task(abrt_task);
> +	if (!iscsi_get_task(abrt_task)) {
> +		spin_unlock(&session->back_lock);
> +		/* We are just about to call iscsi_free_task so wait for it. */
> +		udelay(5);
> +		goto completion_check;
> +	}
> +
>   	abrt_io_task = abrt_task->dd_data;
>   	conn = abrt_task->conn;
>   	beiscsi_conn = conn->dd_data;
> @@ -323,7 +330,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
>   		}
>   
>   		/* get a task ref till FW processes the req for the ICD used */
> -		__iscsi_get_task(task);
> +		if (!iscsi_get_task(task)) {
> +			/*
> +			 * The task has completed in the driver and is
> +			 * completing in libiscsi. Just ignore it here. When we
> +			 * call iscsi_eh_device_reset, it will wait for us.
> +			 */
> +			continue;
> +		}
> +
>   		io_task = task->dd_data;
>   		/* mark WRB invalid which have been not processed by FW yet */
>   		if (is_chip_be2_be3r(phba)) {
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 5c74ab92725f..a2d0daf5bd60 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -83,6 +83,8 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
>   				"%s " dbg_fmt, __func__, ##arg);	\
>   	} while (0);
>   
> +#define ISCSI_CMD_COMPL_WAIT 5
> +
>   inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
>   {
>   	struct Scsi_Host *shost = conn->session->host;
> @@ -482,11 +484,11 @@ static void iscsi_free_task(struct iscsi_task *task)
>   	}
>   }
>   
> -void __iscsi_get_task(struct iscsi_task *task)
> +bool iscsi_get_task(struct iscsi_task *task)
>   {
> -	refcount_inc(&task->refcount);
> +	return refcount_inc_not_zero(&task->refcount);
>   }
> -EXPORT_SYMBOL_GPL(__iscsi_get_task);
> +EXPORT_SYMBOL_GPL(iscsi_get_task);
>   
>   void __iscsi_put_task(struct iscsi_task *task)
>   {
> @@ -600,20 +602,17 @@ static bool cleanup_queued_task(struct iscsi_task *task)
>   }
>   
>   /*
> - * session frwd lock must be held and if not called for a task that is still
> - * pending or from the xmit thread, then xmit thread must be suspended
> + * session back and frwd lock must be held and if not called for a task that
> + * is still pending or from the xmit thread, then xmit thread must be suspended
>    */
> -static void fail_scsi_task(struct iscsi_task *task, int err)
> +static void __fail_scsi_task(struct iscsi_task *task, int err)
>   {
>   	struct iscsi_conn *conn = task->conn;
>   	struct scsi_cmnd *sc;
>   	int state;
>   
> -	spin_lock_bh(&conn->session->back_lock);
> -	if (cleanup_queued_task(task)) {
> -		spin_unlock_bh(&conn->session->back_lock);
> +	if (cleanup_queued_task(task))
>   		return;
> -	}
>   
>   	if (task->state == ISCSI_TASK_PENDING) {
>   		/*
> @@ -632,7 +631,15 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
>   	sc->result = err << 16;
>   	scsi_set_resid(sc, scsi_bufflen(sc));
>   	iscsi_complete_task(task, state);
> -	spin_unlock_bh(&conn->session->back_lock);
> +}
> +
> +static void fail_scsi_task(struct iscsi_task *task, int err)
> +{
> +	struct iscsi_session *session = task->conn->session;
> +
> +	spin_lock_bh(&session->back_lock);
> +	__fail_scsi_task(task, err);
> +	spin_unlock_bh(&session->back_lock);
>   }
>   
>   static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
> @@ -1449,8 +1456,17 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	spin_lock_bh(&conn->session->back_lock);
>   
>   	if (!conn->task) {
> -		/* Take a ref so we can access it after xmit_task() */
> -		__iscsi_get_task(task);
> +		/*
> +		 * Take a ref so we can access it after xmit_task().
> +		 *
> +		 * This should never fail because the failure paths will have
> +		 * stopped the xmit thread. WARN on move on.
> +		 */
> +		if (!iscsi_get_task(task)) {
> +			spin_unlock_bh(&conn->session->back_lock);
> +			WARN_ON_ONCE(1);
> +			return 0;
> +		}
>   	} else {
>   		/* Already have a ref from when we failed to send it last call */
>   		conn->task = NULL;
> @@ -1492,7 +1508,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   		 * get an extra ref that is released next time we access it
>   		 * as conn->task above.
>   		 */
> -		__iscsi_get_task(task);
> +		iscsi_get_task(task);
>   		conn->task = task;
>   	}
>   
> @@ -1907,6 +1923,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
>   	struct iscsi_task *task;
>   	int i;
>   
> +restart_cmd_loop:
>   	spin_lock_bh(&session->back_lock);
>   	for (i = 0; i < session->cmds_max; i++) {
>   		task = session->cmds[i];
> @@ -1915,22 +1932,25 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
>   
>   		if (lun != -1 && lun != task->sc->device->lun)
>   			continue;
> -
> -		__iscsi_get_task(task);
> -		spin_unlock_bh(&session->back_lock);
> +		/*
> +		 * The cmd is completing but if this is called from an eh
> +		 * callout path then when we return scsi-ml owns the cmd. Wait
> +		 * for the completion path to finish freeing the cmd.
> +		 */
> +		if (!iscsi_get_task(task)) {
> +			spin_unlock_bh(&session->back_lock);
> +			spin_unlock_bh(&session->frwd_lock);
> +			udelay(ISCSI_CMD_COMPL_WAIT);
> +			spin_lock_bh(&session->frwd_lock);
> +			goto restart_cmd_loop;
> +		}
>   
>   		ISCSI_DBG_SESSION(session,
>   				  "failing sc %p itt 0x%x state %d\n",
>   				  task->sc, task->itt, task->state);
> -		fail_scsi_task(task, error);
> -
> -		spin_unlock_bh(&session->frwd_lock);
> -		iscsi_put_task(task);
> -		spin_lock_bh(&session->frwd_lock);
> -
> -		spin_lock_bh(&session->back_lock);
> +		__fail_scsi_task(task, error);
> +		__iscsi_put_task(task);
>   	}
> -
>   	spin_unlock_bh(&session->back_lock);
>   }
>   
> @@ -2035,7 +2055,16 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
>   		spin_unlock(&session->back_lock);
>   		goto done;
>   	}
> -	__iscsi_get_task(task);
> +	if (!iscsi_get_task(task)) {
> +		/*
> +		 * Racing with the completion path right now, so give it more
> +		 * time so that path can complete it like normal.
> +		 */
> +		rc = BLK_EH_RESET_TIMER;
> +		task = NULL;
> +		spin_unlock(&session->back_lock);
> +		goto done;
> +	}
>   	spin_unlock(&session->back_lock);
>   
>   	if (session->state != ISCSI_STATE_LOGGED_IN) {
> @@ -2282,6 +2311,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
>   
>   	ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
>   
> +completion_check:
>   	mutex_lock(&session->eh_mutex);
>   	spin_lock_bh(&session->frwd_lock);
>   	/*
> @@ -2321,13 +2351,20 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
>   		return SUCCESS;
>   	}
>   
> +	if (!iscsi_get_task(task)) {
> +		spin_unlock(&session->back_lock);
> +		spin_unlock_bh(&session->frwd_lock);
> +		mutex_unlock(&session->eh_mutex);
> +		/* We are just about to call iscsi_free_task so wait for it. */
> +		udelay(ISCSI_CMD_COMPL_WAIT);
> +		goto completion_check;
> +	}
> +
> +	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
>   	conn = session->leadconn;
>   	iscsi_get_conn(conn->cls_conn);
>   	conn->eh_abort_cnt++;
>   	age = session->age;
> -
> -	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
> -	__iscsi_get_task(task);
>   	spin_unlock(&session->back_lock);
>   
>   	if (task->state == ISCSI_TASK_PENDING) {
> diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
> index 883005757ddb..defe08142b75 100644
> --- a/drivers/scsi/libiscsi_tcp.c
> +++ b/drivers/scsi/libiscsi_tcp.c
> @@ -558,7 +558,10 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
>   		return 0;
>   	}
>   	task->last_xfer = jiffies;
> -	__iscsi_get_task(task);
> +	if (!iscsi_get_task(task)) {
> +		/* Let the path that got the early rsp complete it */
> +		return 0;
> +	}
>   
>   	tcp_conn = conn->dd_data;
>   	rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr;
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 522fd16f1dbb..9032a214104c 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -470,7 +470,7 @@ extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
>   extern void iscsi_requeue_task(struct iscsi_task *task);
>   extern void iscsi_put_task(struct iscsi_task *task);
>   extern void __iscsi_put_task(struct iscsi_task *task);
> -extern void __iscsi_get_task(struct iscsi_task *task);
> +extern bool iscsi_get_task(struct iscsi_task *task);
>   extern void iscsi_complete_scsi_task(struct iscsi_task *task,
>   				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
>   

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit.
  2022-03-08  0:27 ` [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit Mike Christie
@ 2022-03-14 17:46   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-14 17:46 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> set_bit doesn't provide a barrier, so we can hit race where we've called
> iscsi_suspend_tx and didn't see a work queued, and then a work is queued
> and run and doesn't see the suspend bit is set. We will then call into the
> driver when they might have already cleaned up their xmit related code.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index a165d4d10cea..b79739b41b10 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -2020,10 +2020,14 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
>    */
>   void iscsi_suspend_tx(struct iscsi_conn *conn)
>   {
> -	struct Scsi_Host *shost = conn->session->host;
> +	struct iscsi_session *session = conn->session;
> +	struct Scsi_Host *shost = session->host;
>   	struct iscsi_host *ihost = shost_priv(shost);
>   
> +	spin_lock_bh(&session->frwd_lock);
>   	set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags);
> +	spin_unlock_bh(&session->frwd_lock);
> +
>   	if (ihost->workq)
>   		flush_work(&conn->xmitwork);
>   }

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 05/12] scsi: iscsi: Run recv path from workqueue
  2022-03-08  0:27 ` [PATCH 05/12] scsi: iscsi: Run recv path from workqueue Mike Christie
@ 2022-03-18 16:45   ` Lee Duncan
  2022-03-18 22:11     ` Mike Christie
  0 siblings, 1 reply; 30+ messages in thread
From: Lee Duncan @ 2022-03-18 16:45 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> We don't always want to run the recv path from the network softirq
> because when we have to have multiple sessions sharing the same CPUs some
> sessions can eat up the napi softirq budget and affect other sessions or
> users. This patch allows us to queue the recv handling to the iscsi
> workqueue so we can have the scheduler/wq code try to balance the work and
> CPU use across all sessions's  worker threads.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/iscsi_tcp.c | 62 +++++++++++++++++++++++++++++++---------
>   drivers/scsi/iscsi_tcp.h |  2 ++
>   2 files changed, 51 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index f274a86d2ec0..261599938fc9 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -52,6 +52,10 @@ static struct iscsi_transport iscsi_sw_tcp_transport;
>   static unsigned int iscsi_max_lun = ~0;
>   module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
>   
> +static bool iscsi_use_recv_wq;
> +module_param_named(use_recv_wq, iscsi_use_recv_wq, bool, 0644);
> +MODULE_PARM_DESC(use_recv_wq, "Set to true to read iSCSI data/headers from the iscsi_q workqueue. The default is false which will perform reads from the network softirq context.");

I'm just curious why you chose to make this a module parameter, leaving 
the current default.

> +
>   static int iscsi_sw_tcp_dbg;
>   module_param_named(debug_iscsi_tcp, iscsi_sw_tcp_dbg, int,
>   		   S_IRUGO | S_IWUSR);
> @@ -122,20 +126,13 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
>   	return 0;
>   }
>   
> -static void iscsi_sw_tcp_data_ready(struct sock *sk)
> +static void iscsi_sw_tcp_recv_data(struct iscsi_conn *conn)
>   {
> -	struct iscsi_conn *conn;
> -	struct iscsi_tcp_conn *tcp_conn;
> +	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
> +	struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
> +	struct sock *sk = tcp_sw_conn->sock->sk;
>   	read_descriptor_t rd_desc;
>   
> -	read_lock_bh(&sk->sk_callback_lock);
> -	conn = sk->sk_user_data;
> -	if (!conn) {
> -		read_unlock_bh(&sk->sk_callback_lock);
> -		return;
> -	}
> -	tcp_conn = conn->dd_data;
> -
>   	/*
>   	 * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
>   	 * We set count to 1 because we want the network layer to
> @@ -144,13 +141,48 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk)
>   	 */
>   	rd_desc.arg.data = conn;
>   	rd_desc.count = 1;
> -	tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv);
>   
> -	iscsi_sw_sk_state_check(sk);
> +	tcp_read_sock(sk, &rd_desc, iscsi_sw_tcp_recv);
>   
>   	/* If we had to (atomically) map a highmem page,
>   	 * unmap it now. */
>   	iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
> +
> +	iscsi_sw_sk_state_check(sk);
> +}
> +
> +static void iscsi_sw_tcp_recv_data_work(struct work_struct *work)
> +{
> +	struct iscsi_conn *conn = container_of(work, struct iscsi_conn,
> +					       recvwork);
> +	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
> +	struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
> +	struct sock *sk = tcp_sw_conn->sock->sk;
> +
> +	lock_sock(sk);
> +	iscsi_sw_tcp_recv_data(conn);
> +	release_sock(sk);
> +}
> +
> +static void iscsi_sw_tcp_data_ready(struct sock *sk)
> +{
> +	struct iscsi_sw_tcp_conn *tcp_sw_conn;
> +	struct iscsi_tcp_conn *tcp_conn;
> +	struct iscsi_conn *conn;
> +
> +	read_lock_bh(&sk->sk_callback_lock);
> +	conn = sk->sk_user_data;
> +	if (!conn) {
> +		read_unlock_bh(&sk->sk_callback_lock);
> +		return;
> +	}
> +	tcp_conn = conn->dd_data;
> +	tcp_sw_conn = tcp_conn->dd_data;
> +
> +	if (tcp_sw_conn->queue_recv)
> +		iscsi_conn_queue_recv(conn);
> +	else
> +		iscsi_sw_tcp_recv_data(conn);
>   	read_unlock_bh(&sk->sk_callback_lock);
>   }
>   
> @@ -557,6 +589,8 @@ iscsi_sw_tcp_conn_create(struct iscsi_cls_session *cls_session,
>   	conn = cls_conn->dd_data;
>   	tcp_conn = conn->dd_data;
>   	tcp_sw_conn = tcp_conn->dd_data;
> +	INIT_WORK(&conn->recvwork, iscsi_sw_tcp_recv_data_work);
> +	tcp_sw_conn->queue_recv = iscsi_use_recv_wq;
>   
>   	tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
>   	if (IS_ERR(tfm))
> @@ -606,6 +640,8 @@ static void iscsi_sw_tcp_release_conn(struct iscsi_conn *conn)
>   	 */
>   	kernel_sock_shutdown(sock, SHUT_RDWR);
>   
> +	iscsi_suspend_rx(conn);
> +
>   	sock_hold(sock->sk);
>   	iscsi_sw_tcp_conn_restore_callbacks(conn);
>   	sock_put(sock->sk);
> diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
> index 791453195099..850a018aefb9 100644
> --- a/drivers/scsi/iscsi_tcp.h
> +++ b/drivers/scsi/iscsi_tcp.h
> @@ -28,6 +28,8 @@ struct iscsi_sw_tcp_send {
>   
>   struct iscsi_sw_tcp_conn {
>   	struct socket		*sock;
> +	struct work_struct	recvwork;
> +	bool			queue_recv;
>   
>   	struct iscsi_sw_tcp_send out;
>   	/* old values for socket callbacks */

Other than my question above, I'm fine with this.

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API
  2022-03-08  0:27 ` [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API Mike Christie
@ 2022-03-18 16:49   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-18 16:49 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> The conn_send_pdu API is evil in that it returns a pointer to a
> iscsi_task, but that task might have been freed already so you can't
> touch it. This patch splits the task allocation and transmission, so
> functions like iscsi_send_nopout can access the task before its sent and
> do whatever book keeping is needed before it's sent.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 85 ++++++++++++++++++++++++++++++-----------
>   include/scsi/libiscsi.h |  3 --
>   2 files changed, 62 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index cde389225059..a165d4d10cea 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -695,12 +695,18 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
>   	return 0;
>   }
>   
> +/**
> + * iscsi_alloc_mgmt_task - allocate and setup a mgmt task.
> + * @conn: iscsi conn that the task will be sent on.
> + * @hdr: iscsi pdu that will be sent.
> + * @data: buffer for data segment if needed.
> + * @data_size: length of data in bytes.
> + */
>   static struct iscsi_task *
> -__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
> +iscsi_alloc_mgmt_task(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>   		      char *data, uint32_t data_size)
>   {
>   	struct iscsi_session *session = conn->session;
> -	struct iscsi_host *ihost = shost_priv(session->host);
>   	uint8_t opcode = hdr->opcode & ISCSI_OPCODE_MASK;
>   	struct iscsi_task *task;
>   	itt_t itt;
> @@ -780,28 +786,57 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>   						   task->conn->session->age);
>   	}
>   
> -	if (unlikely(READ_ONCE(conn->ping_task) == INVALID_SCSI_TASK))
> -		WRITE_ONCE(conn->ping_task, task);
> +	return task;
> +
> +free_task:
> +	iscsi_put_task(task);
> +	return NULL;
> +}
> +
> +/**
> + * iscsi_send_mgmt_task - Send task created with iscsi_alloc_mgmt_task.
> + * @task: iscsi task to send.
> + *
> + * On failure this returns a non-zero error code, and the driver must free
> + * the task with iscsi_put_task;
> + */
> +static int iscsi_send_mgmt_task(struct iscsi_task *task)
> +{
> +	struct iscsi_conn *conn = task->conn;
> +	struct iscsi_session *session = conn->session;
> +	struct iscsi_host *ihost = shost_priv(conn->session->host);
> +	int rc = 0;
>   
>   	if (!ihost->workq) {
> -		if (iscsi_prep_mgmt_task(conn, task))
> -			goto free_task;
> +		rc = iscsi_prep_mgmt_task(conn, task);
> +		if (rc)
> +			return rc;
>   
> -		if (session->tt->xmit_task(task))
> -			goto free_task;
> +		rc = session->tt->xmit_task(task);
> +		if (rc)
> +			return rc;
>   	} else {
>   		list_add_tail(&task->running, &conn->mgmtqueue);
>   		iscsi_conn_queue_xmit(conn);
>   	}
>   
> -	return task;
> +	return 0;
> +}
>   
> -free_task:
> -	/* regular RX path uses back_lock */
> -	spin_lock(&session->back_lock);
> -	__iscsi_put_task(task);
> -	spin_unlock(&session->back_lock);
> -	return NULL;
> +static int __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
> +				 char *data, uint32_t data_size)
> +{
> +	struct iscsi_task *task;
> +	int rc;
> +
> +	task = iscsi_alloc_mgmt_task(conn, hdr, data, data_size);
> +	if (!task)
> +		return -ENOMEM;
> +
> +	rc = iscsi_send_mgmt_task(task);
> +	if (rc)
> +		iscsi_put_task(task);
> +	return rc;
>   }
>   
>   int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
> @@ -812,7 +847,7 @@ int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
>   	int err = 0;
>   
>   	spin_lock_bh(&session->frwd_lock);
> -	if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
> +	if (__iscsi_conn_send_pdu(conn, hdr, data, data_size))
>   		err = -EPERM;
>   	spin_unlock_bh(&session->frwd_lock);
>   	return err;
> @@ -985,7 +1020,6 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
>   	if (!rhdr) {
>   		if (READ_ONCE(conn->ping_task))
>   			return -EINVAL;
> -		WRITE_ONCE(conn->ping_task, INVALID_SCSI_TASK);
>   	}
>   
>   	memset(&hdr, 0, sizeof(struct iscsi_nopout));
> @@ -999,10 +1033,18 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
>   	} else
>   		hdr.ttt = RESERVED_ITT;
>   
> -	task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
> -	if (!task) {
> +	task = iscsi_alloc_mgmt_task(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
> +	if (!task)
> +		return -ENOMEM;
> +
> +	if (!rhdr)
> +		WRITE_ONCE(conn->ping_task, task);
> +
> +	if (iscsi_send_mgmt_task(task)) {
>   		if (!rhdr)
>   			WRITE_ONCE(conn->ping_task, NULL);
> +		iscsi_put_task(task);
> +
>   		iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n");
>   		return -EIO;
>   	} else if (!rhdr) {
> @@ -1869,11 +1911,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
>   	__must_hold(&session->frwd_lock)
>   {
>   	struct iscsi_session *session = conn->session;
> -	struct iscsi_task *task;
>   
> -	task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
> -				      NULL, 0);
> -	if (!task) {
> +	if (__iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0)) {
>   		spin_unlock_bh(&session->frwd_lock);
>   		iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n");
>   		iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 9032a214104c..412722f44747 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -134,9 +134,6 @@ struct iscsi_task {
>   	void			*dd_data;	/* driver/transport data */
>   };
>   
> -/* invalid scsi_task pointer */
> -#define	INVALID_SCSI_TASK	(struct iscsi_task *)-1l
> -
>   static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
>   {
>   	return task->unsol_r2t.data_length > task->unsol_r2t.sent;

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement
  2022-03-08  0:27 ` [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement Mike Christie
  2022-03-14 17:44   ` Lee Duncan
@ 2022-03-18 17:31   ` Lee Duncan
  1 sibling, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-18 17:31 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> We currently require that the back_lock is held when calling the functions
> that manipulate the iscsi_task refcount. The only reason for this is to
> handle races where we are handing SCSI-ml eh callbacks and the cmd is

handing -> handling

> completing at the same time the normal completion path is running, and we
> can't return from the EH callback until the driver has stopped accessing
> the cmd. By holding the back_lock while also accessing the task->state
> makes it simple to check that a cmd is completing and also get/put a
> refcount at the same time.

This last sentence doesn't completely parse. Maybe leave off the work "By"?

> 
> The problem is that we don't want to take the back_lock from the xmit path
> for normal IO since it causes contention with the completion path if the
> user has chosen to try and split those paths on different CPUs (in this
> case abusing the CPUs and igoring caching improves perf for some uses).
> 
> This patch begins to remove the back_lock requirement for
> iscsi_get/put_task by removing the requirement for the get path. Instead
> of always holding the back_lock we detect if something has done the last
> put and is about to call iscsi_free_task. The next patch will then allow
> iscsi code to do the last put on a task and only grab the back_lock if
> the refcount is now zero and it's going to call iscsi_free_task.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/be2iscsi/be_main.c | 19 ++++++-
>   drivers/scsi/libiscsi.c         | 95 +++++++++++++++++++++++----------
>   drivers/scsi/libiscsi_tcp.c     |  5 +-
>   include/scsi/libiscsi.h         |  2 +-
>   4 files changed, 88 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index ab55681145f8..26e5446ac237 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -231,6 +231,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
>   	cls_session = starget_to_session(scsi_target(sc->device));
>   	session = cls_session->dd_data;
>   
> +completion_check:
>   	/* check if we raced, task just got cleaned up under us */
>   	spin_lock_bh(&session->back_lock);
>   	if (!abrt_task || !abrt_task->sc) {
> @@ -238,7 +239,13 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
>   		return SUCCESS;
>   	}
>   	/* get a task ref till FW processes the req for the ICD used */
> -	__iscsi_get_task(abrt_task);
> +	if (!iscsi_get_task(abrt_task)) {
> +		spin_unlock(&session->back_lock);
> +		/* We are just about to call iscsi_free_task so wait for it. */
> +		udelay(5);
> +		goto completion_check;
> +	}
> +
>   	abrt_io_task = abrt_task->dd_data;
>   	conn = abrt_task->conn;
>   	beiscsi_conn = conn->dd_data;
> @@ -323,7 +330,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
>   		}
>   
>   		/* get a task ref till FW processes the req for the ICD used */
> -		__iscsi_get_task(task);
> +		if (!iscsi_get_task(task)) {
> +			/*
> +			 * The task has completed in the driver and is
> +			 * completing in libiscsi. Just ignore it here. When we
> +			 * call iscsi_eh_device_reset, it will wait for us.
> +			 */
> +			continue;
> +		}
> +
>   		io_task = task->dd_data;
>   		/* mark WRB invalid which have been not processed by FW yet */
>   		if (is_chip_be2_be3r(phba)) {
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 5c74ab92725f..a2d0daf5bd60 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -83,6 +83,8 @@ MODULE_PARM_DESC(debug_libiscsi_eh,
>   				"%s " dbg_fmt, __func__, ##arg);	\
>   	} while (0);
>   
> +#define ISCSI_CMD_COMPL_WAIT 5
> +
>   inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn)
>   {
>   	struct Scsi_Host *shost = conn->session->host;
> @@ -482,11 +484,11 @@ static void iscsi_free_task(struct iscsi_task *task)
>   	}
>   }
>   
> -void __iscsi_get_task(struct iscsi_task *task)
> +bool iscsi_get_task(struct iscsi_task *task)
>   {
> -	refcount_inc(&task->refcount);
> +	return refcount_inc_not_zero(&task->refcount);
>   }
> -EXPORT_SYMBOL_GPL(__iscsi_get_task);
> +EXPORT_SYMBOL_GPL(iscsi_get_task);
>   
>   void __iscsi_put_task(struct iscsi_task *task)
>   {
> @@ -600,20 +602,17 @@ static bool cleanup_queued_task(struct iscsi_task *task)
>   }
>   
>   /*
> - * session frwd lock must be held and if not called for a task that is still
> - * pending or from the xmit thread, then xmit thread must be suspended
> + * session back and frwd lock must be held and if not called for a task that
> + * is still pending or from the xmit thread, then xmit thread must be suspended
>    */
> -static void fail_scsi_task(struct iscsi_task *task, int err)
> +static void __fail_scsi_task(struct iscsi_task *task, int err)
>   {
>   	struct iscsi_conn *conn = task->conn;
>   	struct scsi_cmnd *sc;
>   	int state;
>   
> -	spin_lock_bh(&conn->session->back_lock);
> -	if (cleanup_queued_task(task)) {
> -		spin_unlock_bh(&conn->session->back_lock);
> +	if (cleanup_queued_task(task))
>   		return;
> -	}
>   
>   	if (task->state == ISCSI_TASK_PENDING) {
>   		/*
> @@ -632,7 +631,15 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
>   	sc->result = err << 16;
>   	scsi_set_resid(sc, scsi_bufflen(sc));
>   	iscsi_complete_task(task, state);
> -	spin_unlock_bh(&conn->session->back_lock);
> +}
> +
> +static void fail_scsi_task(struct iscsi_task *task, int err)
> +{
> +	struct iscsi_session *session = task->conn->session;
> +
> +	spin_lock_bh(&session->back_lock);
> +	__fail_scsi_task(task, err);
> +	spin_unlock_bh(&session->back_lock);
>   }
>   
>   static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
> @@ -1449,8 +1456,17 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	spin_lock_bh(&conn->session->back_lock);
>   
>   	if (!conn->task) {
> -		/* Take a ref so we can access it after xmit_task() */
> -		__iscsi_get_task(task);
> +		/*
> +		 * Take a ref so we can access it after xmit_task().
> +		 *
> +		 * This should never fail because the failure paths will have
> +		 * stopped the xmit thread. WARN on move on.
> +		 */
> +		if (!iscsi_get_task(task)) {
> +			spin_unlock_bh(&conn->session->back_lock);
> +			WARN_ON_ONCE(1);
> +			return 0;
> +		}
>   	} else {
>   		/* Already have a ref from when we failed to send it last call */
>   		conn->task = NULL;
> @@ -1492,7 +1508,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   		 * get an extra ref that is released next time we access it
>   		 * as conn->task above.
>   		 */
> -		__iscsi_get_task(task);
> +		iscsi_get_task(task);
>   		conn->task = task;
>   	}
>   
> @@ -1907,6 +1923,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
>   	struct iscsi_task *task;
>   	int i;
>   
> +restart_cmd_loop:
>   	spin_lock_bh(&session->back_lock);
>   	for (i = 0; i < session->cmds_max; i++) {
>   		task = session->cmds[i];
> @@ -1915,22 +1932,25 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
>   
>   		if (lun != -1 && lun != task->sc->device->lun)
>   			continue;
> -
> -		__iscsi_get_task(task);
> -		spin_unlock_bh(&session->back_lock);
> +		/*
> +		 * The cmd is completing but if this is called from an eh
> +		 * callout path then when we return scsi-ml owns the cmd. Wait
> +		 * for the completion path to finish freeing the cmd.
> +		 */
> +		if (!iscsi_get_task(task)) {
> +			spin_unlock_bh(&session->back_lock);
> +			spin_unlock_bh(&session->frwd_lock);
> +			udelay(ISCSI_CMD_COMPL_WAIT);
> +			spin_lock_bh(&session->frwd_lock);
> +			goto restart_cmd_loop;
> +		}
>   
>   		ISCSI_DBG_SESSION(session,
>   				  "failing sc %p itt 0x%x state %d\n",
>   				  task->sc, task->itt, task->state);
> -		fail_scsi_task(task, error);
> -
> -		spin_unlock_bh(&session->frwd_lock);
> -		iscsi_put_task(task);
> -		spin_lock_bh(&session->frwd_lock);
> -
> -		spin_lock_bh(&session->back_lock);
> +		__fail_scsi_task(task, error);
> +		__iscsi_put_task(task);
>   	}
> -
>   	spin_unlock_bh(&session->back_lock);
>   }
>   
> @@ -2035,7 +2055,16 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
>   		spin_unlock(&session->back_lock);
>   		goto done;
>   	}
> -	__iscsi_get_task(task);
> +	if (!iscsi_get_task(task)) {
> +		/*
> +		 * Racing with the completion path right now, so give it more
> +		 * time so that path can complete it like normal.
> +		 */
> +		rc = BLK_EH_RESET_TIMER;
> +		task = NULL;
> +		spin_unlock(&session->back_lock);
> +		goto done;
> +	}
>   	spin_unlock(&session->back_lock);
>   
>   	if (session->state != ISCSI_STATE_LOGGED_IN) {
> @@ -2282,6 +2311,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
>   
>   	ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
>   
> +completion_check:
>   	mutex_lock(&session->eh_mutex);
>   	spin_lock_bh(&session->frwd_lock);
>   	/*
> @@ -2321,13 +2351,20 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
>   		return SUCCESS;
>   	}
>   
> +	if (!iscsi_get_task(task)) {
> +		spin_unlock(&session->back_lock);
> +		spin_unlock_bh(&session->frwd_lock);
> +		mutex_unlock(&session->eh_mutex);
> +		/* We are just about to call iscsi_free_task so wait for it. */
> +		udelay(ISCSI_CMD_COMPL_WAIT);
> +		goto completion_check;
> +	}
> +
> +	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
>   	conn = session->leadconn;
>   	iscsi_get_conn(conn->cls_conn);
>   	conn->eh_abort_cnt++;
>   	age = session->age;
> -
> -	ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
> -	__iscsi_get_task(task);
>   	spin_unlock(&session->back_lock);
>   
>   	if (task->state == ISCSI_TASK_PENDING) {
> diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
> index 883005757ddb..defe08142b75 100644
> --- a/drivers/scsi/libiscsi_tcp.c
> +++ b/drivers/scsi/libiscsi_tcp.c
> @@ -558,7 +558,10 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
>   		return 0;
>   	}
>   	task->last_xfer = jiffies;
> -	__iscsi_get_task(task);
> +	if (!iscsi_get_task(task)) {
> +		/* Let the path that got the early rsp complete it */
> +		return 0;
> +	}
>   
>   	tcp_conn = conn->dd_data;
>   	rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr;
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index 522fd16f1dbb..9032a214104c 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -470,7 +470,7 @@ extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
>   extern void iscsi_requeue_task(struct iscsi_task *task);
>   extern void iscsi_put_task(struct iscsi_task *task);
>   extern void __iscsi_put_task(struct iscsi_task *task);
> -extern void __iscsi_get_task(struct iscsi_task *task);
> +extern bool iscsi_get_task(struct iscsi_task *task);
>   extern void iscsi_complete_scsi_task(struct iscsi_task *task,
>   				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
>   

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path
  2022-03-08  0:27 ` [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path Mike Christie
@ 2022-03-18 17:37   ` Lee Duncan
  0 siblings, 0 replies; 30+ messages in thread
From: Lee Duncan @ 2022-03-18 17:37 UTC (permalink / raw)
  To: Mike Christie, cleech, martin.petersen, linux-scsi, jejb

On 3/7/22 16:27, Mike Christie wrote:
> We need the back lock when freeing a task, so we hold it when calling
> __iscsi_put_task from the completion path to make it easier and to avoid
> having to retake it in that path. For iscsi_put_task we just grabbed it
> while also doing the decrement on the refcount but it's only really needed
> if the refcount is zero and we free the task. This modifies iscsi_put_task
> to just take the lock when needed then has the xmit path use it. Normally
> we will then not take the back lock from the xmit path. It will only be
> rare cases where the network is so fast that we get a response right after
> we send the header/data.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/libiscsi.c | 30 ++++++++++++++----------------
>   1 file changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index a2d0daf5bd60..cde389225059 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -490,6 +490,12 @@ bool iscsi_get_task(struct iscsi_task *task)
>   }
>   EXPORT_SYMBOL_GPL(iscsi_get_task);
>   
> +/**
> + * __iscsi_put_task - drop the refcount on a task
> + * @task: iscsi_task to drop the refcount on
> + *
> + * The back_lock must be held when calling in case it frees the task.
> + */
>   void __iscsi_put_task(struct iscsi_task *task)
>   {
>   	if (refcount_dec_and_test(&task->refcount))
> @@ -501,10 +507,11 @@ void iscsi_put_task(struct iscsi_task *task)
>   {
>   	struct iscsi_session *session = task->conn->session;
>   
> -	/* regular RX path uses back_lock */
> -	spin_lock_bh(&session->back_lock);
> -	__iscsi_put_task(task);
> -	spin_unlock_bh(&session->back_lock);
> +	if (refcount_dec_and_test(&task->refcount)) {
> +		spin_lock_bh(&session->back_lock);
> +		iscsi_free_task(task);
> +		spin_unlock_bh(&session->back_lock);
> +	}
>   }
>   EXPORT_SYMBOL_GPL(iscsi_put_task);
>   
> @@ -1453,8 +1460,6 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   {
>   	int rc;
>   
> -	spin_lock_bh(&conn->session->back_lock);
> -
>   	if (!conn->task) {
>   		/*
>   		 * Take a ref so we can access it after xmit_task().
> @@ -1463,7 +1468,6 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   		 * stopped the xmit thread. WARN on move on.
>   		 */
>   		if (!iscsi_get_task(task)) {
> -			spin_unlock_bh(&conn->session->back_lock);
>   			WARN_ON_ONCE(1);
>   			return 0;
>   		}
> @@ -1477,7 +1481,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	 * case a bad target sends a cmd rsp before we have handled the task.
>   	 */
>   	if (was_requeue)
> -		__iscsi_put_task(task);
> +		iscsi_put_task(task);
>   
>   	/*
>   	 * Do this after dropping the extra ref because if this was a requeue
> @@ -1489,10 +1493,8 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   		 * task and get woken up again.
>   		 */
>   		conn->task = task;
> -		spin_unlock_bh(&conn->session->back_lock);
>   		return -ENODATA;
>   	}
> -	spin_unlock_bh(&conn->session->back_lock);
>   
>   	spin_unlock_bh(&conn->session->frwd_lock);
>   	rc = conn->session->tt->xmit_task(task);
> @@ -1500,10 +1502,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   	if (!rc) {
>   		/* done with this task */
>   		task->last_xfer = jiffies;
> -	}
> -	/* regular RX path uses back_lock */
> -	spin_lock(&conn->session->back_lock);
> -	if (rc) {
> +	} else {
>   		/*
>   		 * get an extra ref that is released next time we access it
>   		 * as conn->task above.
> @@ -1512,8 +1511,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
>   		conn->task = task;
>   	}
>   
> -	__iscsi_put_task(task);
> -	spin_unlock(&conn->session->back_lock);
> +	iscsi_put_task(task);
>   	return rc;
>   }
>   

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 05/12] scsi: iscsi: Run recv path from workqueue
  2022-03-18 16:45   ` Lee Duncan
@ 2022-03-18 22:11     ` Mike Christie
  0 siblings, 0 replies; 30+ messages in thread
From: Mike Christie @ 2022-03-18 22:11 UTC (permalink / raw)
  To: Lee Duncan, cleech, martin.petersen, linux-scsi, jejb

On 3/18/22 11:45 AM, Lee Duncan wrote:
> On 3/7/22 16:27, Mike Christie wrote:
>> We don't always want to run the recv path from the network softirq
>> because when we have to have multiple sessions sharing the same CPUs some
>> sessions can eat up the napi softirq budget and affect other sessions or
>> users. This patch allows us to queue the recv handling to the iscsi
>> workqueue so we can have the scheduler/wq code try to balance the work and
>> CPU use across all sessions's  worker threads.
>>
>> Signed-off-by: Mike Christie <michael.christie@oracle.com>
>> ---
>>   drivers/scsi/iscsi_tcp.c | 62 +++++++++++++++++++++++++++++++---------
>>   drivers/scsi/iscsi_tcp.h |  2 ++
>>   2 files changed, 51 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
>> index f274a86d2ec0..261599938fc9 100644
>> --- a/drivers/scsi/iscsi_tcp.c
>> +++ b/drivers/scsi/iscsi_tcp.c
>> @@ -52,6 +52,10 @@ static struct iscsi_transport iscsi_sw_tcp_transport;
>>   static unsigned int iscsi_max_lun = ~0;
>>   module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
>>   +static bool iscsi_use_recv_wq;
>> +module_param_named(use_recv_wq, iscsi_use_recv_wq, bool, 0644);
>> +MODULE_PARM_DESC(use_recv_wq, "Set to true to read iSCSI data/headers from the iscsi_q workqueue. The default is false which will perform reads from the network softirq context.");
> 
> I'm just curious why you chose to make this a module parameter, leaving the current default.

If you only have a couple sessions, running from the softirq can
be better can give you better perf sometimes. Users might have
pinned things where the xmit and recv paths are on different CPUs.
If we switch the default then it could cause a regression for those
users.

The modparam use is because users typically know how heavily they
will use iscsi beforehand. Like they know if they are only going
to be using a couple or 10 or 20 sessions for one or 2 apps vs 50+
for heavier storage use.

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2022-03-18 22:11 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08  0:27 [[PATCH 00/12] misc iscsi patches Mike Christie
2022-03-08  0:27 ` [PATCH 01/12] scsi: iscsi: Merge suspend fields Mike Christie
2022-03-08 18:47   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 02/12] scsi: iscsi: Rename iscsi_conn_queue_work Mike Christie
2022-03-08 18:49   ` Lee Duncan
2022-03-09  0:55   ` Wu Bo
2022-03-08  0:27 ` [PATCH 03/12] scsi: iscsi: Add recv workqueue helpers Mike Christie
2022-03-10 22:50   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 04/12] scsi: iscsi: Allow a recv and xmit work to run Mike Christie
2022-03-08 19:00   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 05/12] scsi: iscsi: Run recv path from workqueue Mike Christie
2022-03-18 16:45   ` Lee Duncan
2022-03-18 22:11     ` Mike Christie
2022-03-08  0:27 ` [PATCH 06/12] scsi: iscsi_tcp: Use sendpage for the PDU header Mike Christie
2022-03-12 19:42   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 07/12] scsi: iscsi_tcp: Drop target_alloc use Mike Christie
2022-03-09  1:31   ` Wu Bo
2022-03-12 19:43   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 08/12] scsi: iscsi: remove unneeded task state check Mike Christie
2022-03-09  1:33   ` Wu Bo
2022-03-14 17:13   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 09/12] scsi: iscsi: Remove iscsi_get_task back_lock requirement Mike Christie
2022-03-14 17:44   ` Lee Duncan
2022-03-18 17:31   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 10/12] scsi: iscsi: Try to avoid taking back_lock in xmit path Mike Christie
2022-03-18 17:37   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 11/12] scsi: libiscsi: improve conn_send_pdu API Mike Christie
2022-03-18 16:49   ` Lee Duncan
2022-03-08  0:27 ` [PATCH 12/12] scsi: iscsi: Fix race between recovery and task xmit Mike Christie
2022-03-14 17:46   ` Lee Duncan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.