linux/drivers/scsi/libsas
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
..
Kconfig ata: make SATA_PMP option selectable only if any SATA host driver is enabled 2020-03-26 10:28:17 -06:00
Makefile
sas_ata.c scsi: libsas: Introduce more SAM status code aliases in enum exec_status 2021-06-02 16:10:46 -04:00
sas_discover.c scsi: libsas: Clean up whitespace 2021-04-06 00:50:17 -04:00
sas_event.c scsi: libsas: Remove temporarily-added _gfp() API variants 2021-01-22 21:31:10 -05:00
sas_expander.c scsi: libsas: Introduce more SAM status code aliases in enum exec_status 2021-06-02 16:10:46 -04:00
sas_host_smp.c
sas_init.c scsi: libsas: Remove temporarily-added _gfp() API variants 2021-01-22 21:31:10 -05:00
sas_internal.h scsi: libsas: Remove temporarily-added _gfp() API variants 2021-01-22 21:31:10 -05:00
sas_phy.c
sas_port.c scsi: libsas: Tidy SAS address print format 2019-12-21 13:42:42 -05:00
sas_scsi_host.c scsi: libsas: Add LUN number check in .slave_alloc callback 2021-06-22 21:33:33 -04:00
sas_task.c scsi: libsas: Introduce more SAM status code aliases in enum exec_status 2021-06-02 16:10:46 -04:00