linux/drivers/scsi/isci
Yufen Yu 49da96d779 scsi: libsas: Add LUN number check in .slave_alloc callback
Offlining a SATA device connected to a hisi SAS controller and then
scanning the host will result in detecting 255 non-existent devices:

  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:2:0]    disk    SEAGATE  ST600MM0006      B001  /dev/sdc
  # echo "offline" > /sys/block/sdb/device/state
  # echo "- - -" > /sys/class/scsi_host/host2/scan
  # lsscsi
  [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
  [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
  [2:0:1:1]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdh
  ...
  [2:0:1:255]  disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdjb

After a REPORT LUN command issued to the offline device fails, the SCSI
midlayer tries to do a sequential scan of all devices whose LUN number is
not 0. However, SATA does not support LUN numbers at all.

Introduce a generic sas_slave_alloc() handler which will return -ENXIO for
SATA devices if the requested LUN number is larger than 0 and make libsas
drivers use this function as their .slave_alloc callback.

Link: https://lore.kernel.org/r/20210622034037.1467088-1-yuyufen@huawei.com
Reported-by: Wu Bo <wubo40@huawei.com>
Suggested-by: John Garry <john.garry@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-22 21:33:33 -04:00
..
host.c scsi: isci: host: Fix bunch of kernel-doc related issues 2021-03-18 23:41:07 -04:00
host.h scsi: isci: Change sci_controller_start_task's return type to sci_status 2018-10-16 21:38:47 -04:00
init.c scsi: libsas: Add LUN number check in .slave_alloc callback 2021-06-22 21:33:33 -04:00
isci.h scsi: isci: Use true, false for bool variables 2020-04-24 18:21:15 -04:00
Makefile
phy.c scsi: isci: phy: Provide function name and demote non-conforming header 2021-03-18 23:41:07 -04:00
phy.h scsi: isci: Remove unnecessary struct declaration 2021-04-13 01:39:12 -04:00
port_config.c scsi: isci: port_config: Fix a bunch of doc-rot and demote abuses 2021-03-18 23:41:07 -04:00
port.c scsi: isci: port: Fix a bunch of kernel-doc issues 2021-03-18 23:41:08 -04:00
port.h
probe_roms.c
probe_roms.h
registers.h
remote_device.c scsi: isci: remote_device: Fix a bunch of doc-rot issues 2021-03-18 23:41:07 -04:00
remote_device.h scsi: libsas: aic94xx: hisi_sas: mvsas: pm8001: Use dev_is_expander() 2019-06-20 15:37:02 -04:00
remote_node_context.c scsi: isci: remote_node_context: Demote kernel-doc abuse 2021-03-18 23:41:08 -04:00
remote_node_context.h
remote_node_table.c scsi: isci: remote_node_table: Provide some missing params and remove others 2021-03-18 23:41:08 -04:00
remote_node_table.h scsi: isci: Fix a typo in a comment 2020-10-07 23:50:04 -04:00
request.c scsi: libsas: Introduce more SAM status code aliases in enum exec_status 2021-06-02 16:10:46 -04:00
request.h
sas.h scsi: Replace zero-length array with flexible-array member 2020-03-11 23:07:56 -04:00
scu_completion_codes.h
scu_event_codes.h
scu_remote_node_context.h
scu_task_context.h
task.c scsi: libsas: Introduce more SAM status code aliases in enum exec_status 2021-06-02 16:10:46 -04:00
task.h
unsolicited_frame_control.c
unsolicited_frame_control.h