Message ID | 20210817091456.73342-1-hare@suse.de |
---|---|
Headers | show |
Series | SCSI EH argument reshuffle part II | expand |
On Tue, Aug 17, 2021 at 11:14:13AM +0200, Hannes Reinecke wrote: > @@ -383,9 +385,24 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) > } > zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); > zfcp_erp_wait(adapter); > - fc_ret = fc_block_scsi_eh(scpnt); > - if (fc_ret) > - ret = fc_ret; > +retry_rport_blocked: > + spin_lock_irqsave(host->host_lock, flags); > + list_for_each_entry(port, &adapter->port_list, list) { You need to take the `adapter->port_list_lock` to iterate over the `port_list`. i.e.: read_lock_irqsave(&adapter->port_list_lock, flags); > + struct fc_rport *rport = port->rport; > + > + if (rport->port_state == FC_PORTSTATE_BLOCKED) { > + if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT) > + ret = FAST_IO_FAIL; > + else > + ret = NEEDS_RETRY; > + break; > + } > + } > + spin_unlock_irqrestore(host->host_lock, flags); > + if (ret == NEEDS_RETRY) { > + msleep(1000); > + goto retry_rport_blocked; > + } I really can't say I like this open coded FC code in the driver at all. Is there a reason we can't use `fc_block_rport()` for all the rports of the adapter? We already do use it for other EH callbacks in the same file, and you already look up the rports in the adapters rport-list; so using that on the rports in the loop, instead of open-coding it doesn't seem bad? Or is there a locking problem? We might waste a few cycles with that, but frankly, this is all in EH and after adapter reset.. all performance concerns went our of the window with that already.
On Tue, Aug 17, 2021 at 11:14:12AM +0200, Hannes Reinecke wrote: > When calling a host reset we shouldn't rely on the command triggering > the reset, so allow megaraid_abort_and_reset() to be called with a > NULL scb. > And drop the pointless 'bus_reset' and 'target_reset' handlers, which > just call the same function as host_reset. > > Signed-off-by: Hannes Reinecke <hare@suse.com> > --- > drivers/scsi/megaraid.c | 42 ++++++++++++++++------------------------- > 1 file changed, 16 insertions(+), 26 deletions(-) > > diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c > index 56910e94dbf2..7c53933fb1b4 100644 > --- a/drivers/scsi/megaraid.c > +++ b/drivers/scsi/megaraid.c > @@ -1905,7 +1905,7 @@ megaraid_reset(struct scsi_cmnd *cmd) > > spin_lock_irq(&adapter->lock); > > - rval = megaraid_abort_and_reset(adapter, cmd, SCB_RESET); > + rval = megaraid_abort_and_reset(adapter, NULL, SCB_RESET); > > /* > * This is required here to complete any completed requests > @@ -1944,7 +1944,7 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor) > > scb = list_entry(pos, scb_t, list); Ther's a dev_warn before this, which dereferences cmd. > - if (scb->cmd == cmd) { /* Found command */ > + if (!cmd || scb->cmd == cmd) { /* Found command */ > > scb->state |= aor; But more importantly, this function doesn't make much sense for the !cmd case, as it doesn't really do anything when not matched. It seems like the legacy megaraid driver should just stop calling it for resets.
On 8/17/21 1:53 PM, Benjamin Block wrote: > On Tue, Aug 17, 2021 at 11:14:13AM +0200, Hannes Reinecke wrote: >> @@ -383,9 +385,24 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) >> } >> zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); >> zfcp_erp_wait(adapter); >> - fc_ret = fc_block_scsi_eh(scpnt); >> - if (fc_ret) >> - ret = fc_ret; >> +retry_rport_blocked: >> + spin_lock_irqsave(host->host_lock, flags); >> + list_for_each_entry(port, &adapter->port_list, list) { > > You need to take the `adapter->port_list_lock` to iterate over the `port_list`. > > i.e.: read_lock_irqsave(&adapter->port_list_lock, flags); > >> + struct fc_rport *rport = port->rport; >> + >> + if (rport->port_state == FC_PORTSTATE_BLOCKED) { >> + if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT) >> + ret = FAST_IO_FAIL; >> + else >> + ret = NEEDS_RETRY; >> + break; >> + } >> + } >> + spin_unlock_irqrestore(host->host_lock, flags); >> + if (ret == NEEDS_RETRY) { >> + msleep(1000); >> + goto retry_rport_blocked; >> + } > > I really can't say I like this open coded FC code in the driver at all. > > Is there a reason we can't use `fc_block_rport()` for all the rports of > the adapter? > > We already do use it for other EH callbacks in the same file, and you > already look up the rports in the adapters rport-list; so using that on > the rports in the loop, instead of open-coding it doesn't seem bad? Or > is there a locking problem? > > We might waste a few cycles with that, but frankly, this is all in EH > and after adapter reset.. all performance concerns went our of the > window with that already. > Question would be why we need to call fc_block_rport() at all in host reset. To my understanding a host reset is expected to do a full resync of the SAN topology, so the expectation is that after zfcp_erp_wait() the port list is stable (ie the HBA has finished processing all RSCNs related to the SAN resync). So can't we just drop the fc_block_rport() call here? All the other FC drivers do fine without that ... Cheers, Hannes
On 8/17/21 2:22 PM, Christoph Hellwig wrote: > On Tue, Aug 17, 2021 at 11:14:11AM +0200, Hannes Reinecke wrote: >> There's not much in common between host reset and all other error >> handlers, so use a separate function here. > > This loses the search in the internal queueing list. Which is probably > fine, but needs to be explained. > Yeah, correct, I misread the comment. Will be adding a 'qla1280_wait_for_pending_commands()'. Cheers, Hannes
On 8/17/21 11:14 AM, Hannes Reinecke wrote: > Issuing a host reset should not rely on any commands. > So use Scsi_Host as argument for eh_host_reset_handler. > > Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Steffen Maier <maier@linux.ibm.com> # for zfcp and common code Acked-by: Steffen Maier <maier@linux.ibm.com> # for zfcp > --- > Documentation/scsi/scsi_eh.rst | 2 +- > Documentation/scsi/scsi_mid_low_api.rst | 4 +- > drivers/s390/scsi/zfcp_scsi.c | 3 +- > drivers/scsi/scsi_error.c | 2 +- > include/scsi/scsi_host.h | 2 +- > 78 files changed, 271 insertions(+), 334 deletions(-) > > diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst > index 7d78c2475615..1ca451ad57df 100644 > --- a/Documentation/scsi/scsi_eh.rst > +++ b/Documentation/scsi/scsi_eh.rst > @@ -216,7 +216,7 @@ considered to fail always. > int (* eh_abort_handler)(struct scsi_cmnd *); > int (* eh_device_reset_handler)(struct scsi_cmnd *); > int (* eh_bus_reset_handler)(struct scsi_cmnd *); > - int (* eh_host_reset_handler)(struct scsi_cmnd *); > + int (* eh_host_reset_handler)(struct Scsi_Host *); > > Higher-severity actions are taken only when lower-severity actions > cannot recover some of failed scmds. Also, note that failure of the > diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst > index 63ddea2b9640..784587ea7eee 100644 > --- a/Documentation/scsi/scsi_mid_low_api.rst > +++ b/Documentation/scsi/scsi_mid_low_api.rst > @@ -777,7 +777,7 @@ Details:: > > /** > * eh_host_reset_handler - reset host (host bus adapter) > - * @scp: SCSI host that contains this device should be reset > + * @shp: SCSI host that contains this device should be reset > * > * Returns SUCCESS if command aborted else FAILED > * > @@ -794,7 +794,7 @@ Details:: > * > * Optionally defined in: LLD > **/ > - int eh_host_reset_handler(struct scsi_cmnd * scp) > + int eh_host_reset_handler(struct Scsi_Host * shp) > > > /** > diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c > index 9393f1587e8a..8bfa8ffd9ff6 100644 > --- a/drivers/s390/scsi/zfcp_scsi.c > +++ b/drivers/s390/scsi/zfcp_scsi.c > @@ -371,9 +371,8 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) > return ret; > } > > -static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) > +static int zfcp_scsi_eh_host_reset_handler(struct Scsi_Host *host) > { > - struct Scsi_Host *host = scpnt->device->host; > struct zfcp_adapter *adapter = (struct zfcp_adapter *)host->hostdata[0]; > int ret = SUCCESS; > unsigned long flags; > diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c > index 58a252c38992..8218e2976482 100644 > --- a/drivers/scsi/scsi_error.c > +++ b/drivers/scsi/scsi_error.c > @@ -811,7 +811,7 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) > if (!hostt->eh_host_reset_handler) > return FAILED; > > - rtn = hostt->eh_host_reset_handler(scmd); > + rtn = hostt->eh_host_reset_handler(host); > > if (rtn == SUCCESS) { > if (!hostt->skip_settle_delay) > diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h > index 75363707b73f..3b1acf91f4d0 100644 > --- a/include/scsi/scsi_host.h > +++ b/include/scsi/scsi_host.h > @@ -142,7 +142,7 @@ struct scsi_host_template { > int (* eh_device_reset_handler)(struct scsi_cmnd *); > int (* eh_target_reset_handler)(struct scsi_cmnd *); > int (* eh_bus_reset_handler)(struct scsi_cmnd *); > - int (* eh_host_reset_handler)(struct scsi_cmnd *); > + int (* eh_host_reset_handler)(struct Scsi_Host *); > > /* > * Before the mid layer attempts to scan for a new device where none >
On 8/17/2021 2:14 AM, Hannes Reinecke wrote: > lpfc_bus_reset_handler is really just a loop calling > lpfc_target_reset_handler() over all targets, which is what > the error handler will be doing anyway. > > Signed-off-by: Hannes Reinecke <hare@suse.de> > Cc: James Smart <james.smart@broadcom.com> > --- > drivers/scsi/lpfc/lpfc_scsi.c | 91 ----------------------------------- > 1 file changed, 91 deletions(-) > looks fine Reviewed-by: James Smart <jsmart2021@gmail.com> -- james
On 8/17/21 4:10 PM, Hannes Reinecke wrote: > On 8/17/21 4:03 PM, Steffen Maier wrote: >> On 8/17/21 2:54 PM, Hannes Reinecke wrote: >>> On 8/17/21 1:53 PM, Benjamin Block wrote: >>>> On Tue, Aug 17, 2021 at 11:14:13AM +0200, Hannes Reinecke wrote: >>>>> @@ -383,9 +385,24 @@ static int >>>>> zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) >>>>> } >>>>> zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); >>>>> zfcp_erp_wait(adapter); >>>>> - fc_ret = fc_block_scsi_eh(scpnt); >>>>> - if (fc_ret) >>>>> - ret = fc_ret; >>>>> +retry_rport_blocked: >>>>> + spin_lock_irqsave(host->host_lock, flags); >>>>> + list_for_each_entry(port, &adapter->port_list, list) { >>>> >>>> You need to take the `adapter->port_list_lock` to iterate over the >>>> `port_list`. >>>> >>>> i.e.: read_lock_irqsave(&adapter->port_list_lock, flags); >>>> >>>>> + struct fc_rport *rport = port->rport; >>>>> + >>>>> + if (rport->port_state == FC_PORTSTATE_BLOCKED) { >>>>> + if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT) >>>>> + ret = FAST_IO_FAIL; >>>>> + else >>>>> + ret = NEEDS_RETRY; >>>>> + break; >>>>> + } >>>>> + } >>>>> + spin_unlock_irqrestore(host->host_lock, flags); >>>>> + if (ret == NEEDS_RETRY) { >>>>> + msleep(1000); >>>>> + goto retry_rport_blocked; >>>>> + } >>>> >>>> I really can't say I like this open coded FC code in the driver at all. >>>> >>>> Is there a reason we can't use `fc_block_rport()` for all the rports of >>>> the adapter? >> >> Waiting for all rports to unblock in host_reset has been on my todo list >> since we prepared the eh callbacks to get rid of scsi_cmnd with v4.18 >> commits: >> 674595d8519f ("scsi: zfcp: decouple our scsi_eh callbacks from scsi_cmnd") >> 42afc6527d43 ("scsi: zfcp: decouple TMFs from scsi_cmnd by using >> fc_block_rport") >> 26f5fa9d47c1 ("scsi: zfcp: decouple SCSI setup of TMF from scsi_cmnd") >> 39abb11aca00 ("scsi: zfcp: decouple FSF request setup of TMF from >> scsi_cmnd") >> e0116c91c7d8 ("scsi: zfcp: split FCP_CMND IU setup between SCSI I/O and >> TMF again") >> 266883f2f7d5 ("scsi: zfcp: decouple TMF response handler from scsi_cmnd") >> 822121186375 ("scsi: zfcp: decouple SCSI traces for scsi_eh / TMF from >> scsi_cmnd") >> >> But the synchronization is non-trivial as Benjamin's question shows. >> There are also considerations about lock order, etc. >> >> I'm busy with other things, so don't hold your breath until I can review >> and test the code; I don't want any regression in that recovery code. >> >>>> We already do use it for other EH callbacks in the same file, and you >>>> already look up the rports in the adapters rport-list; so using that on >>>> the rports in the loop, instead of open-coding it doesn't seem bad? Or >>>> is there a locking problem? >>>> >>>> We might waste a few cycles with that, but frankly, this is all in EH >>>> and after adapter reset.. all performance concerns went our of the >>>> window with that already. >>>> >>> >>> Question would be why we need to call fc_block_rport() at all in host >>> reset. >>> To my understanding a host reset is expected to do a full resync of the >>> SAN topology, so the expectation is that after zfcp_erp_wait() the port >>> list is stable (ie the HBA has finished processing all RSCNs related to >>> the SAN resync). >> >> There is more to do in zfcp than in other FC HBA drivers, e.g. LUN open >> recoveries and how they related to rport unblock: >> v4.10 6f2ce1c6af37 ("scsi: zfcp: fix rport unblock race with LUN >> recovery"). >> The rport unblock is async to our internal recovery. zfcp_erp_wait() >> only waits for the latter by design. >> >>> So can't we just drop the fc_block_rport() call here? >> >> I don't think so. >> >>> All the other FC drivers do fine without that ... >> >> It would have been nice to have a common interface for all scsi_eh >> scopes. I.e. fc_block_host(struct Scsi_Host*) like we already have for >> fc_block_scsi_eh(struct scsi_cmnd*) and fc_block_rport(struct fc_rport*) >> [the latter having been introduced at the time of above eh callback >> preparations]. >> But if zfcp is the only one needing it for host_reset, having the code >> only in zfcp seems fine to me. >> >> > Right. Just wanted to clarify that. > If we need to use fc_block_rport() in host reset so be it; just wanted > to clarify if this _really_ is the case (and not just some copy'n'paste > stuff). > I'll be reworking the patch to call fc_block_rport(). On second thought, I might have been wrong. The argument I used with the old commit was that we must not unblock the rport too early with regards to zfcp-internal recovery. This is fixed within zfcp recovery (erp) code. So after zfcp_erp_wait() in host_reset, this is still ensured; and eventually the rport unblock will occur. I guess I was rather worried about returning from the host_reset callback with the async rport(s) unblock still pending. After all, (some) other reset_handler sync with rport unblock. However I cannot remember all details right now. Before you invest more time into this, maybe just drop this patch from the series for now and we solve it later on? I mean it's not necessary for the reset_handler function signature change. -- Mit freundlichen Gruessen / Kind regards Steffen Maier Linux on IBM Z and LinuxONE https://www.ibm.com/privacy/us/en/ IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Gregor Pillen Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
On 8/18/21 1:00 PM, Steffen Maier wrote: > On 8/17/21 4:10 PM, Hannes Reinecke wrote: >> On 8/17/21 4:03 PM, Steffen Maier wrote: [ .. ] >>> It would have been nice to have a common interface for all scsi_eh >>> scopes. I.e. fc_block_host(struct Scsi_Host*) like we already have for >>> fc_block_scsi_eh(struct scsi_cmnd*) and fc_block_rport(struct fc_rport*) >>> [the latter having been introduced at the time of above eh callback >>> preparations]. >>> But if zfcp is the only one needing it for host_reset, having the code >>> only in zfcp seems fine to me. >>> >>> >> Right. Just wanted to clarify that. >> If we need to use fc_block_rport() in host reset so be it; just wanted >> to clarify if this _really_ is the case (and not just some copy'n'paste >> stuff). >> I'll be reworking the patch to call fc_block_rport(). > > On second thought, I might have been wrong. > > The argument I used with the old commit was that we must not unblock the > rport too early with regards to zfcp-internal recovery. This is fixed > within zfcp recovery (erp) code. So after zfcp_erp_wait() in host_reset, > this is still ensured; and eventually the rport unblock will occur. > > I guess I was rather worried about returning from the host_reset > callback with the async rport(s) unblock still pending. After all, > (some) other reset_handler sync with rport unblock. However I cannot > remember all details right now. > > Before you invest more time into this, maybe just drop this patch from > the series for now and we solve it later on? I mean it's not necessary > for the reset_handler function signature change. > Well, actually it is. With the signature change host_reset is being called with a Scsi_Host argument, so we cannot identify 'the' rport. But I've modified the patch to cycle through all rports and call fc_block_rport() on each of them. That should be good enough for now. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
On 8/17/2021 2:14 AM, Hannes Reinecke wrote: > Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command > will be removed as argument for SCSI EH functions. > > Signed-off-by: Hannes Reinecke <hare@suse.de> > Cc: James Smart <james.smart@broadcom.com> > --- > drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > looks good Reviewed-by: James Smart <jsmart2021@gmail.com> -- james
On 8/17/2021 2:14 AM, Hannes Reinecke wrote: > Instead of passing in a scsi device we should be using the rport; > we already have the target and lun id as parameters, so there's > no need to pass the scsi device, too. > > Signed-off-by: Hannes Reinecke <hare@suse.com> > Cc: James Smart <james.smart@broadcom.com> > --- > drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > looks good Reviewed-by: James Smart <jsmart2021@gmail.com> -- james
On Tue, Aug 17, 2021 at 02:55:25PM +0200, Hannes Reinecke wrote: > On 8/17/21 2:13 PM, Christoph Hellwig wrote: > > First, thanks for resurrecting the series. > > > > Second, this giant patchbomb is almost impossible to review. It might > > make sense to resend what is the prep patches without the prototype > > changes after the first round of review - maybe we can squeeze those > > into 5.15 still and do the heavy lifting with another series per > > actually changes method or so. > > > Sure, can do. Do you have another chunk of these patches ready? It would be so nice to see the EH code finally cleaned up..
On 2/23/22 13:49, Christoph Hellwig wrote: > On Tue, Aug 17, 2021 at 02:55:25PM +0200, Hannes Reinecke wrote: >> On 8/17/21 2:13 PM, Christoph Hellwig wrote: >>> First, thanks for resurrecting the series. >>> >>> Second, this giant patchbomb is almost impossible to review. It might >>> make sense to resend what is the prep patches without the prototype >>> changes after the first round of review - maybe we can squeeze those >>> into 5.15 still and do the heavy lifting with another series per >>> actually changes method or so. >>> >> Sure, can do. > > Do you have another chunk of these patches ready? It would be so nice > to see the EH code finally cleaned up.. Sure. Against which tree? The SCSI pointer and scsi_request removal will have an impact onto these patches I guess, so I'd rather code against those patches folded in. Cheers, Hannes
On Wed, Feb 23, 2022 at 02:03:01PM +0100, Hannes Reinecke wrote: > Sure. Against which tree? > The SCSI pointer and scsi_request removal will have an impact onto these > patches I guess, so I'd rather code against those patches folded in. The SCSI pointer removal already is in Martin's staging tree, so that is a good baseline. I don't think the the scsi_request removal should have much overlap with the various driver patches and just a trivial overlap with the scsi_ioctl_reset changes. So maybe just prepare a first batch that is needed for the eh_host_reset prototype changes against Martin's staging tree?