Bug 739574 - du fails to get dir size correctly
Summary: du fails to get dir size correctly
Keywords:
Status: CLOSED DUPLICATE of bug 561869
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-19 14:40 UTC by techtonik
Modified: 2012-07-16 11:42 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-07-16 11:42:30 UTC
Type: ---
Embargoed:


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

Description techtonik 2011-09-19 14:40:27 UTC
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 15:36:42 UTC
What does 'correctly' mean in your case?  What filesystem are you on?  Did you try strace?

Comment 2 techtonik 2011-09-19 15:52:26 UTC
(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 16:04:28 UTC
(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 16:47:17 UTC
(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 16:48:02 UTC
Created attachment 523870 [details]
strace.log

Comment 6 Kamil Dudka 2011-09-19 19:33:36 UTC
Are there any hard-linked files in that directory?

$ find -type f -links +1

Comment 7 techtonik 2011-09-20 06:29:00 UTC
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 07:15:36 UTC
This may be a duplicate of bug #561869 then.

Comment 9 techtonik 2011-09-20 07:30:17 UTC
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 11:42:30 UTC
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.