linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugo Mills <hugo@carfax.org.uk>
To: Andrei Borzenkov <arvidjaar@gmail.com>
Cc: Chris Murphy <lists@colorremedies.com>,
	Martin Steigerwald <martin@lichtvoll.de>,
	Zygo Blaxell <ce3g8jdj@umail.furryterror.org>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: Understanding "Used" in df
Date: Mon, 27 Jul 2020 21:47:32 +0100	[thread overview]
Message-ID: <20200727204732.GJ12186@savella.carfax.org.uk> (raw)
In-Reply-To: <8034c0e6-a1d2-5ba9-fdcf-d9b355fd34d1@gmail.com>

On Mon, Jul 27, 2020 at 10:48:18PM +0300, Andrei Borzenkov wrote:
> 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.

   There's an O(n^2) algorithm in the number of devices. It's what I
used to implement the online space checker[1]. I've put up a write up
of the process at [2]. Without proof -- I wasn't able to work it out
-- but nobody's been able to catch it out yet.

   Hugo.

[1] https://carfax.org.uk/btrfs-usage/
[2] https://carfax.org.uk/files/temp/btrfs-allocator.pdf

-- 
Hugo Mills             | >squeek< *POP*
hugo@... carfax.org.uk | gluglugluglug
http://carfax.org.uk/  | <pause>
PGP: E2AB1DE4          | gluglugluglug!

  reply	other threads:[~2020-07-27 20:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 15:10 Understanding "Used" in df Martin Steigerwald
2020-07-22 19:07 ` A L
2020-07-23  4:51 ` Zygo Blaxell
2020-07-27 11:38   ` Martin Steigerwald
2020-07-27 16:42     ` Andrei Borzenkov
2020-07-27 19:30       ` Chris Murphy
2020-07-27 19:48         ` Andrei Borzenkov
2020-07-27 20:47           ` Hugo Mills [this message]
2020-07-28 21:20     ` Zygo Blaxell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200727204732.GJ12186@savella.carfax.org.uk \
    --to=hugo@carfax.org.uk \
    --cc=arvidjaar@gmail.com \
    --cc=ce3g8jdj@umail.furryterror.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    --cc=martin@lichtvoll.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).