Visitar URL original
Use BTRFS reflink for safer deduplication · Issue #201 · 9001/copyparty · GitHub
Skip to content

Use BTRFS reflink for safer deduplication #201

Closed

Description

@DADA30000

tldr;
BTRFS can copy a file without using additional space on disk, and it's safe to delete a file that it was copied from, basically symlinks but show up as a file, and source file can be deleted safely.

https://youtu.be/15_-hgsX2V0?t=409 I've noticed this video in my recommendations and decided to watch it, but on timecode the guy was talking about deduplication being dangerous, as external modification of actual files can break the symlink. Then I immediatly thought about reflinks in BTRFS
BTRFS supports a feature named "reflinks", it's basically like a symlink, but to a user it shows up as a completely regular file, even if you delete the source file that it was copied from, the copy of the file will still be valid, as the source file is like a "link" to the actual data of file, and only the link gets deleted, the actual data is deleted only if there are no "links" to the data.
So this can be used for safe deduplication, maybe a check for this, or an additional flag for deduplication config.

Activity

  1. 9001 commented on Jul 27, 2025

    @9001
    Owner

    yep, this is an excellent idea -- someone mentioned it in #197 too :>

    I plan to add this 👍

  2. DADA30000 commented on Jul 27, 2025

    @DADA30000
    Author

    yep, this is an excellent idea -- someone mentioned it in #197 too :>

    I plan to add this 👍

    oh wow, an instant response :D
    thx for working on this :)
    I will then just leave the issue there to let people see if the feature is implemented

  3. surfaceflinger commented on Jul 27, 2025

    @surfaceflinger

    ZFS has/had this quirk when reflinking between datasets, idk if that's still the case tho https://discourse.practicalzfs.com/t/sanity-check-block-cloning/794/2

  4. DADA30000 commented on Jul 27, 2025

    @DADA30000
    Author

    ZFS has/had this quirk when reflinking between datasets, idk if that's still the case tho https://discourse.practicalzfs.com/t/sanity-check-block-cloning/794/2

    yep, that's why I only mentioned BTRFS, AFAIK only it has completely working reflink implementation without any problems for few years already

  5. 9001 commented on Jul 28, 2025

    @9001
    Owner

    it appears python 3.14 will have a battery for reflinking; python/cpython#93152

    compiling 3.14rc1 to give it a workout (primarily on btrfs) and will add it as an option for the next version if it seems fine

  6. motiejus commented on Jul 28, 2025

    @motiejus

    FWIW copy_file_range (the syscall behind reflink) is also supported on xfs.

  7. added a commit that references this issue on Jul 28, 2025
    df9feab
  8. PotcFdk commented on Jul 29, 2025

    @PotcFdk

    I just wanted to add that ioctl_fideduperange would allow to even share partial duplicate ranges within files. Since copyparty already does partial checksums, the easy way to make use of this might be to notice when a range was seen before, assuming the hashes stick around after the upload has finished, which might not be the case (I did not read the source code).

  9. 9001 commented on Jul 29, 2025

    @9001
    Owner

    ioctl_fideduperange would allow to even share partial duplicate ranges within files

    that's neat!

    right now, copyparty is only aware of the individual chunks as the upload is happening - the chunk checksums are discarded when the upload is completed, and only the full combined hash is stored in the db.

    if we find other reasons to store the individual checksums at some point, then this would be something to look at for sure.

  10. added a commit that references this issue on Jul 30, 2025
    dab7131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions