All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muneendra <muneendra.kumar@broadcom.com>
To: linux-scsi@vger.kernel.org
Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com,
	mkumar@redhat.com, Muneendra <muneendra.kumar@broadcom.com>
Subject: [PATCH 4/5] scsi: Added routine to set SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev
Date: Wed,  5 Aug 2020 08:21:01 +0530	[thread overview]
Message-ID: <1596595862-11075-5-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com>

Added a new routine scsi_set_noretries_abort_io_device()to set
SCMD_NORETRIES_ABORT for all the inflight/pending IO's on a particular
scsi device at that particular instant.

Export the symbol so the routine can be called by scsi_transport_fc.c

Added new function declaration scsi_set_noretries_abort_io_device in
scsi_priv.h

Signed-off-by: Muneendra <muneendra.kumar@broadcom.com>
---
 drivers/scsi/scsi_error.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/scsi_priv.h  |  1 +
 2 files changed, 54 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 3222496..938d770 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -271,6 +271,59 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd)
 	call_rcu(&scmd->rcu, scsi_eh_inc_host_failed);
 }
 
+static bool
+scsi_set_noretries_abort_io(struct request *rq, void *priv, bool reserved)
+{
+	struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
+	struct scsi_device *sdev = scmd->device;
+
+	/* only set SCMD_NORETRIES_ABORT on ios on a specific sdev */
+	if (sdev != priv)
+		return true;
+	/* we don't want this command reissued on abort success
+	 * so set SCMD_NORETRIES_ABORT bit to ensure it
+	 * won't get reissued
+	 */
+	if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT)
+		set_bit(SCMD_NORETRIES_ABORT, &scmd->state);
+	return true;
+}
+
+static int
+__scsi_set_noretries_abort_io_device(struct scsi_device *sdev)
+{
+
+	if (sdev->sdev_state != SDEV_RUNNING)
+		return -EINVAL;
+
+	if (blk_queue_init_done(sdev->request_queue)) {
+
+		blk_mq_quiesce_queue(sdev->request_queue);
+		blk_mq_tagset_busy_iter(&sdev->host->tag_set,
+				scsi_set_noretries_abort_io, sdev);
+		blk_mq_unquiesce_queue(sdev->request_queue);
+	}
+	return 0;
+}
+
+/*
+ * scsi_set_noretries_abort_io_device - set the SCMD_NORETRIES_ABORT
+ * bit for all the pending io's on a device
+ * @sdev:	scsi_device
+ */
+int
+scsi_set_noretries_abort_io_device(struct scsi_device *sdev)
+{
+	struct Scsi_Host *shost = sdev->host;
+	int ret  = -EINVAL;
+
+	mutex_lock(&shost->scan_mutex);
+	ret = __scsi_set_noretries_abort_io_device(sdev);
+	mutex_unlock(&shost->scan_mutex);
+	return ret;
+}
+EXPORT_SYMBOL(scsi_set_noretries_abort_io_device);
+
 /**
  * scsi_times_out - Timeout function for normal scsi commands.
  * @req:	request that is timing out.
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index d12ada0..1bbffd3 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -81,6 +81,7 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost,
 int scsi_eh_get_sense(struct list_head *work_q,
 		      struct list_head *done_q);
 int scsi_noretry_cmd(struct scsi_cmnd *scmd);
+extern int scsi_set_noretries_abort_io_device(struct scsi_device *sdev);
 
 /* scsi_lib.c */
 extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
-- 
1.8.3.1


  parent reply	other threads:[~2020-08-05  9:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05  2:50 [PATCH 0/5] scsi: Support to handle Intermittent errors Muneendra
2020-08-05  2:50 ` [PATCH 1/5] scsi: Added a new macro in scsi_cmnd.h Muneendra
2020-08-10  6:10   ` Hannes Reinecke
2020-08-05  2:50 ` [PATCH 2/5] scsi: Clear state bit SCMD_NORETRIES_ABORT of scsi_cmd before start request Muneendra
2020-08-10  6:11   ` Hannes Reinecke
2020-08-05  2:51 ` [PATCH 3/5] scsi: No retries on abort success Muneendra
2020-08-10  6:19   ` Hannes Reinecke
2020-08-05  2:51 ` Muneendra [this message]
2020-08-10  6:20   ` [PATCH 4/5] scsi: Added routine to set SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Hannes Reinecke
2020-08-05  2:51 ` [PATCH 5/5] scsi_transport_fc: Added a new sysfs attribute noretries_abort Muneendra
2020-08-10  6:24   ` Hannes Reinecke
2020-08-11  6:01     ` Muneendra Kumar M
2020-08-11  6:35       ` Hannes Reinecke
2020-08-11  7:03         ` Muneendra Kumar M
2020-08-11 14:00           ` Hannes Reinecke
2020-08-14  5:33             ` Muneendra Kumar M

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=1596595862-11075-5-git-send-email-muneendra.kumar@broadcom.com \
    --to=muneendra.kumar@broadcom.com \
    --cc=emilne@redhat.com \
    --cc=hare@suse.de \
    --cc=jsmart2021@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkumar@redhat.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.