Skip to content
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

Clone hardlinks #467

Merged
merged 54 commits into from
Mar 27, 2021
Merged

Clone hardlinks #467

merged 54 commits into from
Mar 27, 2021

Conversation

SeeSpotRun
Copy link
Collaborator

Fixes #466.

This PR enables hardlink-clones to be converted to reflink-clones via a single command rmlint --dedupe <original> <hardlink>, while preserving file permissions and times.

Note that converting hardlink to reflink doesn't free any space, in fact it consumes a little bit for the necessary metadata. The advantage is that it de-links the two files' metadata, so that subsequent changes to permissions, access times etc are independent for the two files. Also modifications such as appending data to the original won't affect the reflink the way it would the hardlink.

Note that this implementation does temporarily delete the hardlink, so an untimely crash or error could see the hardlink lost (but not the original file). The workaround would require generating a unique temporary file name for the reflink.

Happy to discuss.

@SeeSpotRun
Copy link
Collaborator Author

I haven't gone any further with this because it can't be done atomically so there is some risk that the hardlink gets deleted or renamed. I could do a bit more work to make it more robust but will wait to see if there is any more interest in #466

@SeeSpotRun SeeSpotRun marked this pull request as draft March 18, 2021 23:20
@SeeSpotRun
Copy link
Collaborator Author

Ok managed to make it reasonably atomic by cloning to a tempfile in the target dir and then atomically renaming that over the top of the hardlink.

@SeeSpotRun SeeSpotRun marked this pull request as ready for review March 19, 2021 00:37
SeeSpotRun added a commit that referenced this pull request Mar 27, 2021
@SeeSpotRun SeeSpotRun merged commit 308ced7 into sahib:develop Mar 27, 2021
@SeeSpotRun SeeSpotRun deleted the clone_hardlinks branch March 28, 2021 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants