From: "Ewan D. Milne" <emilne@redhat.com>
To: Muneendra <muneendra.kumar@broadcom.com>, linux-scsi@vger.kernel.org
Cc: jsmart2021@gmail.com, mkumar@redhat.com
Subject: Re: [PATCH v7 3/5] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL
Date: Mon, 23 Nov 2020 14:47:12 -0500 [thread overview]
Message-ID: <11ca876b0520724f84dc762b15e999421b694cf0.camel@redhat.com> (raw)
In-Reply-To: <1605070685-20945-4-git-send-email-muneendra.kumar@broadcom.com>
On Wed, 2020-11-11 at 10:28 +0530, Muneendra wrote:
> Added a new rport state FC_PORTSTATE_MARGINAL.
>
> Added a new interface fc_eh_should_retry_cmd which Checks if the cmd
> should be retried or not by checking the rport state.
> If the rport state is marginal it returns
> false to make sure there won't be any retries on the cmd.
>
> Also made changes in fc_remote_port_delete,fc_user_scan_tgt,
> fc_timeout_deleted_rport functions to handle the new rport state
> FC_PORTSTATE_MARGINAL.
>
> Signed-off-by: Muneendra <muneendra.kumar@broadcom.com>
>
> ---
> v7:
> Removed the changes related to SCMD_NORETRIES_ABORT bit.
>
> Added a new function fc_eh_should_retry_cmd to check whether the cmd
> should be retried based on the rport state.
>
> v6:
> No change
>
> v5:
> Made changes to clear the SCMD_NORETRIES_ABORT bit if the port_state
> has changed from marginal to online due to port_delete and port_add
> as we need the normal cmd retry behaviour
>
> Made changes in fc_scsi_scan_rport as we are checking
> FC_PORTSTATE_ONLINE
> instead of FC_PORTSTATE_ONLINE and FC_PORTSTATE_MARGINAL
>
> v4:
> Made changes in fc_eh_timed_out to call
> fc_rport_chkmarginal_set_noretries
> so that SCMD_NORETRIES_ABORT bit in cmd->state is set if rport state
> is marginal.
>
> Removed the newly added scsi_cmd argument to fc_remote_port_chkready
> as the current patch handles only SCSI EH timeout/abort case.
>
> v3:
> Rearranged the patch so that all the changes with respect to new
> rport state is part of this patch.
> Added a new argument to scsi_cmd to fc_remote_port_chkready
>
> v2:
> New patch
> ---
> drivers/scsi/scsi_transport_fc.c | 62 +++++++++++++++++++++++-------
> --
> include/scsi/scsi_transport_fc.h | 4 ++-
> 2 files changed, 49 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/scsi/scsi_transport_fc.c
> b/drivers/scsi/scsi_transport_fc.c
> index a926e8f9e56e..ffd25195ae62 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -148,20 +148,23 @@ fc_enum_name_search(host_event_code,
> fc_host_event_code,
> static struct {
> enum fc_port_state value;
> char *name;
> + int matchlen;
> } fc_port_state_names[] = {
> - { FC_PORTSTATE_UNKNOWN, "Unknown" },
> - { FC_PORTSTATE_NOTPRESENT, "Not Present" },
> - { FC_PORTSTATE_ONLINE, "Online" },
> - { FC_PORTSTATE_OFFLINE, "Offline" },
> - { FC_PORTSTATE_BLOCKED, "Blocked" },
> - { FC_PORTSTATE_BYPASSED, "Bypassed" },
> - { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics" },
> - { FC_PORTSTATE_LINKDOWN, "Linkdown" },
> - { FC_PORTSTATE_ERROR, "Error" },
> - { FC_PORTSTATE_LOOPBACK, "Loopback" },
> - { FC_PORTSTATE_DELETED, "Deleted" },
> + { FC_PORTSTATE_UNKNOWN, "Unknown", 7},
> + { FC_PORTSTATE_NOTPRESENT, "Not Present", 11 },
> + { FC_PORTSTATE_ONLINE, "Online", 6 },
> + { FC_PORTSTATE_OFFLINE, "Offline", 7 },
> + { FC_PORTSTATE_BLOCKED, "Blocked", 7 },
> + { FC_PORTSTATE_BYPASSED, "Bypassed", 8 },
> + { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics", 11 },
> + { FC_PORTSTATE_LINKDOWN, "Linkdown", 8 },
> + { FC_PORTSTATE_ERROR, "Error", 5 },
> + { FC_PORTSTATE_LOOPBACK, "Loopback", 8 },
> + { FC_PORTSTATE_DELETED, "Deleted", 7 },
> + { FC_PORTSTATE_MARGINAL, "Marginal", 8 },
> };
> fc_enum_name_search(port_state, fc_port_state, fc_port_state_names)
> +fc_enum_name_match(port_state, fc_port_state, fc_port_state_names)
> #define FC_PORTSTATE_MAX_NAMELEN 20
>
>
> @@ -2509,7 +2512,8 @@ fc_user_scan_tgt(struct Scsi_Host *shost, uint
> channel, uint id, u64 lun)
> if (rport->scsi_target_id == -1)
> continue;
>
> - if (rport->port_state != FC_PORTSTATE_ONLINE)
> + if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
> + (rport->port_state != FC_PORTSTATE_MARGINAL))
> continue;
>
> if ((channel == rport->channel) &&
> @@ -3373,7 +3377,8 @@ fc_remote_port_delete(struct fc_rport *rport)
>
> spin_lock_irqsave(shost->host_lock, flags);
>
> - if (rport->port_state != FC_PORTSTATE_ONLINE) {
> + if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
> + (rport->port_state != FC_PORTSTATE_MARGINAL)) {
> spin_unlock_irqrestore(shost->host_lock, flags);
> return;
> }
> @@ -3515,7 +3520,8 @@ fc_timeout_deleted_rport(struct work_struct
> *work)
> * target, validate it still is. If not, tear down the
> * scsi_target on it.
> */
> - if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
> + if (((rport->port_state == FC_PORTSTATE_ONLINE) ||
> + (rport->port_state == FC_PORTSTATE_MARGINAL)) &&
> (rport->scsi_target_id != -1) &&
> !(rport->roles & FC_PORT_ROLE_FCP_TARGET)) {
> dev_printk(KERN_ERR, &rport->dev,
> @@ -3658,7 +3664,8 @@ fc_scsi_scan_rport(struct work_struct *work)
> struct fc_internal *i = to_fc_internal(shost->transportt);
> unsigned long flags;
>
> - if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
> + if (((rport->port_state == FC_PORTSTATE_ONLINE) ||
> + (rport->port_state == FC_PORTSTATE_MARGINAL)) &&
> (rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
> !(i->f->disable_target_scan)) {
> scsi_scan_target(&rport->dev, rport->channel,
> @@ -3731,6 +3738,28 @@ int fc_block_scsi_eh(struct scsi_cmnd *cmnd)
> }
> EXPORT_SYMBOL(fc_block_scsi_eh);
>
> +/*
> + * fc_eh_should_retry_cmd - Checks if the cmd should be retried or
> not
> + * @scmd: The SCSI command to be checked
> + *
> + * This checks the rport state to decide if a cmd is
> + * retryable.
> + *
> + * Returns: true if the rport state is not in marginal state.
> + */
> +bool fc_eh_should_retry_cmd(struct scsi_cmnd *scmd)
> +{
> + struct fc_rport *rport = starget_to_rport(scsi_target(scmd-
> >device));
> +
> + if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
> + (scmd->request->cmd_flags & REQ_FAILFAST_TRANSPORT)) {
> + set_host_byte(scmd, DID_TRANSPORT_MARGINAL);
> + return false;
> + }
> + return true;
> +}
> +EXPORT_SYMBOL_GPL(fc_eh_should_retry_cmd);
> +
> /**
> * fc_vport_setup - allocates and creates a FC virtual port.
> * @shost: scsi host the virtual port is connected to.
> @@ -4162,7 +4191,8 @@ static blk_status_t fc_bsg_rport_prep(struct
> fc_rport *rport)
> !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT))
> return BLK_STS_RESOURCE;
>
> - if (rport->port_state != FC_PORTSTATE_ONLINE)
> + if ((rport->port_state != FC_PORTSTATE_ONLINE) &&
> + (rport->port_state != FC_PORTSTATE_MARGINAL))
> return BLK_STS_IOERR;
>
> return BLK_STS_OK;
> diff --git a/include/scsi/scsi_transport_fc.h
> b/include/scsi/scsi_transport_fc.h
> index c759b29e46c7..14214ee121ad 100644
> --- a/include/scsi/scsi_transport_fc.h
> +++ b/include/scsi/scsi_transport_fc.h
> @@ -67,6 +67,7 @@ enum fc_port_state {
> FC_PORTSTATE_ERROR,
> FC_PORTSTATE_LOOPBACK,
> FC_PORTSTATE_DELETED,
> + FC_PORTSTATE_MARGINAL,
> };
>
>
> @@ -742,7 +743,6 @@ struct fc_function_template {
> unsigned long disable_target_scan:1;
> };
>
> -
> /**
> * fc_remote_port_chkready - called to validate the remote port
> state
> * prior to initiating io to the port.
> @@ -758,6 +758,7 @@ fc_remote_port_chkready(struct fc_rport *rport)
>
> switch (rport->port_state) {
> case FC_PORTSTATE_ONLINE:
> + case FC_PORTSTATE_MARGINAL:
> if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
> result = 0;
> else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
> @@ -839,6 +840,7 @@ int fc_vport_terminate(struct fc_vport *vport);
> int fc_block_rport(struct fc_rport *rport);
> int fc_block_scsi_eh(struct scsi_cmnd *cmnd);
> enum blk_eh_timer_return fc_eh_timed_out(struct scsi_cmnd *scmd);
> +bool fc_eh_should_retry_cmd(struct scsi_cmnd *scmd);
>
> static inline struct Scsi_Host *fc_bsg_to_shost(struct bsg_job *job)
> {
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
next prev parent reply other threads:[~2020-11-23 19:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 4:58 [PATCH v7 0/5] scsi: Support to handle Intermittent errors Muneendra
2020-11-11 4:58 ` [PATCH v7 1/5] scsi: Added a new error code DID_TRANSPORT_MARGINAL in scsi.h Muneendra
2020-11-16 8:16 ` Hannes Reinecke
2020-11-23 19:45 ` Ewan D. Milne
2020-11-24 17:42 ` Himanshu Madhani
2020-11-11 4:58 ` [PATCH v7 2/5] scsi: No retries on abort success Muneendra
2020-11-16 8:22 ` Hannes Reinecke
2020-11-23 19:45 ` Ewan D. Milne
2020-11-24 17:43 ` Himanshu Madhani
2020-11-11 4:58 ` [PATCH v7 3/5] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL Muneendra
2020-11-16 8:19 ` Hannes Reinecke
2020-11-17 7:43 ` Muneendra Kumar M
2020-11-23 20:01 ` Ewan D. Milne
2020-11-23 19:47 ` Ewan D. Milne [this message]
2020-11-24 17:43 ` Himanshu Madhani
2020-11-11 4:58 ` [PATCH v7 4/5] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs Muneendra
2020-11-16 8:20 ` Hannes Reinecke
2020-11-23 19:47 ` Ewan D. Milne
2020-11-24 17:44 ` Himanshu Madhani
2020-11-11 4:58 ` [PATCH v7 5/5] scsi:lpfc: Added support for eh_should_retry_cmd Muneendra
2020-11-16 8:23 ` Hannes Reinecke
2020-11-23 19:51 ` Ewan D. Milne
2020-11-23 19:48 ` Ewan D. Milne
2020-11-24 17:46 ` Himanshu Madhani
2020-12-08 5:00 ` [PATCH v7 0/5] scsi: Support to handle Intermittent errors Muneendra Kumar M
2020-12-08 5:14 ` Martin K. Petersen
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=11ca876b0520724f84dc762b15e999421b694cf0.camel@redhat.com \
--to=emilne@redhat.com \
--cc=jsmart2021@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mkumar@redhat.com \
--cc=muneendra.kumar@broadcom.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