From: Muneendra <muneendra.kumar@broadcom.com>
To: linux-scsi@vger.kernel.org, hare@suse.de
Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com,
Muneendra <muneendra.kumar@broadcom.com>
Subject: [PATCH v3 06/17] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs
Date: Thu, 15 Oct 2020 08:57:31 +0530 [thread overview]
Message-ID: <1602732462-10443-7-git-send-email-muneendra.kumar@broadcom.com> (raw)
In-Reply-To: <1602732462-10443-1-git-send-email-muneendra.kumar@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 4469 bytes --]
Added a store functionality to set rport port_state using sysfs
under fc_remote_ports/rport-*/port_state
With this functionality the user can move the port_state from
Marginal->Online and Online->Marginal.
On Marginal :This interface will set SCMD_NORETRIES_ABORT bit in
scmd->state for all the io's on the scsi device associated
with remote port.
On Online :This interface will clear SCMD_NORETRIES_ABORT bit in
scmd->state for all the pending io's on the scsi device associated
with remote port.
Below is the interface provided to set the port state to Marginal
and Online.
echo "Marginal" >> /sys/class/fc_remote_ports/rport-X\:Y-Z/port_state
echo "Online" >> /sys/class/fc_remote_ports/rport-X\:Y-Z/port_state
Signed-off-by: Muneendra <muneendra.kumar@broadcom.com>
---
v3:
Removed the port_state from starget attributes.
Enabled the store functionality for port_state under remote port.
used the starget_for_each_device to traverse around all the devices
under rport
v2:
Changed from a noretries_abort attribute under fc_transport/target*/ to
port_state for changing the port_state to a marginal state
---
drivers/scsi/scsi_transport_fc.c | 85 +++++++++++++++++++++++++++++++-
1 file changed, 83 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index df66a51d62e6..ac5283b645a6 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -943,7 +943,88 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr,
static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
show_fc_rport_roles, NULL);
-fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
+static void
+device_chg_noretries_abort(struct scsi_device *sdev, void *data)
+{
+ scsi_chg_noretries_abort_io_device(sdev, *(bool *)data);
+}
+
+static int
+target_chg_noretries_abort(struct device *dev, void *data)
+{
+ if (scsi_is_target_device(dev))
+ starget_for_each_device(to_scsi_target(dev), data,
+ device_chg_noretries_abort);
+ return 0;
+}
+
+static void scsi_target_chg_noretries_abort(struct device *dev, bool set)
+{
+ if (scsi_is_target_device(dev))
+ starget_for_each_device(to_scsi_target(dev), &set,
+ device_chg_noretries_abort);
+ else
+ device_for_each_child(dev, &set, target_chg_noretries_abort);
+}
+
+/*
+ * Sets port_state to Marginal/Online.
+ * On Marginal it Sets no retries on abort in scmd->state for all
+ * outstanding io of all the scsi_devs
+ * This only allows ONLINE->MARGINAL and MARGINAL->ONLINE
+ */
+static ssize_t fc_rport_set_marginal_state(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct fc_rport *rport = transport_class_to_rport(dev);
+ enum fc_port_state port_state;
+ int ret = 0;
+
+ ret = get_fc_port_state_match(buf, &port_state);
+
+ if (port_state == FC_PORTSTATE_MARGINAL) {
+ /*
+ * Change the state to marginal only if the
+ * current rport state is Online
+ * Allow only Online->marginal
+ */
+ if (rport->port_state == FC_PORTSTATE_ONLINE) {
+ rport->port_state = port_state;
+ scsi_target_chg_noretries_abort(&rport->dev, 1);
+ }
+ } else if (port_state == FC_PORTSTATE_ONLINE) {
+ /*
+ * Change the state to Online only if the
+ * current rport state is Marginal
+ * Allow only MArginal->Online
+ */
+ if (rport->port_state == FC_PORTSTATE_MARGINAL) {
+ rport->port_state = port_state;
+ scsi_target_chg_noretries_abort(&rport->dev, 0);
+ }
+ } else
+ return -EINVAL;
+ return count;
+}
+
+static ssize_t
+show_fc_rport_port_state(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ const char *name;
+ struct fc_rport *rport = transport_class_to_rport(dev);
+
+ name = get_fc_port_state_name(rport->port_state);
+ if (!name)
+ return -EINVAL;
+
+ return snprintf(buf, 20, "%s\n", name);
+}
+
+static FC_DEVICE_ATTR(rport, port_state, 0444 | 0200,
+ show_fc_rport_port_state, fc_rport_set_marginal_state);
+
fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
/*
@@ -2266,7 +2347,7 @@ fc_attach_transport(struct fc_function_template *ft)
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles);
- SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state);
+ SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(port_state);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);
--
2.26.2
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4177 bytes --]
next prev parent reply other threads:[~2020-10-15 10:21 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 3:27 [PATCH v3 00/17] scsi: Support to handle Intermittent errors Muneendra
2020-10-15 3:27 ` [PATCH v3 01/17] scsi: Added a new definition in scsi_cmnd.h Muneendra
2020-10-15 3:27 ` [PATCH v3 02/17] scsi: Added a new error code in scsi.h Muneendra
2020-10-15 3:27 ` [PATCH v3 03/17] scsi: No retries on abort success Muneendra
2020-10-16 18:37 ` Mike Christie
2020-10-19 19:05 ` Mike Christie
2020-10-19 19:26 ` Muneendra Kumar M
2020-10-20 19:53 ` Mike Christie
2020-10-20 20:18 ` Mike Christie
2020-10-21 18:51 ` Muneendra Kumar M
2020-10-15 3:27 ` [PATCH v3 04/17] scsi: Added routine to set/clear SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Muneendra
2020-10-15 3:27 ` [PATCH v3 05/17] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL Muneendra
2020-10-16 19:52 ` Mike Christie
2020-10-19 10:47 ` Muneendra Kumar M
2020-10-19 16:10 ` Michael Christie
2020-10-19 16:19 ` Michael Christie
2020-10-19 17:16 ` Hannes Reinecke
2020-10-19 17:31 ` Muneendra Kumar M
2020-10-19 18:55 ` Mike Christie
2020-10-19 19:03 ` Muneendra Kumar M
2020-10-20 18:24 ` Benjamin Marzinski
2020-10-20 6:03 ` Hannes Reinecke
2020-10-19 18:03 ` Muneendra Kumar M
2020-10-19 18:44 ` Mike Christie
2020-10-19 18:55 ` Muneendra Kumar M
2020-10-20 16:48 ` Mike Christie
2020-10-20 17:19 ` Muneendra Kumar M
2020-10-20 18:44 ` Benjamin Marzinski
2020-10-20 18:14 ` Benjamin Marzinski
2020-10-15 3:27 ` Muneendra [this message]
2020-10-15 14:05 ` [PATCH v3 06/17] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs kernel test robot
2020-10-16 18:34 ` Mike Christie
2020-10-19 10:52 ` Muneendra Kumar M
2020-10-15 3:27 ` [PATCH v3 07/17] scsi:lpfc: Added changes to fc_remote_port_chkready Muneendra
2020-10-15 3:27 ` [PATCH v3 08/17] scsi:qla2xx: " Muneendra
2020-10-15 3:27 ` [PATCH v3 09/17] scsi:qedf: " Muneendra
2020-10-15 3:27 ` [PATCH v3 10/17] scsi:libfc: " Muneendra
2020-10-15 3:27 ` [PATCH v3 11/17] scsi:ibmvfc: " Muneendra
2020-10-15 3:27 ` [PATCH v3 12/17] scsi:fnic: " Muneendra
2020-10-15 3:27 ` [PATCH v3 13/17] scsi:bnx2fc: " Muneendra
2020-10-15 3:27 ` [PATCH v3 14/17] scsi:csio: " Muneendra
2020-10-15 3:27 ` [PATCH v3 15/17] scsi:bfa: " Muneendra
2020-10-15 3:27 ` [PATCH v3 16/17] scsi:zfcp: " Muneendra
2020-10-22 16:50 ` Benjamin Block
2020-10-15 3:27 ` [PATCH v3 17/17] scsi:mpt: " Muneendra
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=1602732462-10443-7-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