Re: [RFC PATCH v2 00/18] scsi: scsi_error: Introduce new error handle mechanism

From: Mike Christie
Date: Tue Sep 05 2023 - 20:23:54 EST


On 9/1/23 4:41 AM, Wenchao Hao wrote:
> It's unbearable for systems with large scale scsi devices share HBAs to
> block all devices' IOs when handle error commands, we need a new error
> handle mechanism to address this issue.
>
> I consulted about this issue a year ago, the discuss link can be found in
> refenence. Hannes replied about why we have to block the SCSI host
> then perform error recovery kindly. I think it's unnecessary to block
> SCSI host for all drivers and can try a small level recovery(LUN based for
> example) first to avoid block the SCSI host.
>
> The new error handle mechanism introduced in this patchset has been
> developed and tested with out self developed hardware since one year
> ago, now we want this mechanism can be used by more drivers.
>
> Drivers can decide if using the new error handle mechanism and how to
> handle error commands when scsi_device are scanned,the new mechanism
> makes SCSI error handle more flexible.
>
> SCSI error recovery strategy after blocking host's IO is mainly
> following steps:
>
> - LUN reset
> - Target reset
> - Bus reset
> - Host reset
>
> Some drivers did not implement callbacks for host reset, it's unnecessary
> to block host's IO for these drivers. For example, smartpqi only registered
> device reset, if device reset failed, it's meaningless to fallback to target
> reset, bus reset or host reset any more, because these steps would also
> failed.
>
> Here are some drivers we concerned:(there are too many kinds of drivers
> to figure out, so here I just list some drivers I am familiar with)
>
> +-------------+--------------+--------------+-----------+------------+
> | drivers | device_reset | target_reset | bus_reset | host_reset |
> +-------------+--------------+--------------+-----------+------------+
> | mpt3sas | Y | Y | N | Y |
> +-------------+--------------+--------------+-----------+------------+
> | smartpqi | Y | N | N | N |
> +-------------+--------------+--------------+-----------+------------+
> | megaraidsas | N | Y | N | Y |
> +-------------+--------------+--------------+-----------+------------+
> | virtioscsi | Y | N | N | N |
> +-------------+--------------+--------------+-----------+------------+
> | iscsi_tcp | Y | Y | N | N |
> +-------------+--------------+--------------+-----------+------------+
> | hisisas | Y | Y | N | N |
> +-------------+--------------+--------------+-----------+------------+
>
> For LUN based error handle, when scsi command is classified as error,
> we would block the scsi device's IO and try to recover this scsi
> device, if still can not recover all error commands, it might
> fallback to target or host level recovery.
>
> It's same for target based error handle, but target based error handle
> would block the scsi target's IO then try to recover the error commands
> of this target.
>
> The first patch defines basic framework to support LUN/target based error
> handle mechanism, three key operations are abstracted which are:
> - add error command
> - wake up error handle
> - block IOs when error command is added and recoverying.
>
> Drivers can implement these three function callbacks and setup to SCSI
> middle level; I also add a general LUN/target based error handle strategy
> which can be called directly from drivers to implement LUN/tartget based
> error handle.
>
> The changes of SCSI middle level's error handle are tested with scsi_debug
> which support single LUN error injection, the scsi_debug patches can be
> found in reference, following scenarios are tested.
>
> Scenario1: LUN based error handle is enabled:
> +-----------+---------+-------------------------------------------------------+
> | lun reset | TUR | Desired result |
> + --------- + ------- + ------------------------------------------------------+
> | success | success | retry or finish with EIO(may offline disk) |
> + --------- + ------- + ------------------------------------------------------+
> | success | fail | fallback to host recovery, retry or finish with |
> | | | EIO(may offline disk) |


I didn't get this part about when we offline the disk now. For this LUN case, is
it if the driver has called scsi_device_setup_eh with the fallback arg with false?
If so why doesn't it just try target reset -> bus reset -> host reset like before?


>From a high level I have the following questions/comments:

1. The modparam and drivers calling scsi_device_setup_eh/scsi_device_clear_eh
seem uneeded.

If the driver supports performing multiple TMFs/resets in parallel then why
not always enable it?

2. You probably need to work more closely for some of the drivers. For the iscsi
patch, we would want to allocate a tmf per device and per target, or if a cmd
timesout on a second lun, that will always fail since the iscsi host has only
one tmf preallocated and it would be in use by the first reset.

For the other drivers, did you review what they support? If so, how many drivers
can you just turn this on for? Or what drivers did you test so far?