I need to pass a direct, raw ATA request to a hard drive (0x25,
READ DMA EXT), to disobey max sector count (long story), and to bypass all possible OS caches, buffers, reorderings et al.
HDIO_DRIVE_TASKFILE IOCTL is no longer available due to
I accomplished the goal with a
SG_IO IOCTL with ATA pass-through (
SG_ATA_16). Works perfectly except one problem: I can read a maximum of 8192 sectors in one command. I need to read a full of 32767 sectors.
- max_hw_sectors_kb is 32767, so the drive supports this much transfer
- max_sectors_kb was low, yet I brought it up to 32767 sectors, to no avail
- scheduler is set to noop, no change.
- Tried gather buffer (
iovec_count>0, properly set
iovecsto consecutive buffer slices), no change.
Environment: Ubuntu 16.04/16.10/17.04/17.10 with standard kernels, SATA drive connected to standard AHCI interface on Intel chipset.
No matter what I do, starting with 8193 sectors, IOCTL bails out with "Invalid argument" error (precisely, with
EINVAL errno). On another machine, it varies slightly from run to run (no reboot), usually settling at max 1344 sectors.
Where to look? What can cause a data transfer cap?