--- /dev/null
+From 4cd83ecdac20d30725b4f96e5d7814a1e290bc7e Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:26 -0700
+Subject: Drivers: scsi: storvsc: Change the limits to reflect the values on the host
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit 4cd83ecdac20d30725b4f96e5d7814a1e290bc7e upstream.
+
+Hyper-V hosts can support multiple targets and multiple channels and larger number of
+LUNs per target. Update the code to reflect this. With this patch we can correctly
+enumerate all the paths in a multi-path storage environment.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 51 +++++++++++++++++++++++++++++----------------
+ 1 file changed, 33 insertions(+), 18 deletions(-)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -331,17 +331,17 @@ static int storvsc_timeout = 180;
+
+ static void storvsc_on_channel_callback(void *context);
+
+-/*
+- * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
+- * reality, the path/target is not used (ie always set to 0) so our
+- * scsi host adapter essentially has 1 bus with 1 target that contains
+- * up to 256 luns.
+- */
+-#define STORVSC_MAX_LUNS_PER_TARGET 64
+-#define STORVSC_MAX_TARGETS 1
+-#define STORVSC_MAX_CHANNELS 1
+-
+-
++#define STORVSC_MAX_LUNS_PER_TARGET 255
++#define STORVSC_MAX_TARGETS 2
++#define STORVSC_MAX_CHANNELS 8
++
++#define STORVSC_FC_MAX_LUNS_PER_TARGET 255
++#define STORVSC_FC_MAX_TARGETS 128
++#define STORVSC_FC_MAX_CHANNELS 8
++
++#define STORVSC_IDE_MAX_LUNS_PER_TARGET 64
++#define STORVSC_IDE_MAX_TARGETS 1
++#define STORVSC_IDE_MAX_CHANNELS 1
+
+ struct storvsc_cmd_request {
+ struct list_head entry;
+@@ -1713,7 +1713,6 @@ static struct scsi_host_template scsi_dr
+ .slave_destroy = storvsc_device_destroy,
+ .slave_configure = storvsc_device_configure,
+ .cmd_per_lun = 1,
+- /* 64 max_queue * 1 target */
+ .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
+ .this_id = -1,
+ /* no use setting to 0 since ll_blk_rw reset it to 1 */
+@@ -1778,6 +1777,9 @@ static int storvsc_probe(struct hv_devic
+ }
+
+
++ if (dev_id->driver_data == SFC_GUID)
++ scsi_driver.can_queue = (STORVSC_MAX_IO_REQUESTS *
++ STORVSC_FC_MAX_TARGETS);
+ host = scsi_host_alloc(&scsi_driver,
+ sizeof(struct hv_host_device));
+ if (!host)
+@@ -1811,12 +1813,25 @@ static int storvsc_probe(struct hv_devic
+ host_dev->path = stor_device->path_id;
+ host_dev->target = stor_device->target_id;
+
+- /* max # of devices per target */
+- host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
+- /* max # of targets per channel */
+- host->max_id = STORVSC_MAX_TARGETS;
+- /* max # of channels */
+- host->max_channel = STORVSC_MAX_CHANNELS - 1;
++ switch (dev_id->driver_data) {
++ case SFC_GUID:
++ host->max_lun = STORVSC_FC_MAX_LUNS_PER_TARGET;
++ host->max_id = STORVSC_FC_MAX_TARGETS;
++ host->max_channel = STORVSC_FC_MAX_CHANNELS - 1;
++ break;
++
++ case SCSI_GUID:
++ host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
++ host->max_id = STORVSC_MAX_TARGETS;
++ host->max_channel = STORVSC_MAX_CHANNELS - 1;
++ break;
++
++ default:
++ host->max_lun = STORVSC_IDE_MAX_LUNS_PER_TARGET;
++ host->max_id = STORVSC_IDE_MAX_TARGETS;
++ host->max_channel = STORVSC_IDE_MAX_CHANNELS - 1;
++ break;
++ }
+ /* max cmd length */
+ host->max_cmd_len = STORVSC_MAX_CMD_LEN;
+
--- /dev/null
+From 3533f8603d28b77c62d75ec899449a99bc6b77a1 Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:32 -0700
+Subject: drivers: scsi: storvsc: Correctly handle TEST_UNIT_READY failure
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit 3533f8603d28b77c62d75ec899449a99bc6b77a1 upstream.
+
+On some Windows hosts on FC SANs, TEST_UNIT_READY can return SRB_STATUS_ERROR.
+Correctly handle this. Note that there is sufficient sense information to
+support scsi error handling even in this case.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -1018,6 +1018,13 @@ static void storvsc_handle_error(struct
+ case ATA_12:
+ set_host_byte(scmnd, DID_PASSTHROUGH);
+ break;
++ /*
++ * On Some Windows hosts TEST_UNIT_READY command can return
++ * SRB_STATUS_ERROR, let the upper level code deal with it
++ * based on the sense information.
++ */
++ case TEST_UNIT_READY:
++ break;
+ default:
+ set_host_byte(scmnd, DID_TARGET_FAILURE);
+ }
--- /dev/null
+From 8caf92d80526f3d7cc96831ec18b384ebcaccdf0 Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:28 -0700
+Subject: Drivers: scsi: storvsc: Filter commands based on the storage protocol version
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit 8caf92d80526f3d7cc96831ec18b384ebcaccdf0 upstream.
+
+Going forward it is possible that some of the commands that are not currently
+implemented will be implemented on future Windows hosts. Even if they are not
+implemented, we are told the host will corrrectly handle unsupported
+commands (by returning appropriate return code and sense information).
+Make command filtering depend on the host version.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -1564,9 +1564,19 @@ static int storvsc_queuecommand(struct S
+ struct vmscsi_request *vm_srb;
+ struct stor_mem_pools *memp = scmnd->device->hostdata;
+
+- if (!storvsc_scsi_cmd_ok(scmnd)) {
+- scmnd->scsi_done(scmnd);
+- return 0;
++ if (vmstor_current_major <= VMSTOR_WIN8_MAJOR) {
++ /*
++ * On legacy hosts filter unimplemented commands.
++ * Future hosts are expected to correctly handle
++ * unsupported commands. Furthermore, it is
++ * possible that some of the currently
++ * unsupported commands maybe supported in
++ * future versions of the host.
++ */
++ if (!storvsc_scsi_cmd_ok(scmnd)) {
++ scmnd->scsi_done(scmnd);
++ return 0;
++ }
+ }
+
+ request_size = sizeof(struct storvsc_cmd_request);
--- /dev/null
+From adb6f9e1a8c6af1037232b59edb11277471537ea Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:29 -0700
+Subject: Drivers: scsi: storvsc: Fix a bug in handling VMBUS protocol version
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit adb6f9e1a8c6af1037232b59edb11277471537ea upstream.
+
+Based on the negotiated VMBUS protocol version, we adjust the size of the storage
+protocol messages. The two sizes we currently handle are pre-win8 and post-win8.
+In WS2012 R2, we are negotiating higher VMBUS protocol version than the win8
+version. Make adjustments to correctly handle this.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -1764,19 +1764,22 @@ static int storvsc_probe(struct hv_devic
+ * set state to properly communicate with the host.
+ */
+
+- if (vmbus_proto_version == VERSION_WIN8) {
+- sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
+- vmscsi_size_delta = 0;
+- vmstor_current_major = VMSTOR_WIN8_MAJOR;
+- vmstor_current_minor = VMSTOR_WIN8_MINOR;
+- } else {
++ switch (vmbus_proto_version) {
++ case VERSION_WS2008:
++ case VERSION_WIN7:
+ sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
+ vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
+ vmstor_current_major = VMSTOR_WIN7_MAJOR;
+ vmstor_current_minor = VMSTOR_WIN7_MINOR;
++ break;
++ default:
++ sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
++ vmscsi_size_delta = 0;
++ vmstor_current_major = VMSTOR_WIN8_MAJOR;
++ vmstor_current_minor = VMSTOR_WIN8_MINOR;
++ break;
+ }
+
+-
+ if (dev_id->driver_data == SFC_GUID)
+ scsi_driver.can_queue = (STORVSC_MAX_IO_REQUESTS *
+ STORVSC_FC_MAX_TARGETS);
--- /dev/null
+From 52f9614dd8294e95d2c0929c2d4f64b077ae486f Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:27 -0700
+Subject: Drivers: scsi: storvsc: Set cmd_per_lun to reflect value supported by the Host
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit 52f9614dd8294e95d2c0929c2d4f64b077ae486f upstream.
+
+Set cmd_per_lun to reflect value supported by the Host.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -1712,7 +1712,7 @@ static struct scsi_host_template scsi_dr
+ .slave_alloc = storvsc_device_alloc,
+ .slave_destroy = storvsc_device_destroy,
+ .slave_configure = storvsc_device_configure,
+- .cmd_per_lun = 1,
++ .cmd_per_lun = 255,
+ .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
+ .this_id = -1,
+ /* no use setting to 0 since ll_blk_rw reset it to 1 */
--- /dev/null
+From f885fb73f64154690c2158e813de56363389ffec Mon Sep 17 00:00:00 2001
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+Date: Sat, 12 Jul 2014 09:48:31 -0700
+Subject: drivers: scsi: storvsc: Set srb_flags in all cases
+
+From: "K. Y. Srinivasan" <kys@microsoft.com>
+
+commit f885fb73f64154690c2158e813de56363389ffec upstream.
+
+Correctly set SRB flags for all valid I/O directions. Some IHV drivers on the
+Windows host require this. The host validates the command and SRB flags
+prior to passing the command down to native driver stack.
+
+Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/storvsc_drv.c | 12 +++++-------
+ 1 file changed, 5 insertions(+), 7 deletions(-)
+
+--- a/drivers/scsi/storvsc_drv.c
++++ b/drivers/scsi/storvsc_drv.c
+@@ -1601,26 +1601,24 @@ static int storvsc_queuecommand(struct S
+ vm_srb = &cmd_request->vstor_packet.vm_srb;
+ vm_srb->win8_extension.time_out_value = 60;
+
++ vm_srb->win8_extension.srb_flags |=
++ (SRB_FLAGS_QUEUE_ACTION_ENABLE |
++ SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
+
+ /* Build the SRB */
+ switch (scmnd->sc_data_direction) {
+ case DMA_TO_DEVICE:
+ vm_srb->data_in = WRITE_TYPE;
+ vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_OUT;
+- vm_srb->win8_extension.srb_flags |=
+- (SRB_FLAGS_QUEUE_ACTION_ENABLE |
+- SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
+ break;
+ case DMA_FROM_DEVICE:
+ vm_srb->data_in = READ_TYPE;
+ vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_IN;
+- vm_srb->win8_extension.srb_flags |=
+- (SRB_FLAGS_QUEUE_ACTION_ENABLE |
+- SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
+ break;
+ default:
+ vm_srb->data_in = UNKNOWN_TYPE;
+- vm_srb->win8_extension.srb_flags = 0;
++ vm_srb->win8_extension.srb_flags |= (SRB_FLAGS_DATA_IN |
++ SRB_FLAGS_DATA_OUT);
+ break;
+ }
+
--- /dev/null
+From c1d40a527e885a40bb9ea6c46a1b1145d42b66a0 Mon Sep 17 00:00:00 2001
+From: "Martin K. Petersen" <martin.petersen@oracle.com>
+Date: Tue, 15 Jul 2014 12:49:17 -0400
+Subject: scsi: add a blacklist flag which enables VPD page inquiries
+
+From: "Martin K. Petersen" <martin.petersen@oracle.com>
+
+commit c1d40a527e885a40bb9ea6c46a1b1145d42b66a0 upstream.
+
+Despite supporting modern SCSI features some storage devices continue to
+claim conformance to an older version of the SPC spec. This is done for
+compatibility with legacy operating systems.
+
+Linux by default will not attempt to read VPD pages on devices that
+claim SPC-2 or older. Introduce a blacklist flag that can be used to
+trigger VPD page inquiries on devices that are known to support them.
+
+Reported-by: KY Srinivasan <kys@microsoft.com>
+Tested-by: KY Srinivasan <kys@microsoft.com>
+Reviewed-by: KY Srinivasan <kys@microsoft.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/scsi_scan.c | 4 +++-
+ drivers/scsi/sd.c | 5 +++++
+ include/scsi/scsi_device.h | 1 +
+ include/scsi/scsi_devinfo.h | 1 +
+ 4 files changed, 10 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/scsi_scan.c
++++ b/drivers/scsi/scsi_scan.c
+@@ -950,7 +950,9 @@ static int scsi_add_lun(struct scsi_devi
+
+ sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
+
+- if (*bflags & BLIST_SKIP_VPD_PAGES)
++ if (*bflags & BLIST_TRY_VPD_PAGES)
++ sdev->try_vpd_pages = 1;
++ else if (*bflags & BLIST_SKIP_VPD_PAGES)
+ sdev->skip_vpd_pages = 1;
+
+ transport_configure_device(&sdev->sdev_gendev);
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -2686,6 +2686,11 @@ static void sd_read_write_same(struct sc
+
+ static int sd_try_extended_inquiry(struct scsi_device *sdp)
+ {
++ /* Attempt VPD inquiry if the device blacklist explicitly calls
++ * for it.
++ */
++ if (sdp->try_vpd_pages)
++ return 1;
+ /*
+ * Although VPD inquiries can go to SCSI-2 type devices,
+ * some USB ones crash on receiving them, and the pages
+--- a/include/scsi/scsi_device.h
++++ b/include/scsi/scsi_device.h
+@@ -149,6 +149,7 @@ struct scsi_device {
+ unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
+ unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
+ unsigned skip_vpd_pages:1; /* do not read VPD pages */
++ unsigned try_vpd_pages:1; /* attempt to read VPD pages */
+ unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
+ unsigned no_start_on_add:1; /* do not issue start on add */
+ unsigned allow_restart:1; /* issue START_UNIT in error handler */
+--- a/include/scsi/scsi_devinfo.h
++++ b/include/scsi/scsi_devinfo.h
+@@ -34,4 +34,5 @@
+ #define BLIST_SKIP_VPD_PAGES 0x4000000 /* Ignore SBC-3 VPD pages */
+ #define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
+ for sequential scan */
++#define BLIST_TRY_VPD_PAGES 0x10000000 /* Attempt to read VPD pages */
+ #endif
--- /dev/null
+From 0213436a2cc5e4a5ca2fabfaa4d3877097f3b13f Mon Sep 17 00:00:00 2001
+From: Janusz Dziemidowicz <rraptorr@nails.eu.org>
+Date: Thu, 24 Jul 2014 15:48:46 +0200
+Subject: scsi: do not issue SCSI RSOC command to Promise Vtrak E610f
+
+From: Janusz Dziemidowicz <rraptorr@nails.eu.org>
+
+commit 0213436a2cc5e4a5ca2fabfaa4d3877097f3b13f upstream.
+
+Some devices don't like REPORT SUPPORTED OPERATION CODES and will
+simply timeout causing sd_mod init to take a very very long time.
+Introduce BLIST_NO_RSOC scsi scan flag, that stops RSOC from being
+issued. Add it to Promise Vtrak E610f entry in scsi scan
+blacklist. Fixes bug #79901 reported at
+https://bugzilla.kernel.org/show_bug.cgi?id=79901
+
+Fixes: 98dcc2946adb ("SCSI: sd: Update WRITE SAME heuristics")
+
+Signed-off-by: Janusz Dziemidowicz <rraptorr@nails.eu.org>
+Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/scsi_devinfo.c | 1 +
+ drivers/scsi/scsi_scan.c | 6 ++++++
+ include/scsi/scsi_devinfo.h | 2 ++
+ 3 files changed, 9 insertions(+)
+
+--- a/drivers/scsi/scsi_devinfo.c
++++ b/drivers/scsi/scsi_devinfo.c
+@@ -222,6 +222,7 @@ static struct {
+ {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+ {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+ {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
++ {"Promise", "VTrak E610f", NULL, BLIST_SPARSELUN | BLIST_NO_RSOC},
+ {"Promise", "", NULL, BLIST_SPARSELUN},
+ {"QUANTUM", "XP34301", "1071", BLIST_NOTQ},
+ {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
+--- a/drivers/scsi/scsi_scan.c
++++ b/drivers/scsi/scsi_scan.c
+@@ -922,6 +922,12 @@ static int scsi_add_lun(struct scsi_devi
+ if (*bflags & BLIST_USE_10_BYTE_MS)
+ sdev->use_10_for_ms = 1;
+
++ /* some devices don't like REPORT SUPPORTED OPERATION CODES
++ * and will simply timeout causing sd_mod init to take a very
++ * very long time */
++ if (*bflags & BLIST_NO_RSOC)
++ sdev->no_report_opcodes = 1;
++
+ /* set the device running here so that slave configure
+ * may do I/O */
+ ret = scsi_device_set_state(sdev, SDEV_RUNNING);
+--- a/include/scsi/scsi_devinfo.h
++++ b/include/scsi/scsi_devinfo.h
+@@ -35,4 +35,6 @@
+ #define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
+ for sequential scan */
+ #define BLIST_TRY_VPD_PAGES 0x10000000 /* Attempt to read VPD pages */
++#define BLIST_NO_RSOC 0x20000000 /* don't try to issue RSOC */
++
+ #endif
--- /dev/null
+From 22ffeb48b7584d6cd50f2a595ed6065d86a87459 Mon Sep 17 00:00:00 2001
+From: Hannes Reinecke <hare@suse.de>
+Date: Tue, 3 Jun 2014 10:58:53 +0200
+Subject: scsi_scan: Restrict sequential scan to 256 LUNs
+
+From: Hannes Reinecke <hare@suse.de>
+
+commit 22ffeb48b7584d6cd50f2a595ed6065d86a87459 upstream.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/scsi_scan.c | 6 ++++++
+ include/scsi/scsi_devinfo.h | 2 ++
+ 2 files changed, 8 insertions(+)
+
+--- a/drivers/scsi/scsi_scan.c
++++ b/drivers/scsi/scsi_scan.c
+@@ -1236,6 +1236,12 @@ static void scsi_sequential_lun_scan(str
+ 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
+ * sparse_lun.
+--- a/include/scsi/scsi_devinfo.h
++++ b/include/scsi/scsi_devinfo.h
+@@ -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
--- /dev/null
+From cd53eb686d2418eda938aad3c9da42b7dfa9351f Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+Date: Wed, 9 Jul 2014 15:56:43 +0200
+Subject: scsi_transport_srp: Fix fast_io_fail_tmo=dev_loss_tmo=off behavior
+
+From: Bart Van Assche <bvanassche@acm.org>
+
+commit cd53eb686d2418eda938aad3c9da42b7dfa9351f upstream.
+
+If scsi_remove_host() is called while an rport is in the blocked state
+then scsi_remove_host() will only finish if the rport is unblocked
+from inside a timer function. Make sure that an rport only enters the
+blocked state if a timer will be started that will unblock it. This
+avoids that unloading the ib_srp kernel module after having
+disconnected the initiator from the target system results in a
+deadlock if both the fast_io_fail_tmo and dev_loss_tmo parameters have
+been set to "off".
+
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
+Reviewed-by: David Dillow <dave@thedillows.org>
+Signed-off-by: Roland Dreier <roland@purestorage.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/scsi/scsi_transport_srp.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/scsi_transport_srp.c
++++ b/drivers/scsi/scsi_transport_srp.c
+@@ -473,7 +473,8 @@ static void __srp_start_tl_fail_timers(s
+ if (delay > 0)
+ queue_delayed_work(system_long_wq, &rport->reconnect_work,
+ 1UL * delay * HZ);
+- if (srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {
++ if ((fast_io_fail_tmo >= 0 || dev_loss_tmo >= 0) &&
++ srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {
+ pr_debug("%s new state: %d\n", dev_name(&shost->shost_gendev),
+ rport->state);
+ scsi_target_block(&shost->shost_gendev);
powerpc-thp-invalidate-with-vpn-in-loop.patch
powerpc-thp-use-access_once-when-loading-pmdp.patch
drivers-scsi-storvsc-implement-a-eh_timed_out-handler.patch
+drivers-scsi-storvsc-filter-commands-based-on-the-storage-protocol-version.patch
+drivers-scsi-storvsc-change-the-limits-to-reflect-the-values-on-the-host.patch
+drivers-scsi-storvsc-set-cmd_per_lun-to-reflect-value-supported-by-the-host.patch
+drivers-scsi-storvsc-fix-a-bug-in-handling-vmbus-protocol-version.patch
+drivers-scsi-storvsc-set-srb_flags-in-all-cases.patch
+drivers-scsi-storvsc-correctly-handle-test_unit_ready-failure.patch
+scsi_scan-restrict-sequential-scan-to-256-luns.patch
+scsi-add-a-blacklist-flag-which-enables-vpd-page-inquiries.patch
+scsi-do-not-issue-scsi-rsoc-command-to-promise-vtrak-e610f.patch
+scsi_transport_srp-fix-fast_io_fail_tmo-dev_loss_tmo-off-behavior.patch