SUMMARY Each hard link contributes to disk usage total even when duplicating same inode. STEPS TO REPRODUCE 1. Create a directory. 2. Copy a large file into the new directory. 3. Create several hard links to the file, within the same directory. 4. Scan directory in Filelight. OBSERVED RESULT Disk usage total is file size times number of links. EXPECTED RESULT Disk usage total is file size. SOFTWARE/OS VERSIONS Filelight: 17.12.3 Linux/KDE Plasma: Mint 19.1 Cinnamon KDE Frameworks Version: 5.44.0 Qt Version: 5.9.5 (built against 5.9.5)
A possibly relevant merge request was started @ https://invent.kde.org/utilities/filelight/-/merge_requests/71
Git commit 7356cc3bc8164073e161820c32321ec8bf5b52c4 by Jeremy Whiting. Committed on 17/01/2023 at 17:50. Pushed by whiting into branch 'master'. Don't double count hard link files. On posix file systems, if the number of links for a file is >1 add it to a set the first time we count it and never count it again. Fixes double counting files that aren't taking twice as much space. M +4 -0 autotests/directoryIteratorTest.cpp M +2 -2 autotests/localListerTest.cpp M +1 -0 src/directoryEntry.h M +1 -1 src/localLister.cpp M +13 -0 src/posixWalker.cpp M +4 -0 src/posixWalker.h https://invent.kde.org/utilities/filelight/commit/7356cc3bc8164073e161820c32321ec8bf5b52c4
Would this also fix https://bugs.kde.org/show_bug.cgi?id=144948 ? (I ask because I was googling this issue and stumbled on that one first)
Yep, good point. I'll update that one also. One moment.
This is only actually fixed for hardlinks in the *same directory*. STEPS TO REPRODUCE 1. mkdir /tmp/filelight_test 2. cd /tmp/filelight_test 3. dd if=/dev/zero of=orig bs=4096 count=256k 4. for i in $(seq 10); do ln orig link_$i ; done 5. Open filelight, see only 1 GiB in use in /tmp/filelight_test, as expected (attributed to one file) 6. for i in $(seq 10); do mkdir dir_$i; ln orig dir_$i/link_in_dir ; done 7. Refresh filelight OBSERVED RESULT Filelight shows a total disk usage of 11 GiB, 1 GiB in each subdirectory, and 1 GiB in the root. EXPECTED RESULT Total disk usage of 1 GiB. Attribution of that disk usage is a different issue (with a proposed fix by Martin Sandsmark in #144948) SOFTWARE/OS VERSIONS Filelight: 25.04.3 Gentoo linux, as of 2025-08-01 Plasma: 6.3.6 KDE Framework: 6.13.0 Qt: 6.9.1 (build against 6.9.1)