All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] scsi: scsi_error: Introduce new error handle mechanism
@ 2025-08-16 11:24 JiangJianJun
  2025-08-16 11:24 ` [PATCH 01/14] scsi: scsi_error: Define framework for LUN/target based error handle JiangJianJun
                   ` (16 more replies)
  0 siblings, 17 replies; 38+ messages in thread
From: JiangJianJun @ 2025-08-16 11:24 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, hare, bvanassche, michael.christie, hch,
	haowenchao22, john.g.garry, hewenliang4, yangyun50, wuyifeng10,
	wubo40, yangxingui

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, virtio_scsi 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.

The driver can implement these three function callbacks and set them in
the SCSI midlayer. I have added callbacks for setup/clear implementations:
 - setup/clear LUN based error handler
 - setup/clear target based error handler
As well as a generic implementation that the driver can directly reference. 

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)                                 |
+ --------- + ------- + ------------------------------------------------------+
| fail      | NA      | fallback to host  recovery, retry or finish with      |
|           |         | EIO(may offline disk)                                 |
+ --------- + ------- + ------------------------------------------------------+

Scenario2: target based error handle is enabled:
+-----------+---------+--------------+---------+------------------------------+
| lun reset | TUR     | target reset | TUR     | Desired result               |
+-----------+---------+--------------+---------+------------------------------+
| success   | success | NA           | NA      | retry or finish with         |
|           |         |              |         | EIO(may offline disk)        |
+-----------+---------+--------------+---------+------------------------------+
| success   | fail    | success      | success | retry or finish with         |
|           |         |              |         | EIO(may offline disk)        |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | success      | success | retry or finish with         |
|           |         |              |         | EIO(may offline disk)        |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | success      | fail    | fallback to host recovery,   |
|           |         |              |         | retry or finish with EIO(may |
|           |         |              |         | offline disk)                |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | fail         | NA      | fallback to host  recovery,  |
|           |         |              |         | retry or finish with EIO(may |
|           |         |              |         | offline disk)                |
+-----------+---------+--------------+---------+------------------------------+

