diff mbox series

scsi: scsi_transport_fc: allow setting rport state to current state

Message ID 20240917230643.966768-1-bmarzins@redhat.com
State New
Headers show
Series scsi: scsi_transport_fc: allow setting rport state to current state | expand

Commit Message

Benjamin Marzinski Sept. 17, 2024, 11:06 p.m. UTC
The only input fc_rport_set_marginal_state() currently accepts is
"Marginal" when port_state is "Online", and "Online" when the port_state
is "Marginal". It should also allow setting port_state to its current
state, either "Marginal or "Online".

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 drivers/scsi/scsi_transport_fc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ewan Milne Sept. 26, 2024, 9:06 p.m. UTC | #1
On Tue, Sep 17, 2024 at 7:07 PM Benjamin Marzinski <bmarzins@redhat.com> wrote:
>
> The only input fc_rport_set_marginal_state() currently accepts is
> "Marginal" when port_state is "Online", and "Online" when the port_state
> is "Marginal". It should also allow setting port_state to its current
> state, either "Marginal or "Online".
>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---

Both scsi_host_set_state() and scsi_device_set_state() work this way,
so this seems quite reasonable.

Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Martin K. Petersen Oct. 4, 2024, 2:08 a.m. UTC | #2
On Tue, 17 Sep 2024 19:06:43 -0400, Benjamin Marzinski wrote:

> The only input fc_rport_set_marginal_state() currently accepts is
> "Marginal" when port_state is "Online", and "Online" when the port_state
> is "Marginal". It should also allow setting port_state to its current
> state, either "Marginal or "Online".
> 
> 

Applied to 6.12/scsi-fixes, thanks!

[1/1] scsi: scsi_transport_fc: allow setting rport state to current state
      https://git.kernel.org/mkp/scsi/c/d539a871ae47
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 7d088b8da075..2270732b353c 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1255,7 +1255,7 @@  static ssize_t fc_rport_set_marginal_state(struct device *dev,
 		 */
 		if (rport->port_state == FC_PORTSTATE_ONLINE)
 			rport->port_state = port_state;
-		else
+		else if (port_state != rport->port_state)
 			return -EINVAL;
 	} else if (port_state == FC_PORTSTATE_ONLINE) {
 		/*
@@ -1265,7 +1265,7 @@  static ssize_t fc_rport_set_marginal_state(struct device *dev,
 		 */
 		if (rport->port_state == FC_PORTSTATE_MARGINAL)
 			rport->port_state = port_state;
-		else
+		else if (port_state != rport->port_state)
 			return -EINVAL;
 	} else
 		return -EINVAL;