23.2. Userspace Access
Always take care to use properly aligned and sized I/O. This is especially important for Direct I/O access. Direct I/O should be aligned on a
logical_block_sizeboundary, and in multiples of the
With native 4K devices (i.e.
logical_block_sizeis 4K) it is now critical that applications perform direct I/O in multiples of the device's
logical_block_size. This means that applications will fail with native 4k devices that perform 512-byte aligned I/O rather than 4k-aligned I/O.
To avoid this, an application should consult the I/O parameters of a device to ensure it is using the proper I/O alignment and size. As mentioned earlier, I/O parameters are exposed through the both
sysfsand block device
For more details, refer to
man libblkid. This
manpage is provided by the
The kernel will still export these
sysfsattributes for "legacy" devices that do not provide I/O parameters information, for example:
alignment_offset: 0 physical_block_size: 512 logical_block_size: 512 minimum_io_size: 512 optimal_io_size: 0