Open ChristianTacke opened 9 years ago
I do not have a system with PATA devices (or even supports it) to be able to test and develop it. The ioctl with SCSI command would probably be the first barrier. The Linux SATA layer will translate that into the appropriate ATA commands but for PATA I don't think that's being done at all.
Can you use sg_read to read from your device? If not it will be a pain to support it. If yes, can you log the output of strace for sg_read so I can see what gets done?
Do you need special options to sg_read?
# strace sg_read if=/dev/hda bs=512 count=128
...
open("/dev/hda", O_RDONLY|O_LARGEFILE) = 3
brk(0) = 0xb786d000
brk(0xb789e000) = 0xb789e000
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 65536) = 65536
JFI: The SD-cardreader in my laptop (/dev/mmcblk0
) has the exact same issue with the size ioctl, currently. And the sg_read
looks also the same.
This method is going to be a lot less informative but I guess it would be better to have something rather than not being supported at all. I'll take a look at that shortly.
Note: sg_read if=/dev/sda bs=512 count=128
also uses plain read()
.
Should I use some special options to sg_read?
Adding blk_sgio=1
makes sg_read use SG_IO ioctls on /dev/sda and fail on /dev/hda. Haven't yet tried that on my SD card reader.
The fact that blk_sgio fails is directly related to the fact that the disks are not handled through the SCSI layer and libata. They are handled by the old PATA layer and so would require a different interface to be sent raw commands. As these type of disks are no longer produced and will just die off I won't be spending much time writing code for that old layer. I may consider a patch if it comes my way.
I should however be able to get it tested with plain reads and let the underlying OS translate to the PATA commands. It should be good enough to get the latency information even if we don't get the low level error indicators when they exist.
Please consider supporting
/dev/hd*
devices too. Currently they emit this error:strace has this failing ioctl:
Maybe an alternative is what
blockdev --getsize64
uses: