Commit afdd1126 authored by Muneendra Kumar's avatar Muneendra Kumar Committed by Martin K. Petersen

scsi: scsi_transport_fc: Add store capability to rport port_state in sysfs

Add store capability to the rport port_state using sysfs under
fc_remote_ports/rport-*/port_state.

With this the user can move the port_state from Marginal->Online and
Online->Marginal.

 - Marginal: This interface will set SCMD_NORETRIES_ABORT bit in
   scmd->state for all the pending I/Os on the SCSI device associated with
   target port.

 - Online: This interface will clear SCMD_NORETRIES_ABORT bit in
   scmd->state for all the pending I/Os on the SCSI device associated with
   target port.

The following interface is provided to set the port state to Marginal and
Online respectively:

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

Link: https://lore.kernel.org/r/1609969748-17684-5-git-send-email-muneendra.kumar@broadcom.comReviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMuneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 02c66326
...@@ -1238,7 +1238,59 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr, ...@@ -1238,7 +1238,59 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr,
static FC_DEVICE_ATTR(rport, roles, S_IRUGO, static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
show_fc_rport_roles, NULL); show_fc_rport_roles, NULL);
fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); 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 (ret)
return -EINVAL;
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;
else
return -EINVAL;
} 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;
else
return -EINVAL;
} 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); fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
/* /*
...@@ -2681,7 +2733,7 @@ fc_attach_transport(struct fc_function_template *ft) ...@@ -2681,7 +2733,7 @@ fc_attach_transport(struct fc_function_template *ft)
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name); SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id); SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles); 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_RD(scsi_target_id);
SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo); SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment