2010-06-13 09:38:10

by Andi Kleen

[permalink] [raw]
Subject: ext4 df free space reporting not reliable?


Hi,

I have a ext4 file system on 2.6.34 that shows 0 blocks available
in "df" (it's nearly full but never got a ENOSPC).

But when I delete a couple of files it still shows 0 blocks.
And I can actually create small files without problem, so clearly
there is at least some space available.

So is df reporting not accurate?

Thanks,
-Andi

--
[email protected] -- Speaking for myself only.


2010-06-13 10:27:08

by Theodore Ts'o

[permalink] [raw]
Subject: Re: ext4 df free space reporting not reliable?


On Jun 13, 2010, at 5:38 AM, Andi Kleen wrote:

> Hi,
>
> I have a ext4 file system on 2.6.34 that shows 0 blocks available
> in "df" (it's nearly full but never got a ENOSPC).
>
> But when I delete a couple of files it still shows 0 blocks.
> And I can actually create small files without problem, so clearly
> there is at least some space available.
>
> So is df reporting not accurate?

Are you creating the files as root? Sounds like the standard reserved
blocks behavior that's been around since ext3, ext2, BSD's ufs, etc...

- Ted


2010-06-13 10:34:52

by Andi Kleen

[permalink] [raw]
Subject: Re: ext4 df free space reporting not reliable?

> Are you creating the files as root? Sounds like the standard reserved
> blocks behavior that's been around since ext3, ext2, BSD's ufs, etc...

Yes everything is root.

I would expect root df to not report the reservation. Is that not the case?

-Andi
--
[email protected] -- Speaking for myself only.

2010-06-13 16:45:52

by Sandon Van Ness

[permalink] [raw]
Subject: Re: ext4 df free space reporting not reliable?

On 06/13/2010 03:34 AM, Andi Kleen wrote:
>> Are you creating the files as root? Sounds like the standard reserved
>> blocks behavior that's been around since ext3, ext2, BSD's ufs, etc...
>>
> Yes everything is root.
>
> I would expect root df to not report the reservation. Is that not the case?
>
> -Andi
>

Is the root reserve (default 5% on ext3, not sure for ext3) set to 0?

tune2fs -m0 /dev/sdX

The file-system does not need to be unmounted to do this but this will
change the amount reported as available as once it hits 0 with the root
reserve only root can write to the FS.

2010-06-13 18:59:04

by Theodore Ts'o

[permalink] [raw]
Subject: Re: ext4 df free space reporting not reliable?

On Sun, Jun 13, 2010 at 12:34:51PM +0200, Andi Kleen wrote:
> > Are you creating the files as root? Sounds like the standard reserved
> > blocks behavior that's been around since ext3, ext2, BSD's ufs, etc...
>
> Yes everything is root.
>
> I would expect root df to not report the reservation. Is that not the case?

No, the reservation is always reported, regardless of which user ID is
executing the statfs(2) system call. This has always been true, going
all the way back to BSD 4.3.

I could see the argument for doing this differently, but I could also
see that being very surprising for people to see different results
depending on whether they are running df from a setuid shell or not.
I'm not aware of any Unix system which has implemented the root-only
reservation system which has done this.

- Ted