Skip to content

Commit

Permalink
scsi: iscsi: Fix NOP handling during conn recovery
Browse files Browse the repository at this point in the history
If 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.

Link: https://lore.kernel.org/r/20220408001314.5014-9-michael.christie@oracle.com
Tested-by: Manish Rangankar <mrangankar@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Mike Christie authored and Martin K. Petersen committed Apr 12, 2022
1 parent 5bd8562 commit 44ac971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3317,6 +3320,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);

/*
Expand Down
2 changes: 1 addition & 1 deletion include/scsi/libiscsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44ac971

Please sign in to comment.