linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: bugzilla-daemon@bugzilla.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [Bug 88591] New: SCSI_IOCTL_GET_IDLUN only returns 8 bits for the SCSI Target value
Date: Thu, 20 Nov 2014 16:01:15 -0500	[thread overview]
Message-ID: <546E569B.60906@interlog.com> (raw)
In-Reply-To: <bug-88591-11613@https.bugzilla.kernel.org/>

On 14-11-20 12:55 PM, bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=88591
>
>              Bug ID: 88591
>             Summary: SCSI_IOCTL_GET_IDLUN only returns 8 bits for the SCSI
>                      Target value
>             Product: SCSI Drivers
>             Version: 2.5
>      Kernel Version: 3.14.22
>            Hardware: All
>                  OS: Linux
>                Tree: Mainline
>              Status: NEW
>            Severity: normal
>            Priority: P1
>           Component: Other
>            Assignee: scsi_drivers-other@kernel-bugs.osdl.org
>            Reporter: kg6esx@gmail.com
>          Regression: No
>

If that ioctl has not been deprecated, it should be. Fixing
it would likely break existing apps so I doubt that will
happen. Introducing new ioctls is discouraged.

Also the 8 bit LUN "feature" with this ioctl was documented
over 10 years ago, about the time that a new ioctl was proposed
to address this issue.


The answer is to use sysfs. Now you would think sysfs would
have a pseudo file called "lun" in some obvious place that
would contain the 64 bit LUN value in binary, hex or decimal.
Even better would be a string of eight bytes to match T10's
LUN representation.
No, that would be too simple.

One way to find a file descriptor's LUN is to use stat() to
get its major and minor device numbers. For example if you had
opened /dev/sde that would usually be 8,64 . Then go searching in
sysfs for a "dev" file that contains "8,64" ***, then look at
the real path of the match (i.e. without any symlinks).
That real path might be:
   /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:4/block/sde/dev

Back up that real path until you find /<h>:<c>:<t>:<l>/ and
there is your LUN: <l>
That would be "4" for the path show above.


As you may have noticed sysfs is a pretty bad mechanism
for answering this type of question, compared to an ioctl.

Doug Gilbert


*** the details of the search differ depending on whether the
     driver is bsg, sg, sd, st, ses ....

BTW Thanks to udev, just because a disk is known as /dev/sde
     in the user space, doesn't mean that the kernel (and
     sysfs) will know it as "sde", it could be "sdg". That is
     the reason for searching with major,minor numbers rather
     than its name.

  reply	other threads:[~2014-11-20 21:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 17:55 [Bug 88591] New: SCSI_IOCTL_GET_IDLUN only returns 8 bits for the SCSI Target value bugzilla-daemon
2014-11-20 21:01 ` Douglas Gilbert [this message]
2014-11-20 21:08 ` [Bug 88591] " bugzilla-daemon
2014-11-21  8:39 ` bugzilla-daemon
2014-12-08 21:34 ` 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=546E569B.60906@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=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;
as well as URLs for NNTP newsgroup(s).