]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: statfs: report zero available if metadata are exhausted
authorDavid Sterba <dsterba@suse.com>
Sat, 10 Oct 2015 15:59:53 +0000 (17:59 +0200)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:45:52 +0000 (15:45 -0700)
commit5995864f4080a09b5560349e44c3257c0ce8163b
tree3655224c94f7b754e2d2c1481d9ab51daf2a11a0
parent33455813642800b3ea3298e774d1dd340cc6c678
btrfs: statfs: report zero available if metadata are exhausted

Orabug: 23331025

[ Upstream commit ca8a51b3a979d57b082b14eda38602b7f52d81d1 ]

There is one ENOSPC case that's very confusing. There's Available
greater than zero but no file operation succeds (besides removing
files). This happens when the metadata are exhausted and there's no
possibility to allocate another chunk.

In this scenario it's normal that there's still some space in the data
chunk and the calculation in df reflects that in the Avail value.

To at least give some clue about the ENOSPC situation, let statfs report
zero value in Avail, even if there's still data space available.

Current:
  /dev/sdb1             4.0G  3.3G  719M  83% /mnt/test

New:
  /dev/sdb1             4.0G  3.3G     0 100% /mnt/test

We calculate the remaining metadata space minus global reserve. If this
is (supposedly) smaller than zero, there's no space. But this does not
hold in practice, the exhausted state happens where's still some
positive delta. So we apply some guesswork and compare the delta to a 4M
threshold. (Practically observed delta was 2M.)

We probably cannot calculate the exact threshold value because this
depends on the internal reservations requested by various operations, so
some operations that consume a few metadata will succeed even if the
Avail is zero. But this is better than the other way around.

Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 4e3fa12f124507ad17f999c28ef35803596ff2c6)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/btrfs/super.c