add transfer request length?
I'd like to add another field to the Scsi_Cmnd structure. At least, I think I need another field to accomplish what I want....
Right now, a low-level SCSI driver (i.e. HBA) can't actually tell in advance how much data will be moved by a command. The driver can see the buffer and the buffer length, and can enforce that the transfer length does not exceed that buffer length, but we can't actually algorithmically determine the amount of data we expect to move....
For example, imagine an INQUIRY for 36 bytes issued with a buffer for 256 bytes. This actually does happen.
In this case, it's easy to figure out how much data is requested by reading the command. However, block device commands talk in 'number of blocks', which is something that the HBAs shouldn't have to keep track of.
The worst device is the OnStream driver, which makes allocations in page sizes and then transfers a strange number of bytes (n * 4096 + 512 bytes).
drivers/usb/storage/scsiglue.c has some code to try to figure out how much data should be transfered. This is important for emulated SCSI devices (sbp2, usb, etc.).
So, I'd like to add a field so that high-level drivers (sd, sr, sg, etc.) can tell us how many bytes they intend to move. sg already collects this information, but the HBA can't see it.
Comments?
Matt
Signature · 6 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Ye gods! I have feet??! -- Dust Puppy User Friendly, 12/4/1997
Quoted 12 lines · On 2002.05.30 02:00 Matthew Dharm wrote:
I'd like to add another field to the
Scsi_Cmndstructure. At least, I think I need another field to accomplish what I want....Right now, a low-level SCSI driver (i.e. HBA) can't actually tell in advance how much data will be moved by a command. The driver can see the buffer and the buffer length, and can enforce that the transfer length does not exceed that buffer length, but we can't actually algorithmically determine the amount of data we expect to move....
For example, imagine an INQUIRY for 36 bytes issued with a buffer for 256 bytes. This actually does happen.
Quoted 6 lines
In this case, it's easy to figure out how much data is requested by reading the command. However, block device commands talk in 'number of blocks', which is something that the HBAs shouldn't have to keep track of.
The worst device is the OnStream driver, which makes allocations in page sizes and then transfers a strange number of bytes (n * 4096 + 512 bytes).
Not any more... Turns out that was a problem for the IEEE1394 subsystem, so I changed it to an exact memory allocation.
Quoted 9 lines
drivers/usb/storage/scsiglue.chas some code to try to figure out how much data should be transfered. This is important for emulated SCSI devices (sbp2, usb, etc.).So, I'd like to add a field so that high-level drivers (sd, sr, sg, etc.) can tell us how many bytes they intend to move. sg already collects this information, but the HBA can't see it.
Comments?
/*
* Function: scsi_do_req
*
* Purpose: Queue a SCSI request
*
* Arguments: SRpnt - command descriptor. * cmnd - actual SCSI command to be performed. * buffer - data buffer. * bufflen - size of data buffer. * done - completion function to be run. * timeout - how long to let it run before timeout. * retries - number of retries we allow.
The bufflen above is not enough?
Thanks, Willem Riede.
Quoted 13 lines · Willem Riede
/*
* Function:scsi_do_req
*
* Purpose: Queue a SCSI request
** Arguments: SRpnt - command descriptor. * cmnd - actual SCSI command to be performed. * buffer - data buffer. * bufflen - size of data buffer. * done - completion function to be run. * timeout - how long to let it run before timeout. * retries - number of retries we allow.
Quoted 3 lines
The bufflen above is not enough?
Thanks, Willem Riede.
No, because we still get commands that really expect to transfer less than a bufflen. Osst was the worst offender, but there are others. Start playing with dd for a while with small block sizes and you can see some strange effects.
Matt
Signature · 6 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver What the hell are you? -- Pitr to Dust Puppy User Friendly, 12/3/1997
Quoted 8 lines · Matthew Dharm
Right now, a low-level SCSI driver (i.e. HBA) can't actually tell in advance how much data will be moved by a command. The driver can see the buffer and the buffer length, and can enforce that the transfer length does not exceed that buffer length, but we can't actually algorithmically determine the amount of data we expect to move....
For example, imagine an INQUIRY for 36 bytes issued with a buffer for 256 bytes. This actually does happen.
You mean the mid-layer asks for 256 bytes (buffer length and cmd are 256), but the device returns less than 256 bytes? If so, I don't see how setting another field helps.
Or, the mid-layer asks for 36, and buffer length is 256? If so, we should change the code.
-- Patrick Mansfield
I'm refering to the 'ask for 36 with buffer of 256' case. Given that buffer sizes are tied to page sizes, and that it's not just the mid-layer we're talking about here, it makes sense to me to just add the requested transfer length.
That is, unless we expect something else to keep track of 'actual buffer length' vs. 'reported buffer length'. But it seems to me that it would be useful to know both values at the HBA level.
Matt
Quoted 23 lines · Patrick Mansfield
Quoted 8 lines · Matthew Dharm
Right now, a low-level SCSI driver (i.e. HBA) can't actually tell in advance how much data will be moved by a command. The driver can see the buffer and the buffer length, and can enforce that the transfer length does not exceed that buffer length, but we can't actually algorithmically determine the amount of data we expect to move....
For example, imagine an INQUIRY for 36 bytes issued with a buffer for 256 bytes. This actually does happen.
You mean the mid-layer asks for 256 bytes (buffer length and cmd are 256), but the device returns less than 256 bytes? If so, I don't see how setting another field helps.
Or, the mid-layer asks for 36, and buffer length is 256? If so, we should change the code.
-- Patrick Mansfield
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver S: Another stupid question? G: There's no such thing as a stupid question, only stupid people. -- Stef and Greg User Friendly, 7/15/1998