3 ms·
does copying/moving a file over another not trigger copy-on-write in btrfs? If not, it seems a much simpler (but much less cool and useful for all) solution wo
by kbenson 13y ago
does copying/moving a file over another not trigger copy-on-write in btrfs? If not, it seems a much simpler (but much less cool and useful for all) solution would be to patch rsync with an option to allow writing the temp file over the original when done. While still non-atomic, you'll get the copy-on-write semantics you need. Unfortunately it will use much more IO. There are ways to mitigate the extra IO, such as creating a special diff formatted temp file, but that getting out of the territory of "simple".
Also, in case the FS is saving copies of the temp file and you don't like that, the --temp-dir option might help with that.
Then again, depending on how btrfs treats overwriting a file with a move, if the temp file had a timestamp in the name (patch probably needed) in some form before replacing the original, that might be good enough.
- keeperofdakeys 13y agoMost Unix file systems don't have the semantics of a "move". You unlink an inode from a filename, and link another inode (usually the inode for the tmp file). Then you unlink the original tmp filename. As far as btrfs is concerned, there is no relation between these inodes, and without copying the file (like you suggest), you can't improve this.