Scenario3: both LUN and target based error handle are enabled:
+-----------+---------+--------------+---------+------------------------------+
| lun reset | TUR     | target reset | TUR     | Desired result               |
+-----------+---------+--------------+---------+------------------------------+
| success   | success | NA           | NA      | retry or finish with         |
|           |         |              |         | EIO(may offline disk)        |
+-----------+---------+--------------+---------+------------------------------+
| success   | fail    | success      | success | lun recovery fallback to     |
|           |         |              |         | target recovery, retry or    |
|           |         |              |         | finish with EIO(may offline  |
|           |         |              |         | disk                         |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | success      | success | lun recovery fallback to     |
|           |         |              |         | target recovery, retry or    |
|           |         |              |         | finish with EIO(may offline  |
|           |         |              |         | disk                         |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | success      | fail    | lun recovery fallback to     |
|           |         |              |         | target recovery, then fall   |
|           |         |              |         | back to host recovery, retry |
|           |         |              |         | or fhinsi with EIO(may       |
|           |         |              |         | offline disk)                |
+-----------+---------+--------------+---------+------------------------------+
| fail      | NA      | fail         | NA      | lun recovery fallback to     |
|           |         |              |         | target recovery, then fall   |
|           |         |              |         | back to host recovery, retry |
|           |         |              |         | or fhinsi with EIO(may       |
|           |         |              |         | offline disk)                |
+-----------+---------+--------------+---------+------------------------------+

References: https://lore.kernel.org/linux-scsi/20230815122316.4129333-1-haowenchao2@huawei.com/
References: https://lore.kernel.org/linux-scsi/71e09bb4-ff0a-23fe-38b4-fe6425670efa@huawei.com/

In this version of the push, I have made revisions based on the previous review comments. There
is previous version link:
References: https://lore.kernel.org/linux-scsi/20230901094127.2010873-1-haowenchao2@huawei.com/
References: https://lore.kernel.org/all/20250314012927.150860-1-jiangjianjun3@huawei.com/

JiangJianJun (4):
  scsi: core: increase/decrease target_busy if set error handler
  scsi: scsi_debug: Add params for configuring the error handler
  scsi: virtio_scsi: enable LUN based error handlers
  scsi: iscsi_tcp: enable LUN-based and target-based error handlers

Wenchao Hao (10):
  scsi: scsi_error: Define framework for LUN/target based error handle
  scsi: scsi_error: Move complete variable eh_action from shost to
    sdevice
  scsi: scsi_error: Check if to do reset in scsi_try_xxx_reset
  scsi: scsi_error: Add helper scsi_eh_sdev_stu to do START_UNIT
  scsi: scsi_error: Add helper scsi_eh_sdev_reset to do lun reset
  scsi: scsi_error: Add flags to mark error handle steps has done
  scsi: scsi_error: Add helper to handle scsi device's error command
    list
  scsi: scsi_error: Add a general LUN based error handler
  scsi: scsi_error: Add helper to handle scsi target's error command
    list
  scsi: scsi_error: Add a general target based error handler

 drivers/scsi/iscsi_tcp.c   |   4 +
 drivers/scsi/scsi_debug.c  |  26 +-
 drivers/scsi/scsi_error.c  | 800 ++++++++++++++++++++++++++++++++++---
 drivers/scsi/scsi_lib.c    |  17 +-
 drivers/scsi/scsi_priv.h   |  15 +
 drivers/scsi/scsi_scan.c   |  19 +
 drivers/scsi/scsi_sysfs.c  |   2 +
 drivers/scsi/virtio_scsi.c |   3 +
 include/scsi/scsi_device.h |  87 ++++
 include/scsi/scsi_eh.h     |   8 +
 include/scsi/scsi_host.h   |  33 +-
 11 files changed, 952 insertions(+), 62 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2025-09-14 12:00 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-16 11:24 [PATCH 00/14] scsi: scsi_error: Introduce new error handle mechanism JiangJianJun
2025-08-16 11:24 ` [PATCH 01/14] scsi: scsi_error: Define framework for LUN/target based error handle JiangJianJun
2025-08-16 11:24 ` [PATCH 02/14] scsi: scsi_error: Move complete variable eh_action from shost to sdevice JiangJianJun
2025-08-16 11:24 ` [PATCH 03/14] scsi: scsi_error: Check if to do reset in scsi_try_xxx_reset JiangJianJun
2025-08-16 11:24 ` [PATCH 04/14] scsi: scsi_error: Add helper scsi_eh_sdev_stu to do START_UNIT JiangJianJun
2025-08-16 11:24 ` [PATCH 05/14] scsi: scsi_error: Add helper scsi_eh_sdev_reset to do lun reset JiangJianJun
2025-08-16 11:24 ` [PATCH 06/14] scsi: scsi_error: Add flags to mark error handle steps has done JiangJianJun
2025-08-16 11:24 ` [PATCH 07/14] scsi: scsi_error: Add helper to handle scsi device's error command list JiangJianJun
2025-08-16 11:24 ` [PATCH 08/14] scsi: scsi_error: Add a general LUN based error handler JiangJianJun
2025-08-17  9:18   ` Markus Elfring
2025-08-16 11:24 ` [PATCH 09/14] scsi: core: increase/decrease target_busy if set " JiangJianJun
2025-08-16 11:24 ` [PATCH 10/14] scsi: scsi_error: Add helper to handle scsi target's error command list JiangJianJun
2025-08-16 23:19   ` kernel test robot
2025-08-17  2:46     ` JiangJianJun
2025-08-16 11:24 ` [PATCH 11/14] scsi: scsi_error: Add a general target based error handler JiangJianJun
2025-08-16 11:24 ` [PATCH 12/14] scsi: scsi_debug: Add params for configuring the " JiangJianJun
2025-08-16 11:24 ` [PATCH 13/14] scsi: virtio_scsi: enable LUN based error handlers JiangJianJun
2025-08-16 11:24 ` [PATCH 14/14] scsi: iscsi_tcp: enable LUN-based and target-based " JiangJianJun
2025-08-17  8:46 ` [PATCH 00/14] scsi: scsi_error: Introduce new error handle mechanism JiangJianJun
2025-08-20 12:36 ` Hannes Reinecke
2025-09-02  5:56   ` JiangJianJun
2025-09-02  6:37     ` Hannes Reinecke
2025-09-14 10:41   ` [RFC PATCH v4 0/9] " JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 1/9] scsi: scsi_error: Define framework for LUN based error handle JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 2/9] scsi: scsi_error: Move complete variable eh_action from shost to sdevice JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 3/9] scsi: scsi_error: Check if to do reset in scsi_try_xxx_reset JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 4/9] scsi: scsi_error: Add helper scsi_eh_sdev_stu to do START_UNIT JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 5/9] scsi: scsi_error: Add helper scsi_eh_sdev_reset to do lun reset JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 6/9] scsi: scsi_error: Add flags to mark error handle steps has done JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 7/9] scsi: scsi_error: Add helper to handle scsi device's error command list JiangJianJun
2025-09-14 10:41     ` [RFC PATCH v4 8/9] scsi: scsi_error: Add a general LUN based error handler JiangJianJun
2025-09-14 11:59       ` kernel test robot
2025-09-14 10:41     ` [RFC PATCH v4 9/9] scsi: scsi_debug: Add params for configuring the " JiangJianJun
2025-08-22  7:39 ` [PATCH 00/14] scsi: scsi_error: Introduce new error handle mechanism Damien Le Moal
2025-09-02  5:30   ` JiangJianJun
2025-09-02  5:08     ` Damien Le Moal
2025-09-02  6:03       ` JiangJianJun
2025-09-02  5:30         ` Damien Le Moal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.