I have a mergerfs filesystem where some branches contain symlinks to a directory at the same path within a different branch.
Example:
/mnt/branch1/dir - symlink to /mnt/branch2/dir
/mnt/branch2/dir - a directory
The reasons for doing such a thing are historical (there are existing processes that work with certain branch paths directly, the data had to be moved to a different volume, ...). Maybe I'm using mergerfs horribly wrong, but didn't find any warning about this in the docs and so far it seems to work fine.
The issue:
It seems like when the mergerfs.dedup is called on the merged filesystem it incorrectly identifies the files within both paths as different files (different copies) and would attempt to delete them. That would result in 0 copies of the affected files.
Suggested solution:
There should be an option (or even better it might be the default), where:
-
Before file deletion mergerfs.dedup performs readlink on both paths of the duplicates and compares the results - if they are the same, the deletion shouldn't be performed.
-
Alternatively: It could check if both files are the same inode within the same volume and if so it should reject deletion when the refcount is only 1.
Basically the idea is that a tool made to delete duplicates should make especially sure that everything it deletes are truly duplicates.