New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: copytruncate
could make a CoW clone on supported filesystems.
#538
Comments
I think this may reduce the I/O transfer but I do not think it could save any disk space in long term. |
The disk space saving I mentioned is just for during the copy. My scenario is a system that's near full and a large log file that does ultimately compress well. Using CoW/reflink might pair well with that |
Indeed. The advantage with a reflink copy on Btrfs, XFS (and soon ZFS?) is that a reflink copy is near instant, even on very large files. It also reduce amount of writes needed, even temporarily, while compressing the files (if using compress or delay compress).
Unfortunate as it is, we can't always make sure loggers have good reload functions.
How about using renameat2() RENAME_EXCHANGE
|
@Forza-tng logrotate atomically renames the log file by default. The problem is that the daemon will continue to write to the already rotated log file as long as the original log file descriptor is kept open. On a POSIX system, a rename operation does not affect open file descriptors. And that is exactly the reason why the |
I might have misunderstood how renameat2() works, but the the way I understand it, it keeps the inode of the original file, unlike when you use The process would be something like this:
If we use |
Nope. |
You are correct. I did some tests using https://gist.github.com/eatnumber1/f97ac7dad7b1f5a9721f#file-renameat2-x86_64 which prove your point. I'm sorry for the noise caused 🙏 The original idea using reflinks would still be very beneficial. |
Basically was looking for an option to do the same as
cp --reflink src dst
when both are on the same supported filesystem.This reduces the total free disk space required to duplicate the log before clearing the source file and speeds things up.
On an xfs fs I ran a little test:
Copy with reflink set
Shows that the extents are shared:
And then no longer shared after truncating the original file:
The text was updated successfully, but these errors were encountered: