All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: lduncan@suse.com, martin.petersen@oracle.com,
	mrangankar@marvell.com, svernekar@marvell.com,
	linux-scsi@vger.kernel.org, jejb@linux.ibm.com
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 10/13] scsi: qedi: fix session block/unblock abuse during cleanup
Date: Sat, 10 Apr 2021 13:40:13 -0500	[thread overview]
Message-ID: <20210410184016.21603-11-michael.christie@oracle.com> (raw)
In-Reply-To: <20210410184016.21603-1-michael.christie@oracle.com>

Drivers shouldn't be calling block/unblock session for cmd cleanup
because the functions can change the session state from under libiscsi.
This adds a new a driver level bit so it can block all IO the host
while it drains the card.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/qedi/qedi.h       |  1 +
 drivers/scsi/qedi/qedi_iscsi.c | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index c342defc3f52..ce199a7a16b8 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -284,6 +284,7 @@ struct qedi_ctx {
 #define QEDI_IN_RECOVERY	5
 #define QEDI_IN_OFFLINE		6
 #define QEDI_IN_SHUTDOWN	7
+#define QEDI_BLOCK_IO		8
 
 	u8 mac[ETH_ALEN];
 	u32 src_ip[4];
diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
index 821225f9beb0..536d6653ef8e 100644
--- a/drivers/scsi/qedi/qedi_iscsi.c
+++ b/drivers/scsi/qedi/qedi_iscsi.c
@@ -330,12 +330,22 @@ qedi_conn_create(struct iscsi_cls_session *cls_session, uint32_t cid)
 
 void qedi_mark_device_missing(struct iscsi_cls_session *cls_session)
 {
-	iscsi_block_session(cls_session);
+	struct iscsi_session *session = cls_session->dd_data;
+	struct qedi_conn *qedi_conn = session->leadconn->dd_data;
+
+	spin_lock_bh(&session->frwd_lock);
+	set_bit(QEDI_BLOCK_IO, &qedi_conn->qedi->flags);
+	spin_unlock_bh(&session->frwd_lock);
 }
 
 void qedi_mark_device_available(struct iscsi_cls_session *cls_session)
 {
-	iscsi_unblock_session(cls_session);
+	struct iscsi_session *session = cls_session->dd_data;
+	struct qedi_conn *qedi_conn = session->leadconn->dd_data;
+
+	spin_lock_bh(&session->frwd_lock);
+	clear_bit(QEDI_BLOCK_IO, &qedi_conn->qedi->flags);
+	spin_unlock_bh(&session->frwd_lock);
 }
 
 static int qedi_bind_conn_to_iscsi_cid(struct qedi_ctx *qedi,
@@ -789,6 +799,9 @@ static int qedi_task_xmit(struct iscsi_task *task)
 	if (test_bit(QEDI_IN_SHUTDOWN, &qedi_conn->qedi->flags))
 		return -ENODEV;
 
+	if (test_bit(QEDI_BLOCK_IO, &qedi_conn->qedi->flags))
+		return -EACCES;
+
 	cmd->state = 0;
 	cmd->task = NULL;
 	cmd->use_slowpath = false;
-- 
2.25.1


  parent reply	other threads:[~2021-04-10 18:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 18:40 [RFC PATCH 0/13]: qedi tmf fixes Mike Christie
2021-04-10 18:40 ` [PATCH 01/13] scsi: iscsi: revert Perform connection failure entirely in kernel space Mike Christie
2021-04-10 18:40 ` [PATCH 02/13] scsi: qedi: fix null ref during abort handling Mike Christie
2021-04-12 10:25   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 03/13] scsi: iscsi: add task completion helper Mike Christie
2021-04-10 18:40 ` [PATCH 04/13] scsi: qedi: fix abort vs cmd re-use race Mike Christie
2021-04-12 10:24   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 05/13] scsi: qedi: fix use after free during abort cleanup Mike Christie
2021-04-12 10:26   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 06/13] scsi: qedi: fix tmf tid allocation Mike Christie
2021-04-12 10:27   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 07/13] scsi: qedi: use GFP_NOIO for tmf allocation Mike Christie
2021-04-12 10:28   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 08/13] scsi: iscsi: fix lun/target reset cmd cleanup handling Mike Christie
2021-04-10 18:40 ` [PATCH 09/13] scsi: qedi: fix session block/unblock abuse during tmf handling Mike Christie
2021-04-12 10:31   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` Mike Christie [this message]
2021-04-12 10:33   ` [EXT] [PATCH 10/13] scsi: qedi: fix session block/unblock abuse during cleanup Manish Rangankar
2021-04-10 18:40 ` [PATCH 11/13] scsi: qedi: pass send_iscsi_tmf task to abort Mike Christie
2021-04-12 10:34   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 12/13] scsi: qedi: make sure tmf works are done before disconnect Mike Christie
2021-04-12 10:36   ` [EXT] " Manish Rangankar
2021-04-10 18:40 ` [PATCH 13/13] scsi: qedi: always wake up if cmd_cleanup_req is set Mike Christie
2021-04-12 10:35   ` [EXT] " Manish Rangankar
2021-04-12 10:22 ` [EXT] [RFC PATCH 0/13]: qedi tmf fixes Manish Rangankar
2021-04-13 23:06 [PATCH 00/13] scsi: libicsi and " Mike Christie
2021-04-13 23:06 ` [PATCH 10/13] scsi: qedi: fix session block/unblock abuse during cleanup Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210410184016.21603-11-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=jejb@linux.ibm.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mrangankar@marvell.com \
    --cc=svernekar@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.