public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@bugzilla.kernel.org
To: linux-scsi@vger.kernel.org
Subject: [Bug 80711] [PATCH]SG_FLAG_LUN_INHIBIT is no longer implemented and there's not way to prevent the kernel from using the 2nd cdb byte for the LUN
Date: Thu, 21 Aug 2014 17:31:37 +0000	[thread overview]
Message-ID: <bug-80711-11613-bgFXMG8ykw@https.bugzilla.kernel.org/> (raw)
In-Reply-To: <bug-80711-11613@https.bugzilla.kernel.org/>

https://bugzilla.kernel.org/show_bug.cgi?id=80711

--- Comment #12 from Alan Stern <stern@rowland.harvard.edu> ---
On Thu, 21 Aug 2014, Christoph Hellwig wrote:

> On Thu, Aug 21, 2014 at 10:41:02AM -0400, Douglas Gilbert wrote:
> > Perhaps we could add another bit flag in struct
> > scsi_host_template such as:
> >     unsigned int transport_says_dont_scsi2_lun_cmd:1;
> > 
> > then drivers/usb/storage/scsiglue.c could set that
> > bit in its usb_stor_host_template and
> > drivers/scsi/scsi.c could take heed (and not mask
> > cmd->cmnd[1] with the LUN).
> 
> Fully agreed.
> 
> (except that I'd shorten the flag name to .no_scsi2lun :))

Okay, here's a patch that implements the suggestion, except that I put
the flag in the Scsi_Host structure instead of the template.  This was
to minimize the impact of the change.  Among the various SCSI-over-USB
transports, only the Bulk-Only transport gives the LUN separately from
the CDB.  I don't know if there are any multi-LUN USB devices that
don't use the Bulk-Only transport, but if there are then they won't 
work if the LUN isn't stored in CDB[1].

Tiziano, does this do what you want?

Alan Stern



Index: usb-3.16/include/scsi/scsi_host.h
===================================================================
--- usb-3.16.orig/include/scsi/scsi_host.h
+++ usb-3.16/include/scsi/scsi_host.h
@@ -695,6 +695,9 @@ struct Scsi_Host {
     /* The controller does not support WRITE SAME */
     unsigned no_write_same:1;

+    /* The transport requires the LUN bits NOT to be stored in CDB[1] */
+    unsigned no_scsi2_lun:1;
+
     /*
      * Optional work queue to be utilized by the transport
      */
Index: usb-3.16/drivers/scsi/scsi.c
===================================================================
--- usb-3.16.orig/drivers/scsi/scsi.c
+++ usb-3.16/drivers/scsi/scsi.c
@@ -678,7 +678,8 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
      * If SCSI-2 or lower, store the LUN value in cmnd.
      */
     if (cmd->device->scsi_level <= SCSI_2 &&
-        cmd->device->scsi_level != SCSI_UNKNOWN) {
+        cmd->device->scsi_level != SCSI_UNKNOWN &&
+        !host->no_scsi2_lun) {
         cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
                    (cmd->device->lun << 5 & 0xe0);
     }
Index: usb-3.16/drivers/usb/storage/usb.c
===================================================================
--- usb-3.16.orig/drivers/usb/storage/usb.c
+++ usb-3.16/drivers/usb/storage/usb.c
@@ -981,6 +981,14 @@ int usb_stor_probe2(struct us_data *us)
     if (!(us->fflags & US_FL_SCM_MULT_TARG))
         us_to_host(us)->max_id = 1;

+    /*
+     * Like Windows, we won't store the LUN bits in CDB[1] for SCSI-2
+     * devices using the Bulk-Only transport (even though this violates
+     * the SCSI spec).
+     */
+    if (us->transport == usb_stor_Bulk_transport)
+        us_to_host(us)->no_scsi2_lun = 1;
+
     /* Find the endpoints and calculate pipe values */
     result = get_pipes(us);
     if (result)

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2014-08-21 17:31 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-20  0:37 [Bug 80711] New: SG_FLAG_LUN_INHIBIT is no longer implemented and there's not way to prevent the kernel from using the 2nd cdb byte for the LUN bugzilla-daemon
2014-07-20 14:13 ` [Bug 80711] " bugzilla-daemon
2014-07-21  9:05 ` bugzilla-daemon
2014-07-22 16:13   ` Christoph Hellwig
2014-07-29 15:57 ` [Bug 80711] [PATCH]SG_FLAG_LUN_INHIBIT " bugzilla-daemon
2014-08-06 13:29   ` Douglas Gilbert
2014-08-06 19:32     ` Christoph Hellwig
2014-08-06 20:02       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.1408061545030.1145-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-08-06 20:25           ` Alan Stern
2014-08-07  6:39         ` Christoph Hellwig
2014-08-07 15:58           ` Alan Stern
2014-08-19 17:56             ` Christoph Hellwig
2014-08-20 19:15               ` Alan Stern
     [not found]                 ` <Pine.LNX.4.44L0.1408201507280.1959-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-08-21 14:41                   ` Douglas Gilbert
2014-08-21 14:42                     ` Christoph Hellwig
2014-08-21 17:31                       ` Alan Stern
2014-08-21 21:43                         ` Martin K. Petersen
2014-08-21 21:57                           ` Christoph Hellwig
     [not found]                             ` <20140821215744.GA29651-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-08-22 14:53                               ` Alan Stern
     [not found]                                 ` <Pine.LNX.4.44L0.1408221044450.967-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-08-22 15:05                                   ` Christoph Hellwig
     [not found]                                     ` <20140822150508.GA1321-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-08-22 15:26                                       ` Alan Stern
2014-08-22 15:08                                 ` Martin K. Petersen
2014-08-22 15:39                                 ` James Bottomley
2014-08-22 17:29                                   ` Alan Stern
     [not found]                                     ` <Pine.LNX.4.44L0.1408221249360.967-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-08-24 15:04                                       ` Christoph Hellwig
2014-08-25 14:44                                         ` Alan Stern
2014-08-25 19:39                                           ` James Bottomley
     [not found]                                             ` <1408995547.3629.7.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2014-08-25 20:12                                               ` Alan Stern
     [not found]                                                 ` <Pine.LNX.4.44L0.1408251545580.1385-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-08-25 21:19                                                   ` Alan Stern
2014-08-25 21:30                                                     ` James Bottomley
2014-08-06 13:37 ` bugzilla-daemon
2014-08-06 20:09 ` bugzilla-daemon
2014-08-06 20:25 ` bugzilla-daemon
2014-08-06 21:16 ` bugzilla-daemon
2014-08-07 15:58 ` bugzilla-daemon
2014-08-07 16:10 ` bugzilla-daemon
2014-08-20 19:15 ` bugzilla-daemon
2014-08-21 14:41 ` bugzilla-daemon
2014-08-21 17:31 ` bugzilla-daemon [this message]
2014-08-21 21:43 ` bugzilla-daemon
2014-08-22 14:53 ` bugzilla-daemon
2014-08-22 15:08 ` bugzilla-daemon
2014-08-22 15:26 ` bugzilla-daemon
2014-08-22 17:29 ` bugzilla-daemon
2014-08-25 14:44 ` bugzilla-daemon
2014-08-25 20:12 ` bugzilla-daemon
2014-08-25 21:19 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-80711-11613-bgFXMG8ykw@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@bugzilla.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox