Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Russell Coker <russell@coker.com.au>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: btrfs-progs: btrfs dev usa as non-root is wrong and should just abort
Date: Wed, 10 Jul 2024 09:29:38 -0700	[thread overview]
Message-ID: <20240710162938.GA3394284@zen.localdomain> (raw)
In-Reply-To: <2159193.PIDvDuAF1L@cupcakke>

On Wed, Jul 10, 2024 at 09:52:14PM +1000, Russell Coker wrote:
> Below is the difference between running btrfs dev usa as root and non-root on 
> a laptop with kernel 6.8.12-amd64.  When run as non-root it gets everything 
> wrong and in my tests I have never been able to see it give nay accurate data 
> as non-root.  I think it should just abort with an error in that situation, 
> there's no point in giving a wrong answer.
> 
> # btrfs dev usa /
> /dev/mapper/root, ID: 1
>    Device size:           476.37GiB
>    Device slack:            1.50KiB
>    Data,single:           216.01GiB
>    Metadata,DUP:            6.00GiB
>    System,DUP:             64.00MiB
>    Unallocated:           254.29GiB
> 
> $ btrfs dev usa /
> WARNING: cannot read detailed chunk info, per-device usage will not be shown, 
> run as root
> /dev/mapper/root, ID: 1
>    Device size:           952.73MiB
Hmm..
>    Device slack:           16.00EiB
>    Unallocated:           476.37GiB
Also wrong, but at least it's the "size" number?!

btrfs device usage (and btrfs filesystem usage) usually give
pretty reasonable results without root on my systems, so this is sort of
surprising to me, especially since it looks like we both have the same
trivial raid/volume setup and you are on a relatively new kernel.
e.g., on my system running 6.9:

$ sudo btrfs dev usage /home
/dev/mapper/vol-home, ID: 1
   Device size:           826.50GiB
   Device slack:              0.00B
   Data,single:           117.01GiB
   Metadata,DUP:            2.00GiB
   System,DUP:             16.00MiB
   Unallocated:           707.47GiB

$ btrfs dev usage /home
WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
/dev/mapper/vol-home, ID: 1
   Device size:           826.50GiB
   Device slack:              0.00B
   Unallocated:                 N/A

I suppose my non-root output is lacking usage information, it at least
gets the size right.

Does the same discrepancy happen for you when running
'btrfs filesystem usage /' with and without root? That command gives me
lots of useful, interesting output without root. e.g.,

$ btrfs fi usage /home
WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
Overall:
    Device size:                 826.50GiB
    Device allocated:            119.02GiB
    Device unallocated:          707.47GiB
    Device missing:                  0.00B
    Device slack:                    0.00B
    Used:                        109.38GiB
    Free (estimated):            716.59GiB      (min: 362.85GiB)
    Free (statfs, df):           716.59GiB
    Data ratio:                       1.00
    Metadata ratio:                   2.00
    Global reserve:              168.02MiB      (used: 0.00B)
    Multiple profiles:                  no

Data,single: Size:117.01GiB, Used:107.89GiB (92.21%)

Metadata,DUP: Size:1.00GiB, Used:764.42MiB (74.65%)

System,DUP: Size:8.00MiB, Used:16.00KiB (0.20%)

Thanks,
Boris

> 
> -- 
> My Main Blog         http://etbe.coker.com.au/
> My Documents Blog    http://doc.coker.com.au/
> 
> 
> 

  reply	other threads:[~2024-07-10 16:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10 11:52 btrfs-progs: btrfs dev usa as non-root is wrong and should just abort Russell Coker
2024-07-10 16:29 ` Boris Burkov [this message]
2024-07-11  3:50   ` Russell Coker
2024-07-10 21:13 ` Qu Wenruo
2024-07-11  3:42   ` Russell Coker
2024-07-11  3:47     ` Qu Wenruo
2024-07-11  3:55       ` Russell Coker
2024-07-11  3:58         ` Qu Wenruo

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=20240710162938.GA3394284@zen.localdomain \
    --to=boris@bur.io \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=russell@coker.com.au \
    /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