Unaligned AIO/DIO

I am getting this error on my Ubuntu Server installation:

kernel: [6622929.119915] EXT4-fs (sda1): Unaligned AIO/DIO on inode 43648079 by java; performance will be poor.

Is this a kernel bug? How do I fix it?


It isn't a kernel bug: instead, it is a warning from the kernel that the application in question is using the API (either asynchronous I/O or direct I/O) in an inefficient way.

From the source code:

/*
 * This tests whether the IO in question is block-aligned or not.
 * Ext4 utilizes unwritten extents when hole-filling during direct IO, and they
 * are converted to written only after the IO is complete.  Until they are
 * mapped, these blocks appear as holes, so dio_zero_block() will assume that
 * it needs to zero out portions of the start and/or end block.  If 2 AIO
 * threads are at work on the same unwritten block, they must be synchronized
 * or one thread will zero the other's data, causing corruption.
 */

So it means the program in question is trying to use the asynchronous I/O or direct I/O APIs with memory buffers that aren't aligned to the file system block boundaries, which forces the file system to perform the async operations on the file in series to avoid corruption.

If the program triggering the warning is one you wrote, then you could adjust how it uses the AIO or DIO APIs to avoid the problem. If it isn't your program, or you aren't using the APIs directly, then there probably isn't much you can do other than filing a bug report against the problem program.

For what it is worth, this warning is rate limited to once per day, so it shouldn't fill up your logs.