1

libaio documentation on use with direct devices says read and write offsets must be sector aligned e.g. multiples of 512 bytes for a typical SSD/HDD. Some of the info available on the web also says that the user space buffers used as source and destination also need to be aligned.

What are the alignment restrictions for the vector read and write functions when using a direct device? I assume that the disk side of the operation will still need to be sector aligned (it is after all talking to a block device under the covers). Can my scatter gather lists spread small chunks around to non-aligned targets in user space?

I am working on debian Jessie and have verified support for vector I/O in libaio.

Alex
  • 421
  • 5
  • 8

1 Answers1

0

The short answer established by writing some test code is no. Both the disk side and memory side of the transfers must be sector aligned. The error code returned in the event for non sector aligned operations is -22 (Unknown error).

It would have been interesting if this had worked. The underlying hardware (an SSD and an AHCI compatible controller) are capable of doing DMA to/from any even address.

Alex
  • 421
  • 5
  • 8
  • 1
    Yep, you're correct. And, if it's a 4K-native SSD, everything including the memory has to be 4K-aligned. The io_submit interface is funny. You need to invert the error return, and interpret it as an errno. So, your -22 becomes 22, which is EINVAL. – Mike Andrews Aug 03 '15 at 02:49