All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dougg@torque.net>
To: Matthew Dharm <mdharm-scsi@one-eyed-alien.net>
Cc: Andries.Brouwer@cwi.nl, linux-scsi@vger.kernel.org,
	usb-storage@one-eyed-alien.net
Subject: Re: [usb-storage] Re: 2 PATCHES: fix request_tranferlength
Date: Tue, 30 Jul 2002 09:40:12 -0400	[thread overview]
Message-ID: <3D46973C.6641E9B2@torque.net> (raw)
In-Reply-To: 20020729222451.A2243@one-eyed-alien.net

Matthew Dharm wrote:
> 
> Out of curiosity... which value does the sg interface pass through?  It
> collects both the buffer length and the requested transfer length, if my
> memory serves...

Matt,
The sg driver does not attempt to decode SCSI commands (and,
for example, calculate allocation lengths) but simply passes
them through. In the sg_io_hdr interface what the user gives
as dxfer_len becomes the 4th argument to scsi_do_req() and
hence becomes Scsi_Request::sr_bufflen in the mid and lower
levels. The cumulative length of the elements in scatter gather 
list built by sg (or the single buffer) is greater than or
equal to dxfer_len.

I agree with the others who have stated that the case in which
the mid level sets allocation length at 255 (within a cdb) and 
bufflen=512 is just a bug and should be fixed. Both figures 
should probably be 252 (i.e. maximum 8 bit unsigned value rounded
down to ease alignment problems).

I agree with Kai concerning the use of sr_bufflen but can
see how LLDD maintainers could easily get confused. My idea
about dxfer_len was a duplication intended to help the LLDD
maintainers. Clear documentation would also help.

BTW When sr_buffer points to a scatter gather list sr_sglist_len 
is that list's length in bytes.

Doug Gilbert

> Matt
> 
> On Sun, Jul 28, 2002 at 12:54:48AM -0400, Douglas Gilbert wrote:
> > Matt,
> > I have no objection to adding a field in Scsi_Request
> > called something like 'dxfer_len' (CAM name) that makes
> > its intent pretty clear. We probably have to keep
> > 'bufflen' there for the time being. 'bufflen' is pretty
> > clear in the non scatter gather case (i.e. number of bytes
> > in 'buffer') but is confusing in the scatter gather case
> > when 'buffer' contains the scatter gather list.
> >
> > Doug Gilbert
> >
> >
> > Matthew Dharm wrote:
> > >
> > > ARGH!!
> > >
> > > Okay search the linux-scsi archives for May 29-30.  We've had this
> > > discussion before.
> > >
> > > At that time, I proposed adding a field to indicate the actual amount of
> > > data being requested, as opposed to the buffer size.  At the time (again,
> > > see the archives), I was told that the request_bufflen field _was_ that
> > > field.... any case where the request_bufflen didn't match up with the
> > > command was a bug and needed to be fixed.
> > >
> > > So which is it?  This needs to be fixed one way or another.
> > >
> > > Emulated SCSI busses _need_ to know how much data to move.  usb-storage has
> > > a large table to try to figure it out, but it only gets the correct answer
> > > in _most_ cases, not all cases.  Only the originator of the command truly
> > > knows how much data is going to be moved, so the only mechanism that makes
> > > sense is to make the originator of the command indicate that number via
> > > some mechanism.
> > >
> > > Matt
> > >
> > > On Sun, Jul 28, 2002 at 12:48:03AM +0200, Andries.Brouwer@cwi.nl wrote:
> > > >     I haven't seen these patches integrated into a kernel yet... have I just
> > > >     missed them, or is there some reason they have been rejected?
> > > >
> > > >     > +++ b/drivers/scsi/scsi_scan.c    Sun Jul 21 00:55:37 2002
> > > >     > -              256, SCSI_TIMEOUT+4*HZ, 3);
> > > >     > +              scsi_cmd[4], SCSI_TIMEOUT+4*HZ, 3);
> > > >
> > > >     > +++ b/drivers/scsi/sd.c    Sun Jul 21 00:55:44 2002
> > > >     > -              512, SD_TIMEOUT, MAX_RETRIES);
> > > >     > +              255, SD_TIMEOUT, MAX_RETRIES);
> > > >
> > > > There are many more possibilities.
> > > > Since the number of hours in a day is very finite, Linus cannot
> > > > look at everything, so even if the patch is perfect it can be ignored.
> > > >
> > > > There is not really a SCSI maintainer, but there are people that are
> > > > well-known as active in the SCSI area. You may try to submit via
> > > > one of them.
> > > >
> > > > But then the question is whether these are good patches.
> > > >
> > > > I booted 2.5.29 earlier this evening and was greeted by
> > > > kernel BUG at transport.c: 351 and
> > > > kernel BUG at scsiglue.c: 150.
> > > > (And the usb-storage module now hangs initializing; rmmod fails,
> > > > reboot is necessary.)
> > > >
> > > > The former BUG_ON wants to have len == srb->request_bufflen.
> > > > But I don't know whether that is wise. It is less confusing
> > > > when bufflen indicates the size of the buffer available,
> > > > rather than the number of bytes you expect to move.
> > > > It is not unusual to get one byte more than you asked for,
> > > > in case you ask for an odd number of bytes.
> > > >
> > > > So, maybe these patches aren't clear improvements.
> > > >
> > > > Andries
> > >
> > > --
> > > Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net
> > > Maintainer, Linux USB Mass Storage Driver
> > >
> > > I could always suspend a few hundred accounts and watch what happens.
> > >                                         -- Tanya
> > > User Friendly, 7/31/1998
> > >
> > >   ------------------------------------------------------------------------------------------
> > >    Part 1.2Type: application/pgp-signature
> 
> --
> Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net
> Maintainer, Linux USB Mass Storage Driver
> 
> C:  They kicked your ass, didn't they?
> S:  They were cheating!
>                                         -- The Chief and Stef
> User Friendly, 11/19/1997
> 
>   ------------------------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature

  reply	other threads:[~2002-07-30 13:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-27 22:48 [usb-storage] Re: 2 PATCHES: fix request_tranferlength Andries.Brouwer
2002-07-28  2:55 ` Matthew Dharm
2002-07-28  4:54   ` Douglas Gilbert
2002-07-28  9:11     ` Matthew Dharm
2002-07-30  5:24     ` Matthew Dharm
2002-07-30 13:40       ` Douglas Gilbert [this message]
2002-07-31  4:29         ` Matthew Dharm
2002-07-31  5:14           ` Doug Ledford
2002-07-31  5:35           ` Douglas Gilbert
2002-07-28 10:22   ` Kai Makisara
2002-07-28 19:31     ` Matthew Dharm
2002-07-28 21:01       ` Kai Makisara
2002-07-29 19:51         ` Doug Ledford
2002-07-29 20:50           ` Kai Makisara

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=3D46973C.6641E9B2@torque.net \
    --to=dougg@torque.net \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mdharm-scsi@one-eyed-alien.net \
    --cc=usb-storage@one-eyed-alien.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.