未对齐的 AIO/DIO

Mal*_*olm 7 kernel 11.04

我在我的 Ubuntu Server 安装中收到此错误:

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

这是内核错误吗?我如何解决它?

Jam*_*dge 9

这不是内核错误:相反,它是来自内核的警告,表明相关应用程序正在以低效的方式使用 API(异步 I/O 或直接 I/O)。

源代码

/*
 * 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.
 */
Run Code Online (Sandbox Code Playgroud)

所以这意味着有问题的程序正在尝试使用异步 I/O 或直接 I/O API,其内存缓冲区与文件系统块边界不对齐,这迫使文件系统对文件执行异步操作串联以避免腐败。

如果触发警告的程序是您编写的程序,那么您可以调整它使用 AIO 或 DIO API 的方式来避免该问题。如果它不是您的程序,或者您没有直接使用 API,那么除了针对问题程序提交错误报告之外,您可能无能为力。

值得一提的是,此警告的频率限制为每天一次,因此它不应填满您的日志。