xfs - how to not modify mtime when writing to file?

痴心易碎 提交于 2019-12-04 18:09:30

See man 2 stat for the semantics of mtime and ctime. In practice, the mtime and ctime will be updated in the in-memory copy of the inode and flushed out to disk asynchronously.

You can't skip the mtime update in the inode without major kernel hackery and if you really think that a copy from one 32bit counter to another memory location is slowing you down, you are mistakenly trying to optimize the fast part of write(2).

Want to increase file write performance on a 1GB file? Add more memory for the block cache to use and forget about the mtime.

added in response to comment

Synchronous writes will not provide safety in any meaningful sense as a pulled power cord in the middle of a disk write is not helped by sync; this is why journaled filesystems like xfs and ext3+ are used. The best you can hope for is consistency in the face of failure.

You appear to desire certainty that the data recorded are cast in stone which is fundamentally impossible even if you build a RAID with battery backed SRAM write buffers as something can always fail before the bits are committed. Writing the raw volume gives you even less protection than a journaled filesystem.

If you clarify your design intention in your question, a better answer might be possible. On a gut level, even though the write times are longer, for a piddling little 1GB file, flash memory strikes me as less failure prone than spinning oxides, but this is not a formal declaration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!