Hi Mike, Thanks for the detailed input. I will apply the below changes and will resubmit the patches. Regards, Muneendra. -----Original Message----- From: Mike Christie [mailto:michael.christie@xxxxxxxxxx] Sent: Friday, November 6, 2020 12:46 AM To: Muneendra Kumar M <muneendra.kumar@xxxxxxxxxxxx>; linux-scsi@xxxxxxxxxxxxxxx; hare@xxxxxxx Cc: jsmart2021@xxxxxxxxx; emilne@xxxxxxxxxx; mkumar@xxxxxxxxxx Subject: Re: [PATCH v6 3/4] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL On 11/5/20 11:27 AM, Muneendra Kumar M wrote: > Hi Mike, > Thanks for the input. > Below are my replies. > > >> Hey sorry for the late reply. I was trying to test some things out >> but am not sure if all drivers work the same. > >> For the code above, what will happen if we have passed that check in >> the driver, then the driver does the report del and add sequence? >> Let's say it's initially calling the abort callout, and we passed >> that check, we then do the >del/add seqeuence, what will happen next? >> Do the fc drivers return success or failure for the abort call. What >> happens for the other callouts too? > >> If failure, then the eh escalates and when we call the next callout, >> and we hit the check above and will clear it, so we are ok. > > If success then we would not get a chance to clear it right? > [Muneendra]Agreed. So what about clearing the flags in > fc_remote_port_del. I think this should address all the concerns? > >> If this is the case, then I think you need to instead go the route >> where you add the eh cmd completion/decide_disposition callout. You >> would call it in scmd_eh_abort_handler, scsi_eh_bus_device_reset, etc >> when we are deciding if we want to retry/fail the command. > [Muneendra]Sorry I didn't get what you are saying could you please > elaborate on the same. > > In this approach you do not need the eh_timed_out changes, since we > only seem to care about the port state after the eh callout has completed. > [Muneendra]what about setting the SCMD_NORETRIES_ABORT bit? > I don't think you need it. It sounds like we only care about the port state when the cmd is completing. For example we have: 1. the case where the cmd times out, we do aborts/resets, then the port state goes into marginal, then the aborts/resets complete. We want to fail the cmds without retries. 2. If the port state is in marginal, the cmd times out, we do the aborts/resets and when we are done if the port state is still marginal we want to fail the cmd without retries. 3. If the port state is marginal (or any value), before or after the cmd initially times out, but the port state goes back to online, then when the aborts/resets complete we want to retry the cmd. So can we just add a callout to check the port state when the eh has completed like the untested unfinished patch below: diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 983eeb0..8ad3a9a 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6041,6 +6041,7 @@ struct scsi_host_template lpfc_template = { .info = lpfc_info, .queuecommand = lpfc_queuecommand, .eh_timed_out = fc_eh_timed_out, + .eh_timed_out = fc_eh_should_retry_cmd, .eh_abort_handler = lpfc_abort_handler, .eh_device_reset_handler = lpfc_device_reset_handler, .eh_target_reset_handler = lpfc_target_reset_handler, diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index f11f51e..7c66d17 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -140,6 +140,7 @@ static bool scsi_cmd_retry_allowed(struct scsi_cmnd *cmd) struct scsi_cmnd *scmd = container_of(work, struct scsi_cmnd, abort_work.work); struct scsi_device *sdev = scmd->device; + struct Scsi_Host *host = sdev->host; int rtn; if (scsi_host_eh_past_deadline(sdev->host)) { @@ -159,7 +160,8 @@ static bool scsi_cmd_retry_allowed(struct scsi_cmnd *cmd) "eh timeout, not retrying " "aborted command\n")); } else if (!scsi_noretry_cmd(scmd) && - scsi_cmd_retry_allowed(scmd)) { + scsi_cmd_retry_allowed(scmd) && + host->hostt->eh_should_retry_cmd(scmd)) { SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_WARNING, scmd, "retry aborted command\n")); @@ -2105,7 +2107,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q) list_for_each_entry_safe(scmd, next, done_q, eh_entry) { list_del_init(&scmd->eh_entry); if (scsi_device_online(scmd->device) && - !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd)) { + !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd) && + host->hostt->eh_should_retry_cmd(scmd)) { SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, "%s: flush retry cmd\n", diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 2ff7f06..7011963 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -2043,6 +2043,18 @@ static int fc_vport_match(struct attribute_container *cont, return &i->vport_attr_cont.ac == cont; } +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_MARGINAL) + return false; + + /* Other port states will set the sdev state */ + /* TODO check comment above */ + return true; +} +EXPORT_SYMBOL_GPL(fc_eh_should_retry_cmd); /** * fc_eh_timed_out - FC Transport I/O timeout intercept handler diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 701f178..51d5af0 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -315,6 +315,13 @@ struct scsi_host_template { */ enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); + /* + * Optional routine that allows the transport to decide if a cmd is + * retryable. Return true if the transport is in a state the cmd + * should be retried on. + */ + bool (*eh_should_retry_cmd)(struct scsi_cmnd *); + /* This is an optional routine that allows transport to initiate * LLD adapter or firmware reset using sysfs attribute. * diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 1c7dd35..f21b583 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -803,6 +803,7 @@ struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, 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) {
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature