From: Douglas Gilbert <dougg@torque.net>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: linux-scsi@vger.kernel.org,
Luben Tuikov <luben_tuikov@adaptec.com>,
Jeff Garzik <jgarzik@pobox.com>
Subject: Re: [PATCH RFC] more struct scsi_lun
Date: Tue, 25 Oct 2005 08:27:04 +1000 [thread overview]
Message-ID: <435D5FB8.7000407@torque.net> (raw)
In-Reply-To: <435D3E07.5050709@s5r6.in-berlin.de>
Stefan Richter wrote:
> Luben Tuikov wrote:
>
>> On 10/23/05 12:49, Jeff Garzik wrote:
>>
>>> Stefan Richter wrote:
>>>
>>>> sprintf(s+2*i, "%02x", lun.scsi_lun[i]);
>>>
>>>
>>> There is obviously room for improvement. Any naive representation is
>>> sub-optimal, be it for small luns (my current code) or larger luns
>>> (your example).
>>>
>>> For situations with smaller luns, we should probably continue to use
>>> the current scsilun_to_int() conversion, while using your example for
>>> larger luns, i.e.
>>>
>>> if (upper 4 bytes zero)
>>> scsilun to int
>>> printk %d
>>> else
>>> for each byte
>>> printk %x
>>>
>>> But Douglas's code suggested that if we are more motivated, we could
>>> provide an even better representation.
>
>
> A plain, non-interpreted representation should suffice. Compact but
> easily parseable, i.e. uniform.
>
>> If a LUN is u8[8], then,
>>
>> #define SAS_ADDR(_sa) ((unsigned long long) be64_to_cpu(*(__be64
>> *)(_sa)))
>>
>> "%016llx", SAS_ADDR(LUN) prints it like this (e.g.):
>>
>> sas: 5000c50000513329 probing LUN:0000000000000000
>> sas: device 500000e000031c12 LUN: 0000000000000000 powering up or not
>> ready yet, sleeping...
>> sas: 500000e000031c12 probing LUN:0000000000000000
>> sas: device 50001c171601060d LUN: 0000000000000000 powering up or not
>> ready yet, sleeping...
>>
>> This is from drivers/scsi/sas/sas_discover.c.
>>
>> Luben
>
>
> What about an 64bit integer as carrier of LUN in the first place? The
> most frequent occurrence of LUN data is when it is passed through in
> function calls but it seems rarely to be manipulated.
>
> --- linux/include/scsi/scsi.h.orig 2005-10-20 08:23:05.000000000 +0200
> +++ linux/include/scsi/scsi.h 2005-10-24 21:45:41.000000000 +0200
> @@ -238,9 +238,7 @@
> /*
> * ScsiLun: 8 byte LUN.
> */
> -struct scsi_lun {
> - __u8 scsi_lun[8];
> -};
> +typedef __be64 scsi_lun;
Stefan,
IMO it is very important to keep luns as __u8[8]. Lots
of different lun conventions map into that array, almost
all of which would look horrible viewed as hex or
decimal integers. For example SCSI-2 luns (embedded
in cbds) run from 0 to 7 and map (in hex) to:
00 00 00 00 00 00 00 00
00 07 00 00 00 00 00 00
Just like a SCSI cdb, to decode a lun, first one needs
to examine scsi_lun[0], then depending on ... . As
you are no doubt aware, the only current transport
defined to have 2 byte luns is sbp-2/sbp-3 and it is
obvious what those 2 bytes will be: scsi_lun[0] and
scsi_lun[1].
Generic target+initiator (port) identifiers in SAM
(see sam4r03.pdf Annex A) should also be a sequence of
bytes (not an integer). iSCSI seems to be the limiting
case with up to 241 (utf-8) bytes. Linux may want to keep
its enumerating "id" integer, in which case a mapping
should be visible (as SDI does).
Doug Gilbert
next prev parent reply other threads:[~2005-10-24 22:26 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-23 4:33 [PATCH RFC] use struct scsi_lun in generic code Jeff Garzik
2005-10-23 4:49 ` [PATCH RFC] more struct scsi_lun Jeff Garzik
2005-10-23 9:47 ` Stefan Richter
2005-10-23 13:14 ` Stefan Richter
2005-10-23 16:49 ` Jeff Garzik
2005-10-24 16:27 ` Luben Tuikov
2005-10-24 20:03 ` Stefan Richter
2005-10-24 20:10 ` Luben Tuikov
2005-10-24 20:28 ` Mark Rustad
2005-10-24 22:27 ` Douglas Gilbert [this message]
2005-10-23 5:20 ` [PATCH RFC] use struct scsi_lun in generic code Jeff Garzik
2005-10-23 5:22 ` Douglas Gilbert
2005-10-23 7:01 ` Jeff Garzik
2005-10-24 14:55 ` Luben Tuikov
2005-10-23 7:00 ` [PATCH RFC] yet more struct scsi_lun Jeff Garzik
2005-10-23 10:48 ` Douglas Gilbert
2005-10-23 11:53 ` Arjan van de Ven
2005-10-23 14:27 ` max_sectors [was Re: [PATCH RFC] yet more struct scsi_lun] Douglas Gilbert
2005-10-23 14:42 ` Arjan van de Ven
2005-10-23 16:44 ` [PATCH RFC] yet more struct scsi_lun Jeff Garzik
2005-10-23 16:43 ` Jeff Garzik
2005-10-23 18:53 ` Kai Makisara
2005-10-24 7:59 ` Jens Axboe
2005-10-28 17:24 ` Mike Christie
2005-10-31 10:24 ` Jens Axboe
2005-11-04 2:23 ` Mike Christie
2005-11-04 2:25 ` Mike Christie
2005-11-04 7:37 ` Jens Axboe
2005-11-04 17:27 ` Mike Christie
2005-10-23 7:16 ` [PATCH RFC] even " Jeff Garzik
2005-10-24 15:27 ` [PATCH RFC] use struct scsi_lun in generic code Patrick Mansfield
2005-10-24 22:40 ` Douglas Gilbert
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=435D5FB8.7000407@torque.net \
--to=dougg@torque.net \
--cc=jgarzik@pobox.com \
--cc=linux-scsi@vger.kernel.org \
--cc=luben_tuikov@adaptec.com \
--cc=stefanr@s5r6.in-berlin.de \
/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).