Skip to content

Commit

Permalink
scsi_scan: Restrict sequential scan to 256 LUNs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hannes Reinecke authored and Christoph Hellwig committed Jul 17, 2014
1 parent c309b35 commit 22ffeb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/scsi/scsi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,12 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
if (scsi_level < SCSI_3 && !(bflags & BLIST_LARGELUN))
max_dev_lun = min(8U, max_dev_lun);

/*
* Stop scanning at 255 unless BLIST_SCSI3LUN
*/
if (!(bflags & BLIST_SCSI3LUN))
max_dev_lun = min(256U, max_dev_lun);

/*
* We have already scanned LUN 0, so start at LUN 1. Keep scanning
* until we reach the max, or no LUN is found and we are not
Expand Down
2 changes: 2 additions & 0 deletions include/scsi/scsi_devinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@
#define BLIST_ATTACH_PQ3 0x1000000 /* Scan: Attach to PQ3 devices */
#define BLIST_NO_DIF 0x2000000 /* Disable T10 PI (DIF) */
#define BLIST_SKIP_VPD_PAGES 0x4000000 /* Ignore SBC-3 VPD pages */
#define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
for sequential scan */
#endif

0 comments on commit 22ffeb4

Please sign in to comment.