]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.16.3/scsi_scan-restrict-sequential-scan-to-256-luns.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / scsi_scan-restrict-sequential-scan-to-256-luns.patch
CommitLineData
033b5a72
GKH
1From 22ffeb48b7584d6cd50f2a595ed6065d86a87459 Mon Sep 17 00:00:00 2001
2From: Hannes Reinecke <hare@suse.de>
3Date: Tue, 3 Jun 2014 10:58:53 +0200
4Subject: scsi_scan: Restrict sequential scan to 256 LUNs
5
6From: Hannes Reinecke <hare@suse.de>
7
8commit 22ffeb48b7584d6cd50f2a595ed6065d86a87459 upstream.
9
10Sequential scan for more than 256 LUNs is very fragile as
11LUNs might not be numbered sequentially after that point.
12
13SAM revisions later than SCSI-3 impose a structure on
14LUNs larger than 256, making LUN numbers between 256
15and 16384 illegal.
16SCSI-3, however allows for plain 64-bit numbers with
17no internal structure.
18
19So restrict sequential LUN scan to 256 LUNs and add a
20new blacklist flag 'BLIST_SCSI3LUN' to scan up to
21max_lun devices.
22
23Signed-off-by: Hannes Reinecke <hare@suse.de>
24Reviewed-by: Ewan Milne <emilne@redhat.com>
25Signed-off-by: Christoph Hellwig <hch@lst.de>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28---
29 drivers/scsi/scsi_scan.c | 6 ++++++
30 include/scsi/scsi_devinfo.h | 2 ++
31 2 files changed, 8 insertions(+)
32
33--- a/drivers/scsi/scsi_scan.c
34+++ b/drivers/scsi/scsi_scan.c
35@@ -1239,6 +1239,12 @@ static void scsi_sequential_lun_scan(str
36 max_dev_lun = min(8U, max_dev_lun);
37
38 /*
39+ * Stop scanning at 255 unless BLIST_SCSI3LUN
40+ */
41+ if (!(bflags & BLIST_SCSI3LUN))
42+ max_dev_lun = min(256U, max_dev_lun);
43+
44+ /*
45 * We have already scanned LUN 0, so start at LUN 1. Keep scanning
46 * until we reach the max, or no LUN is found and we are not
47 * sparse_lun.
48--- a/include/scsi/scsi_devinfo.h
49+++ b/include/scsi/scsi_devinfo.h
50@@ -32,4 +32,6 @@
51 #define BLIST_ATTACH_PQ3 0x1000000 /* Scan: Attach to PQ3 devices */
52 #define BLIST_NO_DIF 0x2000000 /* Disable T10 PI (DIF) */
53 #define BLIST_SKIP_VPD_PAGES 0x4000000 /* Ignore SBC-3 VPD pages */
54+#define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
55+ for sequential scan */
56 #endif