misc iscsi patches
Subsystems (4)
Mike Christie
maintainerv3 cover misc iscsi patches
The following patches were made over Martin's 5.18 branches which contain Bart's SCp.ptr changes and some other iscsi patches. They also apply over Linus's tree but that kernel does not boot for me due to unrelated issues.
They are mix of minor fixes and perf improvements and cleanups.
V3:
- Added fixes for iscsid restart for issues found by Marvell.
- There was a mixup in v2 where an older version of a patch was sent that used msleep instead of udelay (v1 has udelay but v2 has msleep). This posting has the correct udelay version so checkpatch is happy and msleep was too long
V2:
- Fix up git commit messages.
- Rename modparam that controls if we create sessions using the network softirq or iscsi_q.
- Drop zero copy patch but leave the part that set the sendpage version of MSG_MORE. It turns out we were never using zero copy for the header and it was the MSG_SENDPAGE_NOTLAST that was helping.
Mike Christie
maintainerPATCH v3 1/15 scsi: iscsi: Move iscsi_ep_disconnect
This patch moves iscsi_ep_disconnect so it can be called earlier in the next patch.
--- drivers/scsi/scsi_transport_iscsi.c | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +19 -19
@@ -2217,6 +2217,25 @@ static void iscsi_stop_conn(struct iscsi_cls_conn *conn, int flag)ISCSI_DBG_TRANS_CONN (conn,"Stopping conn done.\n" ); } +static void iscsi_ep_disconnect (struct iscsi_cls_conn *conn,bool is_active) +{ +struct iscsi_cls_session *session =iscsi_conn_to_session (conn); +struct iscsi_endpoint *ep; + +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); + conn->state =ISCSI_CONN_FAILED ; + +if (!conn->ep || !session->transport->ep_disconnect) +return ; + + ep = conn->ep; + conn->ep =NULL ; + + session->transport->unbind_conn (conn, is_active); + session->transport->ep_disconnect (ep); +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); +} +static int iscsi_if_stop_conn (struct iscsi_transport *transport,struct iscsi_uevent *ev) {
@@ -2257,25 +2276,6 @@ static int iscsi_if_stop_conn(struct iscsi_transport *transport,return 0 ; } -static void iscsi_ep_disconnect (struct iscsi_cls_conn *conn,bool is_active) -{ -struct iscsi_cls_session *session =iscsi_conn_to_session (conn); -struct iscsi_endpoint *ep; - -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); - conn->state =ISCSI_CONN_FAILED ; - -if (!conn->ep || !session->transport->ep_disconnect) -return ; - - ep = conn->ep; - conn->ep =NULL ; - - session->transport->unbind_conn (conn, is_active); - session->transport->ep_disconnect (ep); -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); -} -static void iscsi_cleanup_conn_work_fn (struct work_struct *work) { struct iscsi_cls_conn *conn = container_of(work, struct iscsi_cls_conn,
Signature · 1 line
2.25.1
Re: [PATCH V3 01/15] scsi: iscsi: Move iscsi_ep_disconnect
Quoted 54 lines · Mike Christie
This patch moves
iscsi_ep_disconnectso it can be called earlier in the next patch.Signed-off-by Mike Christie <[email protected]>--- drivers/scsi/scsi_transport_iscsi.c | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-)drivers/scsi/scsi_transport_iscsi.c +19
-12@@ -2217,6 +2217,25 @@ static void iscsi_stop_conn(struct iscsi_cls_conn *conn, int flag)ISCSI_DBG_TRANS_CONN (conn,"Stopping conn done.\n" ); } +static void iscsi_ep_disconnect (struct iscsi_cls_conn *conn,bool is_active) +{ +struct iscsi_cls_session *session =iscsi_conn_to_session (conn); +struct iscsi_endpoint *ep; + +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); + conn->state =ISCSI_CONN_FAILED ; + +if (!conn->ep || !session->transport->ep_disconnect) +return ; + + ep = conn->ep; + conn->ep =NULL ; + + session->transport->unbind_conn (conn, is_active); + session->transport->ep_disconnect (ep); +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); +} +static int iscsi_if_stop_conn (struct iscsi_transport *transport,struct iscsi_uevent *ev) {@@ -2257,25 +2276,6 @@ static int iscsi_if_stop_conn(struct iscsi_transport *transport,return 0 ; } -static void iscsi_ep_disconnect (struct iscsi_cls_conn *conn,bool is_active) -{ -struct iscsi_cls_session *session =iscsi_conn_to_session (conn); -struct iscsi_endpoint *ep; - -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); - conn->state =ISCSI_CONN_FAILED ; - -if (!conn->ep || !session->transport->ep_disconnect) -return ; - - ep = conn->ep;
drivers/scsi/scsi_transport_iscsi.c static int iscsi_if_stop_conn(struct iscsi_transport *transport, · line 2281
Quoted 10 lines
drivers/scsi/scsi_transport_iscsi.c +0
-7- conn->ep =NULL ; - - session->transport->unbind_conn (conn, is_active); - session->transport->ep_disconnect (ep); -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); -} -static void iscsi_cleanup_conn_work_fn (struct work_struct *work) { struct iscsi_cls_conn *conn = container_of(work, struct iscsi_cls_conn,
Re: [PATCH V3 01/15] scsi: iscsi: Move iscsi_ep_disconnect
In reply to Mike ChristieQuoted 63 lines · Mike Christie
This patch moves
iscsi_ep_disconnectso it can be called earlier in the next patch.Signed-off-by Mike Christie <[email protected]>--- drivers/scsi/scsi_transport_iscsi.c | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-)drivers/scsi/scsi_transport_iscsi.c +18
-19@@ -2217,6 +2217,25 @@ static void iscsi_stop_conn(struct iscsi_cls_conn *conn, int flag) ISCSI_DBG_TRANS_CONN(conn, "Stopping conn done.\n"); } +static void iscsi_ep_disconnect (struct iscsi_cls_conn *conn,bool +is_active) { +struct iscsi_cls_session *session =iscsi_conn_to_session (conn); +struct iscsi_endpoint *ep; + +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); + conn->state =ISCSI_CONN_FAILED ; + +if (!conn->ep || !session->transport->ep_disconnect) +return ; + + ep = conn->ep; + conn->ep =NULL ; + + session->transport->unbind_conn (conn, is_active); + session->transport->ep_disconnect (ep); +ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); } +static int iscsi_if_stop_conn (struct iscsi_transport *transport,struct iscsi_uevent *ev) {@@ -2257,25 +2276,6 @@ static int iscsi_if_stop_conn(struct iscsi_transport *transport, return 0; } -static void iscsi_ep_disconnect(struct iscsi_cls_conn *conn, bool is_active) -{ -struct iscsi_cls_session *session =iscsi_conn_to_session (conn); -struct iscsi_endpoint *ep; - -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep.\n" ); - conn->state =ISCSI_CONN_FAILED ; - -if (!conn->ep || !session->transport->ep_disconnect) -return ; - - ep = conn->ep; - conn->ep =NULL ; - - session->transport->unbind_conn (conn, is_active); - session->transport->ep_disconnect (ep); -ISCSI_DBG_TRANS_CONN (conn,"disconnect ep done.\n" ); -} -static void iscsi_cleanup_conn_work_fn (struct work_struct *work) { struct iscsi_cls_conn *conn = container_of(work, struct iscsi_cls_conn, --
Quoted 1 line
2.25.1
Mike Christie
maintainerPATCH v3 2/15 scsi: iscsi: Fix offload conn cleanup when iscsid restarts
In reply to Mike ChristieWhen userspace restarts during boot or upgrades it won't know about the offload driver's endpoint and connection mappings. iscsid will start by cleaning up the old session by doing a stop_conn call. Later if we are able to create a new connection, we cleanup the old endpoint during the binding stage. The problem is that if we do stop_conn before doing the ep_disconnect call offload drivers can still be executing IO. We then might free tasks from the under the card/driver.
This moves the ep_disconnect call to before we do the stop_conn call for this case. It will then work and look like a normal recovery/cleanup procedure from the driver's point of view.
--- drivers/scsi/scsi_transport_iscsi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +9 -10
@@ -2260,6 +2260,15 @@ static int iscsi_if_stop_conn(struct iscsi_transport *transport,* Figure out if it was the kernel or userspace initiating this. */ if (!test_and_set_bit (ISCSI_CLS_CONN_BIT_CLEANUP , &conn->flags)) { +if (conn->ep) { +/* +* For offload, when iscsid is restarted it +* won't know about existing endpoints. We +* clean it up here for userspace. +*/ +iscsi_ep_disconnect (conn, true); + } +iscsi_stop_conn (conn, flag); }else { ISCSI_DBG_TRANS_CONN(conn,
@@ -3704,16 +3713,6 @@ static int iscsi_if_transport_conn(struct iscsi_transport *transport,switch (nlh->nlmsg_type) {case ISCSI_UEVENT_BIND_CONN : -if (conn->ep) { -/* -* For offload boot support where iscsid is restarted -* during the pivot root stage, the ep will be intact -* here when the new iscsid instance starts up and -* reconnects. -*/ -iscsi_ep_disconnect (conn, true); - } - session =iscsi_session_lookup (ev->u.b_conn.sid);if (!session) { err = -EINVAL ;
Signature · 1 line
2.25.1
Re: [PATCH V3 02/15] scsi: iscsi: Fix offload conn cleanup when iscsid restarts
Quoted 44 lines · Mike Christie
When userspace restarts during boot or upgrades it won't know about the offload driver's endpoint and connection mappings. iscsid will start by cleaning up the old session by doing a
stop_conncall. Later if we are able to create a new connection, we cleanup the old endpoint during the binding stage. The problem is that if we dostop_connbefore doing theep_disconnectcall offload drivers can still be executing IO. We then might free tasks from the under the card/driver.This moves the
ep_disconnectcall to before we do thestop_conncall for this case. It will then work and look like a normal recovery/cleanup procedure from the driver's point of view.Signed-off-by Mike Christie <[email protected]>--- drivers/scsi/scsi_transport_iscsi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/scsi/scsi_transport_iscsi.c +9
-3@@ -2260,6 +2260,15 @@ static int iscsi_if_stop_conn(struct iscsi_transport *transport,* Figure out if it was the kernel or userspace initiating this. */ if (!test_and_set_bit (ISCSI_CLS_CONN_BIT_CLEANUP , &conn->flags)) { +if (conn->ep) { +/* +* For offload, when iscsid is restarted it +* won't know about existing endpoints. We +* clean it up here for userspace. +*/ +iscsi_ep_disconnect (conn, true); + } +iscsi_stop_conn (conn, flag); }else { ISCSI_DBG_TRANS_CONN(conn,@@ -3704,16 +3713,6 @@ static int iscsi_if_transport_conn(struct iscsi_transport *transport,switch (nlh->nlmsg_type) {case ISCSI_UEVENT_BIND_CONN : -if (conn->ep) { -/* -* For offload boot support where iscsid is restarted
drivers/scsi/scsi_transport_iscsi.c static int iscsi_if_transport_conn(struct iscsi_transport *transport, · line 3718
Quoted 10 lines
drivers/scsi/scsi_transport_iscsi.c +0
-7-* during the pivot root stage, the ep will be intact -* here when the new iscsid instance starts up and -* reconnects. -*/ -iscsi_ep_disconnect (conn, true); - } - session =iscsi_session_lookup (ev->u.b_conn.sid);if (!session) { err = -EINVAL ;
Mike Christie
maintainerPATCH v3 3/15 scsi: iscsi: Merge suspend fields
In reply to Mike ChristieMove the tx and rx suspend fields into one flags field.
--- 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(-)
drivers/scsi/bnx2i/bnx2i_hwi.c +1 -1
@@ -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 "
drivers/scsi/bnx2i/bnx2i_iscsi.c +1 -1
@@ -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
drivers/scsi/cxgbi/libcxgbi.c +3 -3
@@ -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 ; }
drivers/scsi/libiscsi.c +10 -10
@@ -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); }
@@ -3330,8 +3330,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);
drivers/scsi/libiscsi_tcp.c +1 -1
@@ -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 ;
include/scsi/libiscsi.h +5 -4
@@ -53,8 +53,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
@@ -211,8 +213,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*/
Signature · 1 line
2.25.1
Re: [PATCH V3 03/15] scsi: iscsi: Merge suspend fields
Quoted 187 lines
Move the tx and rx suspend fields into one flags field.
Reviewed-by Lee Duncan <[email protected]>Signed-off-by Mike Christie <[email protected]>--- 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(-)drivers/scsi/bnx2i/bnx2i_hwi.c index renamed from drivers/scsi/bnx2i/bnx2i_hwi.c +0
-0
5521469ce678..e16327a4b4c9100644drivers/scsi/bnx2i/bnx2i_hwi.c +1
-1@@ -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 &&drivers/scsi/bnx2i/bnx2i_hwi.c +0
-0nopin->itt == (u16) RESERVED_ITT) { printk(KERN_ALERT "bnx2i: Unsolicited "drivers/scsi/bnx2i/bnx2i_iscsi.c +1
-1@@ -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.cb/drivers/scsi/cxgbi/libcxgbi.cindex8c7d4dda4cf2..4365d52c6430100644drivers/scsi/cxgbi/libcxgbi.c +4
-3@@ -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 ; }drivers/scsi/libiscsi.c index renamed from drivers/scsi/libiscsi.c +0
-0
d09926e6c8a8..5e7bd5a3b430100644drivers/scsi/libiscsi.c +3
-3@@ -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, structiscsi_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 drivers/scsi/libiscsi.c +2
-2* 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 ;drivers/scsi/libiscsi.c +5
-5goto 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); }@@ -3330,8 +3330,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);drivers/scsi/libiscsi_tcp.c index renamed from drivers/scsi/libiscsi_tcp.c +0
-0
2e9ffe3d1a55..883005757ddb100644drivers/scsi/libiscsi_tcp.c +1
-1@@ -927,7 +927,7 @@ int iscsi_tcp_recv_skb(struct iscsi_conn *conn, structsk_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 ;drivers/scsi/libiscsi_tcp.c +0
-0return 0 ;include/scsi/libiscsi.h index renamed from include/scsi/libiscsi.h +0
-0
e76c94697c1b..84086c240228100644include/scsi/libiscsi.h +5
-5@@ -53,8 +53,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@@ -211,8 +213,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*/ --
Quoted 1 line
2.25.1
Mike Christie
maintainerPATCH v3 4/15 scsi: iscsi: Fix nop handling during conn recovery
In reply to Mike ChristieIf a offload driver doesn't use the xmit workqueue, then when we are doing ep_disconnect libiscsi can still inject PDUs to the driver. This adds a check for if the connection is bound before trying to inject PDUs.
--- drivers/scsi/libiscsi.c | 7 ++++++- include/scsi/libiscsi.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +6 -1
@@ -678,7 +678,8 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,struct iscsi_task *task;itt_t itt; -if (session->state ==ISCSI_STATE_TERMINATE ) +if (session->state ==ISCSI_STATE_TERMINATE || + !test_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags))return NULL ;if (opcode ==ISCSI_OP_LOGIN || opcode ==ISCSI_OP_TEXT ) {
@@ -2214,6 +2215,8 @@ void iscsi_conn_unbind(struct iscsi_cls_conn *cls_conn, bool is_active)iscsi_suspend_tx (conn);spin_lock_bh (&session->frwd_lock); +clear_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags); +if (!is_active) {/* * if logout timed out before userspace could even send a PDU
@@ -3318,6 +3321,8 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,spin_lock_bh (&session->frwd_lock);if (is_leading) session->leadconn = conn; + +set_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags);spin_unlock_bh (&session->frwd_lock);/*
include/scsi/libiscsi.h +1 -1
@@ -56,7 +56,7 @@ enum {/* Connection flags */ #define ISCSI_CONN_FLAG_SUSPEND_TX BIT(0)#define ISCSI_CONN_FLAG_SUSPEND_RX BIT(1) - +#define ISCSI_CONN_FLAG_BOUND BIT(2)#define ISCSI_ITT_MASK 0x1fff#define ISCSI_TOTAL_CMDS_MAX 4096
Signature · 1 line
2.25.1
Re: [PATCH V3 04/15] scsi: iscsi: Fix nop handling during conn recovery
Quoted 47 lines · Mike Christie
If a offload driver doesn't use the xmit workqueue, then when we are doing
ep_disconnectlibiscsi can still inject PDUs to the driver. This adds a check for if the connection is bound before trying to inject PDUs.Signed-off-by Mike Christie <[email protected]>--- drivers/scsi/libiscsi.c | 7 ++++++- include/scsi/libiscsi.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)drivers/scsi/libiscsi.c +6
-1@@ -678,7 +678,8 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,struct iscsi_task *task;itt_t itt; -if (session->state ==ISCSI_STATE_TERMINATE ) +if (session->state ==ISCSI_STATE_TERMINATE || + !test_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags))return NULL ;if (opcode ==ISCSI_OP_LOGIN || opcode ==ISCSI_OP_TEXT ) {@@ -2214,6 +2215,8 @@ void iscsi_conn_unbind(struct iscsi_cls_conn *cls_conn, bool is_active)iscsi_suspend_tx (conn);spin_lock_bh (&session->frwd_lock); +clear_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags); +if (!is_active) {/* * if logout timed out before userspace could even send a PDU @@ -3318,6 +3321,8 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,spin_lock_bh (&session->frwd_lock);if (is_leading) session->leadconn = conn; + +set_bit (ISCSI_CONN_FLAG_BOUND , &conn->flags);spin_unlock_bh (&session->frwd_lock);/* include/scsi/libiscsi.h +0
-0
include/scsi/libiscsi.h enum { · line 62
Quoted 8 lines
include/scsi/libiscsi.h +1
-1@@ -56,7 +56,7 @@ enum {/* Connection flags */ #define ISCSI_CONN_FLAG_SUSPEND_TX BIT(0)#define ISCSI_CONN_FLAG_SUSPEND_RX BIT(1) - +#define ISCSI_CONN_FLAG_BOUND BIT(2)#define ISCSI_ITT_MASK 0x1fff#define ISCSI_TOTAL_CMDS_MAX 4096
Mike Christie
maintainerPATCH v3 5/15 scsi: iscsi: Rename iscsi_conn_queue_work
In reply to Mike ChristieRename iscsi_conn_queue_work to iscsi_conn_queue_xmit to reflect it handles queueing of xmits only.
--- 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(-)
drivers/scsi/cxgbi/libcxgbi.c +1 -1
@@ -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);
drivers/scsi/iscsi_tcp.c +1 -1
@@ -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)
drivers/scsi/libiscsi.c +6 -6
@@ -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)
@@ -765,7 +765,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;
@@ -1513,7 +1513,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);
@@ -1782,7 +1782,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++;
@@ -1963,7 +1963,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); }/*
include/scsi/libiscsi.h +1 -1
@@ -453,7 +453,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, \
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 6/15 scsi: iscsi: Add recv workqueue helpers
In reply to Mike ChristieAdd helpers to allow the drivers to run their recv paths from libiscsi's workqueue.
--- drivers/scsi/libiscsi.c | 29 +++++++++++++++++++++++++++-- include/scsi/libiscsi.h | 4 ++++ 2 files changed, 31 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +27 -2
@@ -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) {
@@ -1943,7 +1953,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
@@ -1956,7 +1966,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);
@@ -1966,6 +1976,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
include/scsi/libiscsi.h +4 -0
@@ -213,6 +213,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 */
@@ -452,8 +454,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, \
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 7/15 scsi: iscsi: Allow a recv and xmit work to run
In reply to Mike ChristieAllow 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.
--- drivers/scsi/libiscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +2 -2
@@ -2827,8 +2827,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; }
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 8/15 scsi: iscsi: Run recv path from workqueue
In reply to Mike ChristieWe 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.
--- drivers/scsi/iscsi_tcp.c | 62 +++++++++++++++++++++++++++++++--------- drivers/scsi/iscsi_tcp.h | 2 ++ 2 files changed, 51 insertions(+), 13 deletions(-)
drivers/scsi/iscsi_tcp.c +49 -13
@@ -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_recv_from_iscsi_q; +module_param_named (recv_from_iscsi_q, iscsi_recv_from_iscsi_q, bool,0644 ); +MODULE_PARM_DESC (recv_from_iscsi_q,"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_recv_from_iscsi_q; tfm =crypto_alloc_ahash ("crc32c" ,0 ,CRYPTO_ALG_ASYNC );if (IS_ERR (tfm))
@@ -610,6 +644,8 @@ static void iscsi_sw_tcp_release_conn(struct iscsi_conn *conn)iscsi_sw_tcp_conn_restore_callbacks (conn);sock_put (sock->sk); +iscsi_suspend_rx (conn); +spin_lock_bh (&session->frwd_lock); tcp_sw_conn->sock =NULL ;spin_unlock_bh (&session->frwd_lock);
drivers/scsi/iscsi_tcp.h +2 -0
@@ -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 */
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 9/15 scsi: iscsi_tcp: Tell net when there's more data
In reply to Mike ChristieIf we have more data set the MSG_SENDPAGE_NOTLAST in case we go down the sendpage path.
--- drivers/scsi/iscsi_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/iscsi_tcp.c +1 -1
@@ -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) {
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 10/15 scsi: iscsi_tcp: Drop target_alloc use
In reply to Mike ChristieFor 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.
--- drivers/scsi/iscsi_tcp.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/iscsi_tcp.c +0 -1
@@ -1039,7 +1039,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,
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 11/15 scsi: iscsi: remove unneeded task state check
In reply to Mike ChristieThe 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.
--- drivers/scsi/libiscsi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/libiscsi.c +8 -5
@@ -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 )
@@ -1485,7 +1488,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.
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 12/15 scsi: iscsi: Remove iscsi_get_task back_lock requirement
In reply to Mike ChristieWe 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 handling 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. Holding the back_lock while also accessing the task->state made it simple to check that a cmd is completing and also get/put a refcount at the same time, and at the time we were not as concerned about performance.
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.
--- 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(-)
drivers/scsi/be2iscsi/be_main.c +17 -2
@@ -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)) {
drivers/scsi/libiscsi.c +66 -29
179 lines not on this page · raw message
drivers/scsi/libiscsi_tcp.c +4 -1
@@ -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;
include/scsi/libiscsi.h +1 -1
@@ -482,7 +482,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);
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 13/15 scsi: iscsi: Try to avoid taking back_lock in xmit path
In reply to Mike ChristieWe 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.
--- drivers/scsi/libiscsi.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/scsi/libiscsi.c +14 -16
@@ -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);
@@ -1454,8 +1461,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().
@@ -1464,7 +1469,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 ; }
@@ -1478,7 +1482,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
@@ -1490,10 +1494,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);
@@ -1501,10 +1503,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.
@@ -1513,8 +1512,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; }
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 14/15 scsi: libiscsi: improve conn_send_pdu API
In reply to Mike ChristieThe 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.
--- drivers/scsi/libiscsi.c | 85 ++++++++++++++++++++++++++++++----------- include/scsi/libiscsi.h | 3 -- 2 files changed, 62 insertions(+), 26 deletions(-)
drivers/scsi/libiscsi.c +62 -23
@@ -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;
@@ -781,28 +787,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,
@@ -813,7 +848,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;
@@ -986,7 +1021,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 ));
@@ -1000,10 +1034,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) {
@@ -1870,11 +1912,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 );
include/scsi/libiscsi.h +0 -3
@@ -135,9 +135,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;
Signature · 1 line
2.25.1
Mike Christie
maintainerPATCH v3 15/15 scsi: iscsi: Fix race between recovery and task xmit.
In reply to Mike Christieset_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.
--- drivers/scsi/libiscsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/libiscsi.c +5 -1
@@ -2021,10 +2021,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); }
Signature · 1 line
2.25.1
Mike Christie
maintainerQuoted 14 lines · Mike Christie
The following patches were made over Martin's 5.18 branches which contain Bart's SCp.ptr changes and some other iscsi patches. They also apply over Linus's tree but that kernel does not boot for me due to unrelated issues.
They are mix of minor fixes and perf improvements and cleanups.
V3:
- Added fixes for iscsid restart for issues found by Marvell.
- There was a mixup in v2 where an older version of a patch was sent that used msleep instead of udelay (v1 has udelay but v2 has msleep). This posting has the correct udelay version so checkpatch is happy and msleep was too long
Quoted 8 lines
V2:
- Fix up git commit messages.
- Rename modparam that controls if we create sessions using the network softirq oriscsi_q.
- Drop zero copy patch but leave the part that set the sendpage version ofMSG_MORE. It turns out we were never using zero copy for the header and it was theMSG_SENDPAGE_NOTLASTthat was helping.
Martin, Ignore this version of the patches. Marvell found another bug and the fix for it conflicts with these patches and is more important because it's a regression.
I'll send the regression fix and the fixes from this set and then redo the feature patches over them and send them separately, so you can easily take the fixes in 5.18 if you want.