public inbox for linux-scsi@vger.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 5/5] scsi_transport_fc: Added a new sysfs attribute noretries_abort
Date: Wed,  5 Aug 2020 08:21:02 +0530	[thread overview]
Message-ID: <1596595862-11075-6-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com>

Added a new sysfs attribute noretries_abort under fc_transport/target*/

This interface will set SCMD_NORETRIES_ABORT bit in scmd->state for all
the pending io's on the scsi device associated with target port.

Below is the interface provided to abort the io
echo 1 >> /sys/class/fc_transport/targetX\:Y\:Z/noretries_abort

Signed-off-by: Muneendra <muneendra.kumar@broadcom.com>
---
 drivers/scsi/scsi_transport_fc.c | 49 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2732fa6..f7b00ae 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -305,7 +305,7 @@ struct device_attribute device_attr_##_prefix##_##_name = 	\
  * Attribute counts pre object type...
  * Increase these values if you add attributes
  */
-#define FC_STARGET_NUM_ATTRS 	3
+#define FC_STARGET_NUM_ATTRS	4
 #define FC_RPORT_NUM_ATTRS	10
 #define FC_VPORT_NUM_ATTRS	9
 #define FC_HOST_NUM_ATTRS	29
@@ -994,6 +994,44 @@ static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
 /*
  * FC SCSI Target Attribute Management
  */
+static void scsi_target_set_noretries_abort(struct scsi_target *starget)
+{
+	struct scsi_device *sdev, *tmp;
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	unsigned long flags;
+
+	spin_lock_irqsave(shost->host_lock, flags);
+	list_for_each_entry_safe(sdev, tmp, &starget->devices, same_target_siblings) {
+		if (sdev->sdev_state == SDEV_DEL)
+			continue;
+		if (scsi_device_get(sdev))
+			continue;
+
+		spin_unlock_irqrestore(shost->host_lock, flags);
+		scsi_set_noretries_abort_io_device(sdev);
+		spin_lock_irqsave(shost->host_lock, flags);
+		scsi_device_put(sdev);
+	}
+	spin_unlock_irqrestore(shost->host_lock, flags);
+}
+
+/*
+ * Sets  no retries on abort in scmd->state for all
+ * outstanding io of all the scsi_devs
+ * write 1 to set the bit for all outstanding io's
+ */
+static ssize_t fc_target_set_noretries_abort(struct device *dev,
+						struct device_attribute *attr,
+						const char *buf, size_t count)
+{
+	struct scsi_target *starget = transport_class_to_starget(dev);
+
+	scsi_target_set_noretries_abort(starget);
+	return count;
+}
+
+static FC_DEVICE_ATTR(starget, noretries_abort, 0200,
+		NULL, fc_target_set_noretries_abort);
 
 /*
  * Note: in the target show function we recognize when the remote
@@ -1036,6 +1074,13 @@ static FC_DEVICE_ATTR(starget, field, S_IRUGO,			\
 	if (i->f->show_starget_##field)					\
 		count++
 
+#define SETUP_PRIVATE_STARGET_ATTRIBUTE_RW(field)			\
+do {									\
+	i->private_starget_attrs[count] = device_attr_starget_##field; \
+	i->starget_attrs[count] = &i->private_starget_attrs[count];	\
+	count++;							\
+} while (0)
+
 #define SETUP_STARGET_ATTRIBUTE_RW(field)				\
 	i->private_starget_attrs[count] = device_attr_starget_##field; \
 	if (!i->f->set_starget_##field) {				\
@@ -2197,7 +2242,7 @@ struct scsi_transport_template *
 	SETUP_STARGET_ATTRIBUTE_RD(node_name);
 	SETUP_STARGET_ATTRIBUTE_RD(port_name);
 	SETUP_STARGET_ATTRIBUTE_RD(port_id);
-
+	SETUP_PRIVATE_STARGET_ATTRIBUTE_RW(noretries_abort);
 	BUG_ON(count > FC_STARGET_NUM_ATTRS);
 
 	i->starget_attrs[count] = NULL;
-- 
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 ` [PATCH 4/5] scsi: Added routine to set SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Muneendra
2020-08-10  6:20   ` Hannes Reinecke
2020-08-05  2:51 ` Muneendra [this message]
2020-08-10  6:24   ` [PATCH 5/5] scsi_transport_fc: Added a new sysfs attribute noretries_abort 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-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox