Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support old PATA/non-SCSI drives on Linux #36

Open
ChristianTacke opened this issue Jun 13, 2015 · 6 comments
Open

Support old PATA/non-SCSI drives on Linux #36

ChristianTacke opened this issue Jun 13, 2015 · 6 comments
Assignees
Milestone

Comments

@ChristianTacke
Copy link

Please consider supporting /dev/hd*devices too. Currently they emit this error:

E: Failed to issue ioctl to device errno=22: Invalid argument
E: Can't get block device size information for path /dev/hda: Invalid argument

strace has this failing ioctl:

ioctl(3, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[10]=[25, 00, 00, 00, 00, 00, 00, 00, 00, 00], mx_sb_len=0, iovec_count=0, dxfer_len=512, timeout=600000, flags=0x2}) = -1 EINVAL (Invalid argument)

Maybe an alternative is what blockdev --getsize64 uses:

ioctl(3, BLKGETSIZE64, 20020396032)     = 0
@baruch
Copy link
Owner

baruch commented Jun 13, 2015

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?

@ChristianTacke
Copy link
Author

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

@ChristianTacke
Copy link
Author

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.

@baruch
Copy link
Owner

baruch commented Jun 14, 2015

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.

@ChristianTacke
Copy link
Author

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.

@ChristianTacke ChristianTacke changed the title Support old PATA drives on Linux Support old PATA/non-SCSI drives on Linux Jun 14, 2015
@baruch
Copy link
Owner

baruch commented Sep 17, 2015

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.

@baruch baruch added this to the Future milestone Sep 18, 2015
@baruch baruch modified the milestones: Version 0.17, Future Oct 10, 2015
@baruch baruch self-assigned this Oct 10, 2015
@baruch baruch modified the milestones: Version 0.18, Version 0.50 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants