mbox series

[PATCHv6,0/9] scsi: EH rework, main part

Message ID 20231016121542.111501-1-hare@suse.de
Headers show
Series scsi: EH rework, main part | expand

Message

Hannes Reinecke Oct. 16, 2023, 12:15 p.m. UTC
Hi all,

(taking up an old thread:)
here's now the main part of my EH rework.
It modifies the reset callbacks for SCSI EH such that
each callback (eh_host_reset_handler, eh_bus_reset_handler,
eh_target_reset_handler, eh_device_reset_handler) only
references the actual entity it needs to work on
(ie 'Scsi_Host', (scsi bus), 'scsi_target', 'scsi_device'),
and the 'struct scsi_cmnd' is dropped from the argument list.
This simplifies the handler themselves as they don't need to
exclude some 'magic' command, and we don't need to allocate
a mock 'struct scsi_cmnd' when issuing a reset via SCSI ioctl.

The entire patchset can be found at:

https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git
branch eh-rework.v6

As usual, comments and reviews are welcome.

Changes to v5:
- Improve description for patch to modify scsi_eh_bus_device_reset()
- Add patch to modify the iteratrion in scsi_eh_bus_reset()

Hannes Reinecke (9):
  scsi: Use Scsi_Host as argument for eh_host_reset_handler
  scsi: Use Scsi_Host and channel number as argument for
    eh_bus_reset_handler()
  scsi: Use scsi_target as argument for eh_target_reset_handler()
  scsi: Use scsi_device as argument to eh_device_reset_handler()
  scsi: set host byte after EH completed
  scsi_error: iterate over list of failed commands in
    scsi_eh_bus_reset()
  scsi: Do not allocate scsi command in scsi_ioctl_reset()
  scsi_error: iterate over list of failed commands in
    scsi_eh_bus_device_reset()
  scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL

 Documentation/scsi/scsi_eh.rst              |  15 +-
 Documentation/scsi/scsi_mid_low_api.rst     |  33 ++-
 drivers/infiniband/ulp/srp/ib_srp.c         |  12 +-
 drivers/message/fusion/mptfc.c              |  25 +-
 drivers/message/fusion/mptsas.c             |  10 +-
 drivers/message/fusion/mptscsih.c           | 110 ++++-----
 drivers/message/fusion/mptscsih.h           |   8 +-
 drivers/message/fusion/mptspi.c             |   8 +-
 drivers/s390/scsi/zfcp_scsi.c               |  16 +-
 drivers/scsi/3w-9xxx.c                      |  11 +-
 drivers/scsi/3w-sas.c                       |  11 +-
 drivers/scsi/3w-xxxx.c                      |  13 +-
 drivers/scsi/53c700.c                       |  39 +--
 drivers/scsi/BusLogic.c                     |  15 +-
 drivers/scsi/NCR5380.c                      |   5 +-
 drivers/scsi/a100u2w.c                      |  11 +-
 drivers/scsi/aacraid/linit.c                |  41 ++--
 drivers/scsi/advansys.c                     |  26 +-
 drivers/scsi/aha152x.c                      |  10 +-
 drivers/scsi/aha1542.c                      |  28 +--
 drivers/scsi/aic7xxx/aic79xx_osm.c          |  37 ++-
 drivers/scsi/aic7xxx/aic7xxx_osm.c          |  10 +-
 drivers/scsi/arcmsr/arcmsr_hba.c            |   8 +-
 drivers/scsi/arm/acornscsi.c                |   8 +-
 drivers/scsi/arm/fas216.c                   |  24 +-
 drivers/scsi/arm/fas216.h                   |  17 +-
 drivers/scsi/atari_scsi.c                   |   4 +-
 drivers/scsi/be2iscsi/be_main.c             |  12 +-
 drivers/scsi/bfa/bfad_im.c                  |   8 +-
 drivers/scsi/bnx2fc/bnx2fc.h                |   4 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c             |  12 +-
 drivers/scsi/csiostor/csio_scsi.c           |   5 +-
 drivers/scsi/cxlflash/main.c                |  10 +-
 drivers/scsi/dc395x.c                       |  24 +-
 drivers/scsi/esas2r/esas2r.h                |   8 +-
 drivers/scsi/esas2r/esas2r_main.c           |  57 +++--
 drivers/scsi/esp_scsi.c                     |   9 +-
 drivers/scsi/fdomain.c                      |   3 +-
 drivers/scsi/fnic/fnic.h                    |   4 +-
 drivers/scsi/fnic/fnic_scsi.c               |   8 +-
 drivers/scsi/hpsa.c                         |  14 +-
 drivers/scsi/hptiop.c                       |   6 +-
 drivers/scsi/ibmvscsi/ibmvfc.c              |  19 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c            |  25 +-
 drivers/scsi/imm.c                          |   4 +-
 drivers/scsi/initio.c                       |  14 +-
 drivers/scsi/ipr.c                          |  29 ++-
 drivers/scsi/ips.c                          |  30 +--
 drivers/scsi/libfc/fc_fcp.c                 |  18 +-
 drivers/scsi/libiscsi.c                     |  21 +-
 drivers/scsi/libsas/sas_scsi_host.c         |  21 +-
 drivers/scsi/lpfc/lpfc_scsi.c               |  29 ++-
 drivers/scsi/mac53c94.c                     |   8 +-
 drivers/scsi/megaraid.c                     |   6 +-
 drivers/scsi/megaraid.h                     |   2 +-
 drivers/scsi/megaraid/megaraid_mbox.c       |  14 +-
 drivers/scsi/megaraid/megaraid_sas.h        |   3 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   |  60 +++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  55 +++--
 drivers/scsi/mesh.c                         |  12 +-
 drivers/scsi/mpi3mr/mpi3mr_os.c             | 134 +++++------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c        |  80 +++----
 drivers/scsi/mvumi.c                        |   9 +-
 drivers/scsi/myrb.c                         |   3 +-
 drivers/scsi/myrs.c                         |   3 +-
 drivers/scsi/ncr53c8xx.c                    |   4 +-
 drivers/scsi/nsp32.c                        |  14 +-
 drivers/scsi/pcmcia/nsp_cs.c                |  10 +-
 drivers/scsi/pcmcia/nsp_cs.h                |   6 +-
 drivers/scsi/pcmcia/qlogic_stub.c           |   4 +-
 drivers/scsi/pcmcia/sym53c500_cs.c          |   8 +-
 drivers/scsi/pmcraid.c                      |  31 ++-
 drivers/scsi/ppa.c                          |   4 +-
 drivers/scsi/qedf/qedf_main.c               |  13 +-
 drivers/scsi/qedi/qedi_iscsi.c              |   3 +-
 drivers/scsi/qla1280.c                      |  74 +++---
 drivers/scsi/qla2xxx/qla_os.c               |  85 +++----
 drivers/scsi/qla4xxx/ql4_os.c               |  56 ++---
 drivers/scsi/qlogicfas408.c                 |  10 +-
 drivers/scsi/qlogicfas408.h                 |   2 +-
 drivers/scsi/qlogicpti.c                    |   3 +-
 drivers/scsi/scsi_debug.c                   |  31 ++-
 drivers/scsi/scsi_error.c                   | 248 +++++++++-----------
 drivers/scsi/scsi_lib.c                     |   2 -
 drivers/scsi/smartpqi/smartpqi.h            |   1 -
 drivers/scsi/smartpqi/smartpqi_init.c       |  19 +-
 drivers/scsi/snic/snic.h                    |   5 +-
 drivers/scsi/snic/snic_scsi.c               |  41 +---
 drivers/scsi/stex.c                         |   9 +-
 drivers/scsi/storvsc_drv.c                  |   4 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c         |  14 +-
 drivers/scsi/virtio_scsi.c                  |  12 +-
 drivers/scsi/vmw_pvscsi.c                   |  20 +-
 drivers/scsi/wd33c93.c                      |   8 +-
 drivers/scsi/wd33c93.h                      |   2 +-
 drivers/scsi/wd719x.c                       |  17 +-
 drivers/scsi/xen-scsifront.c                |   6 +-
 drivers/staging/rts5208/rtsx.c              |   6 +-
 drivers/target/loopback/tcm_loop.c          |  17 +-
 drivers/ufs/core/ufshcd.c                   |  18 +-
 drivers/usb/image/microtek.c                |   4 +-
 drivers/usb/storage/scsiglue.c              |   8 +-
 drivers/usb/storage/uas.c                   |   3 +-
 include/scsi/libfc.h                        |   4 +-
 include/scsi/libiscsi.h                     |   4 +-
 include/scsi/libsas.h                       |   4 +-
 include/scsi/scsi_cmnd.h                    |   1 -
 include/scsi/scsi_eh.h                      |   2 +-
 include/scsi/scsi_host.h                    |   8 +-
 109 files changed, 1000 insertions(+), 1183 deletions(-)

Comments

Christoph Hellwig Oct. 17, 2023, 6:40 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Christoph Hellwig Oct. 17, 2023, 6:41 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Christoph Hellwig Oct. 17, 2023, 7:29 a.m. UTC | #3
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Wenchao Hao Oct. 17, 2023, 2:07 p.m. UTC | #4
On 2023/10/16 20:15, Hannes Reinecke wrote:
> The device reset function should only depend on the scsi device,
> not the scsi command.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>   Documentation/scsi/scsi_eh.rst          |  2 +-
>   Documentation/scsi/scsi_mid_low_api.rst |  4 +-
>   drivers/infiniband/ulp/srp/ib_srp.c     |  6 +--
>   drivers/message/fusion/mptfc.c          | 12 +++---
>   drivers/message/fusion/mptscsih.c       | 27 ++++---------
>   drivers/message/fusion/mptscsih.h       |  2 +-
>   drivers/s390/scsi/zfcp_scsi.c           |  4 +-
>   drivers/scsi/a100u2w.c                  |  7 ++--
>   drivers/scsi/aacraid/linit.c            |  9 ++---
>   drivers/scsi/aha152x.c                  |  6 +--
>   drivers/scsi/aha1542.c                  |  8 ++--
>   drivers/scsi/aic7xxx/aic79xx_osm.c      | 27 +++++--------
>   drivers/scsi/aic7xxx/aic7xxx_osm.c      |  4 +-
>   drivers/scsi/arm/fas216.c               |  5 +--
>   drivers/scsi/arm/fas216.h               |  6 +--
>   drivers/scsi/be2iscsi/be_main.c         |  8 ++--
>   drivers/scsi/bfa/bfad_im.c              |  3 +-
>   drivers/scsi/bnx2fc/bnx2fc.h            |  2 +-
>   drivers/scsi/bnx2fc/bnx2fc_io.c         |  6 +--
>   drivers/scsi/csiostor/csio_scsi.c       |  5 +--
>   drivers/scsi/cxlflash/main.c            |  5 +--
>   drivers/scsi/esas2r/esas2r.h            |  2 +-
>   drivers/scsi/esas2r/esas2r_main.c       |  3 +-
>   drivers/scsi/fnic/fnic.h                |  2 +-
>   drivers/scsi/fnic/fnic_scsi.c           |  5 +--
>   drivers/scsi/hpsa.c                     | 14 +++----
>   drivers/scsi/ibmvscsi/ibmvfc.c          |  8 ++--
>   drivers/scsi/ibmvscsi/ibmvscsi.c        | 19 ++++-----
>   drivers/scsi/ipr.c                      | 24 +++++------
>   drivers/scsi/libfc/fc_fcp.c             | 13 +++---
>   drivers/scsi/libiscsi.c                 | 15 ++++---
>   drivers/scsi/libsas/sas_scsi_host.c     | 12 +++---
>   drivers/scsi/lpfc/lpfc_scsi.c           | 12 +++---
>   drivers/scsi/mpi3mr/mpi3mr_os.c         | 40 ++++++++-----------
>   drivers/scsi/mpt3sas/mpt3sas_scsih.c    | 30 ++++++--------
>   drivers/scsi/pcmcia/nsp_cs.h            |  2 -
>   drivers/scsi/pmcraid.c                  |  8 ++--
>   drivers/scsi/qedf/qedf_main.c           |  6 +--
>   drivers/scsi/qla1280.c                  | 53 ++++++++-----------------
>   drivers/scsi/qla2xxx/qla_os.c           | 24 +++++------
>   drivers/scsi/qla4xxx/ql4_os.c           | 23 +++++------
>   drivers/scsi/scsi_debug.c               |  3 +-
>   drivers/scsi/scsi_error.c               |  2 +-
>   drivers/scsi/smartpqi/smartpqi.h        |  1 -
>   drivers/scsi/smartpqi/smartpqi_init.c   | 19 ++++-----
>   drivers/scsi/snic/snic.h                |  2 +-
>   drivers/scsi/snic/snic_scsi.c           |  4 +-
>   drivers/scsi/virtio_scsi.c              | 12 +++---
>   drivers/scsi/vmw_pvscsi.c               | 10 ++---
>   drivers/scsi/wd719x.c                   |  6 +--
>   drivers/scsi/xen-scsifront.c            |  6 +--
>   drivers/staging/rts5208/rtsx.c          |  6 ++-
>   drivers/target/loopback/tcm_loop.c      |  8 ++--
>   drivers/ufs/core/ufshcd.c               |  8 ++--
>   drivers/usb/storage/scsiglue.c          |  4 +-
>   drivers/usb/storage/uas.c               |  3 +-
>   include/scsi/libfc.h                    |  2 +-
>   include/scsi/libiscsi.h                 |  2 +-
>   include/scsi/libsas.h                   |  2 +-
>   include/scsi/scsi_host.h                |  2 +-
>   60 files changed, 253 insertions(+), 322 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index c247a3c7ae17..a2c3ffa2b5bd 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5306,9 +5306,8 @@ static void scsi_debug_stop_all_queued(struct scsi_device *sdp)
>   				scsi_debug_stop_all_queued_iter, sdp);
>   }
>   
> -static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
> +static int scsi_debug_device_reset(struct scsi_device *sdp)
>   {
> -	struct scsi_device *sdp = SCpnt->device;
>   	struct sdebug_dev_info *devip = sdp->hostdata;
>   
>   	++num_dev_resets;

The change of my scsi_debug error injection conflict with it, you can
fix the conflict with following:

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index a7c374b399a1..60070d12c949 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5590,12 +5590,10 @@ static void scsi_debug_stop_all_queued(struct scsi_device *sdp)
  				scsi_debug_stop_all_queued_iter, sdp);
  }
  
