3 ms·
For approach #2, can you lose the file completely or only the new version? In many cases it would be acceptable if the old version was still there after a crash
by wmf 18y ago
For approach #2, can you lose the file completely or only the new version? In many cases it would be acceptable if the old version was still there after a crash (ACI semantics).
- pmjordan 18y agoAs I understand it, you can lose both versions in #2. The rename drops the refcount of the old file to 0, freeing its inode and associated file blocks. If you're lucky, they haven't been overwritten and can still find them. Not easily from an app though. On the other hand, the new file might not have been flushed to disk yet. I suspect this could be solved fs-side using a journal that doesn't just store metadata (as most do) but also file content. Slow, though, as files are effectively written to disk twice.
- wmf 18y agoUgh, that is bad if true. A filesystem shouldn't commit a rename to disk before the file being renamed; that is common sense causality. Especially since (AFAIK) #2 is totally safe under ZFS, so Linux is behind yet again.
- glymor 18y agoMy guess is the rename must occur immediately or he would have covered it. But even if it doesn't the write and the rename are not correlated so it's still not safe. e.g. the move does not occur iff the write completes. Is there any way to queue the move as a system call?