linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Mansfield <patmans@us.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH RFC] use struct scsi_lun in generic code
Date: Mon, 24 Oct 2005 08:27:30 -0700	[thread overview]
Message-ID: <20051024152730.GA28341@us.ibm.com> (raw)
In-Reply-To: <20051023043301.GA22615@havoc.gtf.org>

Nice work Jeff ...

On Sun, Oct 23, 2005 at 12:33:01AM -0400, Jeff Garzik wrote:

> * export scsilun_to_int()
> 
> * create scsilun_to_str() helper

> -	if (sdev->scsi_level <= SCSI_2)
> +	if (sdev->scsi_level <= SCSI_2) {
> +		unsigned int tmp_lun = scsilun_to_int(&sdev->lun);
>  		scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
> -			(sdev->lun << 5 & 0xe0);
> +			(tmp_lun << 5 & 0xe0);
> +	}

Why convert the lun value for every IO? Not efficient here and in the
driver code.

Instead call scsilun_to_int once per sdev, and store the value in
sdev->lun, sort of like James earlier patch, but only do so based on a
shost->opaque_lun_value or better if we could call a transport function
once to setup sdev->lun as needed by the driver, except we have transports
that include drivers/HBA's that use different sized LUNs.

Then struct scsi_lun has to be a u64 or another sXXX_lun(XXX).

>  	snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
> -		 "%d:%d:%d:%d", sdev->host->host_no,
> -		 sdev_channel(sdev), sdev_id(sdev), sdev->lun);
> +		 "%d:%d:%d:%s", sdev->host->host_no,
> +		 sdev_channel(sdev), sdev_id(sdev),
> +		scsilun_to_str(sdev, lunstr));

BUS_ID_SIZE is KOBJ_NAME_LEN is still 20. I thought we were moving to hex
for the bus_id value?

> +static inline char *scsilun_to_str(struct scsi_device *sdev, char *s)
> +{
> +	sprintf(s, "%d", scsilun_to_int(&sdev->lun));
> +	return s;

And format the LUN output based on the shost->opaque_luns. IMO for
!opaque_lun_value print LUN in the same order as today, else print 8 byte
hex string.

Some (probably most) users of drivers/transports with 8 byte LUN support
will be confused one way or another. Yes, most will expect to see 1 for
LUN 0001000000000000. We can't always display the LUN the same as used by
storage vendors in their setup/administration tools.

Perhaps base parsing of user space LUN values on the shost->opaque_lun_value,
I don't know how we can support 8 byte LUNs from user space and be
backwards compatible without adding another attribute or interface.

Note that current SAM (sam4r02) sort of allows for different sized LUNs,
it says "A logical unit number shall contain 64 bits or 16 bits, with the
size being defined by the SCSI transport protocol.  For SCSI transport
protocols that define 16-bit logical unit numbers, the two bytes shall be
formatted as described for the FIRST LEVEL ADDRESSING field (see table 5
in 4.9.5)."

-- Patrick Mansfield

  parent reply	other threads:[~2005-10-24 22:02 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
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 ` Patrick Mansfield [this message]
2005-10-24 22:40   ` [PATCH RFC] use struct scsi_lun in generic code 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=20051024152730.GA28341@us.ibm.com \
    --to=patmans@us.ibm.com \
    --cc=jgarzik@pobox.com \
    --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).