This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 739574 - du fails to get dir size correctly
du fails to get dir size correctly
Status: CLOSED DUPLICATE of bug 561869
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
15
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ondrej Vasik
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-19 10:40 EDT by techtonik
Modified: 2012-07-16 07:42 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-16 07:42:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
strace.log (4.60 MB, text/plain)
2011-09-19 12:48 EDT, techtonik
no flags Details

  None (edit)
Description techtonik 2011-09-19 10:40:27 EDT
How reproducible:
Now

Steps to Reproduce:
1.du -hs *
2.du -hs dir/*
3.
  
Actual results:
$ du -hs *
47M	scons-hg-001
1.6M	scons-hg-002
27M	scons-hg-003
$ du -hs scons-hg-00?
47M	scons-hg-001
47M	scons-hg-002
27M	scons-hg-003

Expected results:
$ du -hs *
47M	scons-hg-001
47M	scons-hg-002
27M	scons-hg-003
Comment 1 Kamil Dudka 2011-09-19 11:36:42 EDT
What does 'correctly' mean in your case?  What filesystem are you on?  Did you try strace?
Comment 2 techtonik 2011-09-19 11:52:26 EDT
(In reply to comment #1)
> What does 'correctly' mean in your case?

scons-hg-002 size should be 47M in both cases?

>  What filesystem are you on?

$ mount | grep sda8
/dev/sda8 on /mnt/shared type ext3 (rw,noatime,seclabel,errors=continue,barrier=0,data=ordered)

> Did you try strace?

What's this? It's not installed on my system.
Comment 3 Kamil Dudka 2011-09-19 12:04:28 EDT
(In reply to comment #2)
> $ mount | grep sda8
> /dev/sda8 on /mnt/shared type ext3
> (rw,noatime,seclabel,errors=continue,barrier=0,data=ordered)

Is the filesystem consistent?  Did you try fsck?

> > Did you try strace?
> 
> What's this? It's not installed on my system.

strace is a tool that traces system calls, certainly worth to install.  You can capture the trace for du as follows:

$ strace -o strace.log du ...

If you try to repeat both steps 1. and 2. once again, do they produce the exactly same results?
Comment 4 techtonik 2011-09-19 12:47:17 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > $ mount | grep sda8
> > /dev/sda8 on /mnt/shared type ext3
> > (rw,noatime,seclabel,errors=continue,barrier=0,data=ordered)
> 
> Is the filesystem consistent?  Did you try fsck?

Yes. I rebooted into 'single' mode and did a check on /dev/sda8 with no errors.

> > > Did you try strace?
> > 
> > What's this? It's not installed on my system.
> 
> strace is a tool that traces system calls, certainly worth to install.  You can
> capture the trace for du as follows:
> 
> $ strace -o strace.log du ...

I'll attach with the next comment.

> If you try to repeat both steps 1. and 2. once again, do they produce the
> exactly same results?

Well. It produces the same errors until. I've added a couple of other dirs there. Now the results become:

$ du -hs *
41M	checkout
4.0K	getsize.py
30M	onlytrunk
27M	scons-hg
47M	scons-hg-001
47M	scons-hg-002
1.3M	scons-hg-003
316K	scons-hg-003.log
17M	scons-hg-nobranches
108K	scons-migration-scripts
1.4G	scons-mirror

Note that now scons-hg-003 is reported wrongly.

$ rm -rf checkout
$  du -hs *
4.0K	getsize.py
30M	onlytrunk
27M	scons-hg
47M	scons-hg-001
47M	scons-hg-002
27M	scons-hg-003
316K	scons-hg-003.log
17M	scons-hg-nobranches
108K	scons-migration-scripts
1.4G	scons-mirror

No everything seems ok.I recreate the clone with Mercurial and it's broken again.

$ hg clone scons-hg-002 checkout
$ du -hs *
60M	checkout
4.0K	getsize.py
30M	onlytrunk
27M	scons-hg
47M	scons-hg-001
1.6M	scons-hg-002
27M	scons-hg-003
316K	scons-hg-003.log
17M	scons-hg-nobranches
108K	scons-migration-scripts
1.4G	scons-mirror

I'll attach strace.log for the last call.
Comment 5 techtonik 2011-09-19 12:48:02 EDT
Created attachment 523870 [details]
strace.log
Comment 6 Kamil Dudka 2011-09-19 15:33:36 EDT
Are there any hard-linked files in that directory?

$ find -type f -links +1
Comment 7 techtonik 2011-09-20 02:29:00 EDT
It appears that yes, there are. With `du -hsl` I get sizes correctly, but that's not intuitive and not needed by default. Especially in this case when directories are specified separately.
Comment 8 Kamil Dudka 2011-09-20 03:15:36 EDT
This may be a duplicate of bug #561869 then.
Comment 9 techtonik 2011-09-20 03:30:17 EDT
I could agree that this one is a duplicate if it wasn't hard to agree with resolution.
Comment 10 Ondrej Vasik 2012-07-16 07:42:30 EDT
Cleanup.

*** This bug has been marked as a duplicate of bug 561869 ***

Note You need to log in before you can comment on or make changes to this bug.