[Gllug] Odd (but apparently correct) behaviour from du

John Winters john at sinodun.org.uk
Thu Jul 17 09:09:33 UTC 2008


Nix wrote:
> On 16 Jul 2008, John Winters told this:
>> The results which came back were startlingly variable.  Instead of a
>> consistent 30G or so (slowly increasing) in each snapshot I got wildly
>> varying values.  One night's snapshot would be 31G and the next night's
>> apparently 2G.  Looking at them manually however they all seemed to be
>> complete.
> 
> That seems very strange.
> 
> du's process_file() handles hard links by hashing every (inode, dev) it
> finds for inodes with a link count >1, then not accumulating sizes or
> names for inodes it's seen already (unless --count-links is active).
> 
> Therefore you shouldn't see *varying* output unless your filesystem
> is returning readdir() results in a different order every time du runs
> (which is possible but really rather unlikely).

Possible misconception here.  When I said "varying" I didn't mean
"varying from run to run" - just "varying from snapshot to snapshot".
If you run it again you get the same result.

> 
>> I got the right answer.  Now hands up all those who knew that du behaved
>> this way.
> 
> Er, I thought it was obvious that it had to do something like this from
> the moment I first met du. I don't see how else it could possibly give
> the right totals in the presence of hard links.

I suppose it depends what you're expecting it to do.  When I invoked it
with a list of directories I rather expected it to tell me the disc
usage for each of those directories separately.  The author on the other
hand clearly expected it to provide values which could subsequently be
added together to give a correct total for all the directories together.
 Once you're working towards the latter objective then clearly it does
need to work in the way which it does.

Cheers,
John
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list