5 ms·
Is there some widely used software that does O_DIRECT writes? MariaDB?
by fulafel 3y ago
Is there some widely used software that does O_DIRECT writes? MariaDB?
- hedora 3y agoO_DIRECT is almost always the wrong choice. sync_file_range gives you much better control over scheduling of the write backs, and madvise gives you better control over caching policy. There were some old UNIX variants where O_DIRECT actually bypassed the filesystem cache, but Linux's cache is coherent, so reading a file immediately after an O_DIRECT write completes is guaranteed to give the new value. That is more sane than the cache-incoherent approach (how do you know your write is going to a page that is clean in OS cache in the other UNIXes?), but also eliminates most of the code-path-length benefit of O_DIRECT. Also, if I remember right, O_DIRECT doesn't bypass the I/O scheduler on Linux. That, and bypassing the cache are the two main benefits of the old API, and you get neither. As a bonus, filesystems like tmpfs passive-aggressively return error if you try to use O_DIRECT.
- jcalvinowens 3y ago> but Linux's cache is coherent Linux achieves that coherency by making O_DIRECT invalidate the page in the page cache. I think it paints a more accurate picture to say the caching is disabled with O_DIRECT, not that it is coherent (although it certainly is).