[PATCH] USB Storage: Force starget->scsi_level in usb-storage scsiglue.c

When the usb-storage module forces sdev->scsi_level to SCSI_2, it should
also force starget->scsi_level to the same value. Otherwise, the SCSI
layer may attempt to issue SCSI-3 commands to the device, such as REPORT
LUNS, which it cannot handle. This can prevent the device from working
with Linux.

The AMS Venus DS3 DS2316SU2S SATA-to-SATA+USB enclosure, based on the
Oxford Semiconductor OXU921S chip, requires this patch to function
correctly on Linux. The enclosure reports a SCSI-3 SPC-2 command set
level, but does not correctly handle the REPORT LUNS SCSI command -
probably due to a bug in its firmware.

It seems likely that other USB storage enclosures with similar bugs will
also benefit from this patch.

Tony Lindgren <tony@atomide.com> collaborated in the development of this
patch.

Signed-off-by: Paul Walmsley <paul@booyaka.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Paul Walmsley and committed by Linus Torvalds 28120be5 23f9b317

+2 -2
+2 -2
drivers/usb/storage/scsiglue.c
··· 109 109 * data comes from. 110 110 */ 111 111 if (sdev->scsi_level < SCSI_2) 112 - sdev->scsi_level = SCSI_2; 112 + sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2; 113 113 114 114 /* According to the technical support people at Genesys Logic, 115 115 * devices using their chips have problems transferring more than ··· 162 162 * a Get-Max-LUN request, we won't lose much by setting the 163 163 * revision level down to 2. The only devices that would be 164 164 * affected are those with sparse LUNs. */ 165 - sdev->scsi_level = SCSI_2; 165 + sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2; 166 166 167 167 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable 168 168 * Hardware Error) when any low-level error occurs,