标题: 请教:哪种方式能保证文件系统数据完整写入磁盘?sync or direct IO or 其它? [打印本页] 作者: humjb_1983 时间: 2014-11-14 12:50 标题: 请教:哪种方式能保证文件系统数据完整写入磁盘?sync or direct IO or 其它? RT,谢谢!作者: Tinnal 时间: 2014-11-14 14:17 回复 1# humjb_1983
O_DIRECT alone only promises that the kernel will avoid copying data from user space to kernel space, and will instead write it directly via DMA (if possible). Data does not go into caches. There is no strict guarantee that the function will return only after all data has been transferred.
O_SYNC guarantees that the call will not return before all data has been transferred to the disk (as far as the OS can tell). This still does not guarantee that the data isn't somewhere in the harddisk write cache, but it is as much as the OS can guarantee.
O_DIRECT|O_SYNC is the combination of these, i.e. "DMA + guarantee".作者: Tinnal 时间: 2014-11-14 14:20 回复 1# humjb_1983