-static int sdebug_fail_lun_reset(struct scsi_cmnd *cmnd)
+static int sdebug_fail_lun_reset(struct scsi_device *sdp)
  {
-	struct scsi_device *sdp = cmnd->device;
  	struct sdebug_dev_info *devip = (struct sdebug_dev_info *)sdp->hostdata;
  	struct sdebug_err_inject *err;
-	unsigned char *cmd = cmnd->cmnd;
  	int ret = 0;
  
  	if (devip == NULL)
@@ -5603,8 +5601,7 @@ static int sdebug_fail_lun_reset(struct scsi_cmnd *cmnd)
  
  	rcu_read_lock();
  	list_for_each_entry_rcu(err, &devip->inject_err_list, list) {
-		if (err->type == ERR_LUN_RESET_FAILED &&
-		    (err->cmd == cmd[0] || err->cmd == 0xff)) {
+		if (err->type == ERR_LUN_RESET_FAILED) {
  			ret = !!err->cnt;
  			if (err->cnt < 0)
  				err->cnt++;
@@ -5618,12 +5615,9 @@ static int sdebug_fail_lun_reset(struct scsi_cmnd *cmnd)
  	return 0;
  }
  
-static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_device_reset(struct scsi_device *sdp)
  {
-	struct scsi_device *sdp = SCpnt->device;
  	struct sdebug_dev_info *devip = sdp->hostdata;
-	u8 *cmd = SCpnt->cmnd;
-	u8 opcode = cmd[0];
  
  	++num_dev_resets;
  
@@ -5634,8 +5628,8 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
  	if (devip)
  		set_bit(SDEBUG_UA_POR, devip->uas_bm);
  
-	if (sdebug_fail_lun_reset(SCpnt)) {
-		scmd_printk(KERN_INFO, SCpnt, "fail lun reset 0x%x\n", opcode);
+	if (sdebug_fail_lun_reset(sdp)) {
+		sdev_printk(KERN_INFO, sdp, "fail lun reset\n");
  		return FAILED;
  	}