markfasheh / duperemove

Tools for deduping file systems
GNU General Public License v2.0
832 stars 82 forks source link

filerec_count_shared(): fix sharing accounting #323

Closed trofi closed 1 year ago

trofi commented 1 year ago

Before the change filerec_count_shared() incorrectly accounted for extent end compared to file end:

$ ls -lh /nix/var/nix/db/db.sqlite
-rw-r--r-- 1 root root 1.4G Nov  9 22:21 /nix/var/nix/db/db.sqlite

Before the change due to incorrect tail handling sharing reported size larger than the file itself:

$ ./show-shared-extents /nix/var/nix/db/db.sqlite
/nix/var/nix/db/db.sqlite: 27065321263104 shared bytes

After the change sharing reports a reasonable value:

$ ./show-shared-extents /nix/var/nix/db/db.sqlite
/nix/var/nix/db/db.sqlite: 1169276928 shared bytes

Note: before the change sharing reported a few orders of magnitude savings larger than initial file size. After the change the value is more reasonable.

JackSlateur commented 1 year ago

Thank you for improving this report