Commit 22ffeb48b7584d6cd50f2a595ed6065d86a87459

Authored by Hannes Reinecke
Committed by Christoph Hellwig
1 parent c309b35171

scsi_scan: Restrict sequential scan to 256 LUNs

Sequential scan for more than 256 LUNs is very fragile as
LUNs might not be numbered sequentially after that point.

SAM revisions later than SCSI-3 impose a structure on
LUNs larger than 256, making LUN numbers between 256
and 16384 illegal.
SCSI-3, however allows for plain 64-bit numbers with
no internal structure.

So restrict sequential LUN scan to 256 LUNs and add a
new blacklist flag 'BLIST_SCSI3LUN' to scan up to
max_lun devices.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>

Showing 2 changed files with 8 additions and 0 deletions Side-by-side Diff

drivers/scsi/scsi_scan.c
... ... @@ -1235,6 +1235,12 @@
1235 1235 max_dev_lun = min(8U, max_dev_lun);
1236 1236  
1237 1237 /*
  1238 + * Stop scanning at 255 unless BLIST_SCSI3LUN
  1239 + */
  1240 + if (!(bflags & BLIST_SCSI3LUN))
  1241 + max_dev_lun = min(256U, max_dev_lun);
  1242 +
  1243 + /*
1238 1244 * We have already scanned LUN 0, so start at LUN 1. Keep scanning
1239 1245 * until we reach the max, or no LUN is found and we are not
1240 1246 * sparse_lun.
include/scsi/scsi_devinfo.h
... ... @@ -32,5 +32,7 @@
32 32 #define BLIST_ATTACH_PQ3 0x1000000 /* Scan: Attach to PQ3 devices */
33 33 #define BLIST_NO_DIF 0x2000000 /* Disable T10 PI (DIF) */
34 34 #define BLIST_SKIP_VPD_PAGES 0x4000000 /* Ignore SBC-3 VPD pages */
  35 +#define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
  36 + for sequential scan */
35 37 #endif