Linux quota reporting performance

linuxperformancequotareporting

I have a system with over 10,000,000 files where I want to track the disk usage of a couple of users (these users own the millions of files). Based on the following Q&A https://stackoverflow.com/questions/4307692/fastest-way-to-calculate-directory-sizes I want to look into linux disk quotas for this job since the du command also takes over an hour to run on my system.

My question is:

1) What is the expected run time of repquota? is it always very fast (eg. run in under 1 minute)? or does it depend on the number of files and disk size being tracked?

2) do I need to run quotacheck to update the quata information (files? database?) to change the output of repquota? or will repquota always give me up-to-date information?

Update

Example for 2):
If I run the following commands what is the expected output:

repquota /tmp
head -c 1024 /dev/urandom > /tmp/new.file
sleep 1
repquota /tmp

3) Will the second repquota /tmp give the same output as the first? or will the quota info be updated only because I wrote to the disk (and not based on running some other background quota updating program)?

Best Answer

  1. Repquota should be almost instant, however doing a quota check won't be. On a server with about 500k files 4 disk RAID0 it took around half an hour, however that was with fairly high disk load (50% or so). It does depend on the number of files, not so much disk size as disk speed.

  2. repquota reports based on the quota file (which is updated when quota runs, i believe roughly every 5 minutes), if you want complete up to date information then running quotacheck is a good idea. Bear in mind you need to turn off quota to do that.

We use the following script:

#!/usr/bin/php
<?php
echo date('Y-m-d H:i:s') . ': Checking quota and fixing' . "\n";

if (file_exists('/usr/local/bin/quota')) {
 `rm -rf /usr/bin/quota`;
 `ln -s /usr/local/bin/quota /usr/bin/quota`;
}

`quotacheck -avugm`;
sleep(1);
`quotaon -av`;
`repquota -as`;