Bug 406030 - hard links multiply counted in usage totals
Summary: hard links multiply counted in usage totals
Status: REOPENED
Alias: None
Product: filelight
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Mint (Ubuntu based) Linux
: NOR minor
Target Milestone: ---
Assignee: Martin Sandsmark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-30 03:11 UTC by brainchild
Modified: 2025-08-01 09:36 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 23.03
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brainchild 2019-03-30 03:11:06 UTC
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)
Comment 1 Bug Janitor Service 2023-01-13 18:51:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/filelight/-/merge_requests/71
Comment 2 Jeremy Whiting 2023-01-17 17:50:38 UTC
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
Comment 3 Niko Strijbol 2023-09-27 13:31:43 UTC
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)
Comment 4 Jeremy Whiting 2023-09-27 14:04:06 UTC
Yep, good point. I'll update that one also. One moment.
Comment 5 Alexander van Gessel 2025-08-01 09:36:26 UTC
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)