Re: Understanding "Used" in df

Andrei Borzenkov
2020-07-27T19:48:23Z

27.07.2020 22:30, Chris Murphy пишет:
> On Mon, Jul 27, 2020 at 10:43 AM Andrei Borzenkov <arvidjaar@gmail.com> wrote:
>>
>> Unfortunately, "df" does not display "free" (I was wrong in other post).
>> But using stat ...
>>
>>
>> $ LANGUAGE=en stat -f .
>> ...
>> Block size: 4096 Fundamental block size: 4096
>> Blocks: Total: 115164174 Free: 49153062 Available: 43297293
>>
>> $ LANGUAGE=en df -B 4K .
>> Filesystem 4K-blocks Used Available Use% Mounted on
>> /dev/sda4 115164174 66011112 43297293 61% /
>>
>> 115164174 - 49153062 == 66011112
>>
>> But there is no way you can compute Available from other values - it is
>> whatever filesystem returns.
>>
>
> It's definitely goofy in the odd device raid1 case.

Well, I already explained why it happens. Yes, it looks like a bug, the
question is how to do better estimation without performing exhaustive
single-chunk allocation every time. Three equal size devices looks
simple, but consider general case of multiple devices of different size
or different amount of free space.

> If I fallocate a
> file equal to Avail, Avail is not zero.

Yes, because real allocator breaks large file into chunks and estimation
in statfs "allocates" large size as single operation. So end result is
different.

> The fallocated file + new
> Avail != old Avail, which is just not at all correct behavior. So I
> keep fallocating files to get to 0 Avail, and instead I'm only chasing
> zero Avail condition. Once I'm close enough, and delete all six
> fallocated files, I end up for a short period of time, an Avail that
> seems reasonable but is way bigger than it was at the start. And then
> a minute later, without any additional action on my part, returns to
> reporting nonsense.
>
> It's pretty confusing.
>
>