UNMAP command parameter list
Hi all,
I'm trying to see what parameters are passed to the UFS driver from the
SCSI midlayer when an UNMAP command is issued. In the UFS driver I can see the 10 byte command itself in the unsigned char *cmnd field of the struct scsi_cmnd, and it tells me that the parameter list length is 24 bytes (an 8 byte UNMAP Parameter List header followed by one 16 byte long UNMAP Block Descriptor), but I'm having trouble finding where this UNMAP Parameter List is. It doesn't seem to be in the cmnd[] byte array after the UNMAP command itself.
Can anyone tell me where I can find the UNMAP Parameter List which belongs
to a particular UNMAP command?
Any and all info would be greatly appreciated.
Andras
Quoted 21 lines
-----Original Message-----
From: [email protected] [mailto:linux-scsi- [email protected]] On Behalf Of Andras Kovacs
Sent: Friday, 07 November, 2014 5:30 PM
To: [email protected]
Subject: UNMAP command parameter listHi all,
I'm trying to see what parameters are passed to the UFS driver from the
SCSI midlayer when an UNMAP command is issued. In the UFS driver I can see the 10 byte command itself in the unsigned char *cmnd field of the structscsi_cmnd, and it tells me that the parameter list length is 24 bytes (an 8 byte UNMAP Parameter List header followed by one 16 byte long UNMAP Block Descriptor), but I'm having trouble finding where this UNMAP Parameter List is. It doesn't seem to be in the cmnd[] byte array after the UNMAP command itself.
Quoted 6 lines
Can anyone tell me where I can find the UNMAP Parameter List which
belongs to a particular UNMAP command?Any and all info would be greatly appreciated.
Andras
That is the data transferred for the command, not in the command descriptor block itself.
Typical T10 terminology is:
* parameter list = data-out buffer (i.e., write data)
* parameter data = data-in buffer (i.e., read data)
---
Rob Elliott HP Server Storage
Quoted 2 lines · Elliott, Robert (Server Storage <Elliott <at> hp.com> writes:
That is the data transferred for the command, not in the command descriptor block itself.
Thank you. Then I guess I'll find the Paramerer List in the struct scsi_data_buffer sdb variable (within struct scsi_cmnd). Will check on Monday.
Quoted 9 lines · Andras Kovacs <akovacs <at> fixstars.com> writes:
Quoted 2 lines · Elliott, Robert (Server Storage <Elliott <at> hp.com> writes:
That is the data transferred for the command, not in the command descriptor block itself.
Thank you. Then I guess I'll find the Paramerer List in the struct
scsi_data_buffersdb variable (within structscsi_cmnd). Will check on Monday.
I've looked into it, but struct scsi_data_buffer doesn't contain a byte
array (rather a struct sg_table variable and some housekeeping vars). So my question is still: where can I find the Parameter List associated with a particular UNMAP command?
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Andras" == Andras Kovacs <[email protected]> writes:
Thank you. Then I guess I'll find the Paramerer List in the struct
scsi_data_buffersdb variable (within structscsi_cmnd). Will check on Monday.
Andras> I've looked into it, but struct scsi_data_buffer doesn't contain Andras> a byte array (rather a struct sg_table variable and some Andras> housekeeping vars). So my question is still: where can I find Andras> the Parameter List associated with a particular UNMAP command?
You'll have to traverse scatterlist and extract the descriptor from there. You can use scsi_for_each_sg() to walk the list.
If you only care about in-kernel discards it's pretty easy since we only issue a single descriptor. If you want to support arbitrary block pc UNMAP commands you'll have to be able to deal with multiple descriptors across multiple scatterlist elements. But the accessor macro makes that easy so I suggest you take that approach.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 8 lines · Martin K. Petersen
You'll have to traverse scatterlist and extract the descriptor from there. You can use
scsi_for_each_sg()to walk the list.If you only care about in-kernel discards it's pretty easy since we only issue a single descriptor. If you want to support arbitrary block pc UNMAP commands you'll have to be able to deal with multiple descriptors across multiple scatterlist elements. But the accessor macro makes that easy so I suggest you take that approach.
Note that if the hardware doesn't actually implement UNMAP and you have to emulate something you're probably better off emulating WRITE SAME
(16) with the UNMAP bit, as the format is a lot easier to handle, and it's much better specified to start with.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> Note that if the hardware doesn't actually implement UNMAP Christoph> and you have to emulate something you're probably better off Christoph> emulating WRITE SAME (16) with the UNMAP bit, as the format Christoph> is a lot easier to handle, and it's much better specified to Christoph> start with.
Yup, absolutely!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 4 lines · Christoph Hellwig <hch <at> infradead.org> writes:
Quoted 2 lines · Martin K. Petersen
You'll have to traverse scatterlist and extract the descriptor from there. You can use
scsi_for_each_sg()to walk the list.
Thank you; I'm working on it.
Quoted 11 lines
Quoted 6 lines
If you only care about in-kernel discards it's pretty easy since we only issue a single descriptor. If you want to support arbitrary block pc UNMAP commands you'll have to be able to deal with multiple descriptors across multiple scatterlist elements. But the accessor macro makes that easy so I suggest you take that approach.
Note that if the hardware doesn't actually implement UNMAP and you have to emulate something you're probably better off emulating WRITE SAME
(16) with the UNMAP bit, as the format is a lot easier to handle, and it's much better specified to start with.
Actually, my case is that the HW (at least in its current iteration)
doesn't support WRITE SAME but does support UNMAP. But it seems that the discard option given to ext4 at mount time is "ineffective" in the sense of not keeping up a high write transfer rate to the device (it looks like write amplification is happening, something which discard -- and UNMAP -- ought to preempt). So now I'm writing code to 'debug' the UNMAP commands which get passed to the device.