Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Russell Coker <russell@coker.com.au>, linux-btrfs@vger.kernel.org
Subject: Re: btrfs-progs: btrfs dev usa as non-root is wrong and should just abort
Date: Thu, 11 Jul 2024 13:17:59 +0930	[thread overview]
Message-ID: <ad3498e5-d41a-40ce-be73-c5d9de4f85a1@gmx.com> (raw)
In-Reply-To: <4914581.rnE6jSC6OK@cupcakke>



在 2024/7/11 13:12, Russell Coker 写道:
> On Thursday, 11 July 2024 07:13:25 AEST Qu Wenruo wrote:
>> 在 2024/7/10 21:22, Russell Coker 写道:
>>> 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
>>>      Device slack:           16.00EiB
>>>      Unallocated:           476.37GiB
>>
>> Mind to post the raw result?
>>
>> The 16EiB output definitely means something wrong.
>>
>> So far the result looks like btrfs-progs is interpret the result wrong
>> with some offset of the result.
>>
>> In my case, non-root call of "btrfs dev usage" always shows the slack as
>> 0, and unallocated as N/A, so the 16EiB looks like some shift.
>
> # btrfs dev usa -b /
> /dev/mapper/root, ID: 1
>     Device size:          511493395968

The device size is 4K aligned.

I guess it's some older fs? As newer mkfs would always round down to the
sector size.


>     Device slack:               1536
>     Data,single:          231936622592
>     Metadata,DUP:         6442450944
>     System,DUP:             67108864
>     Unallocated:          273047212032
>
> $ btrfs dev usa -b /
> WARNING: cannot read detailed chunk info, per-device usage will not be shown,
> run as root
> /dev/mapper/root, ID: 1
>     Device size:           999010539
>     Device slack:         18446743563215167723
>     Unallocated:          511493394432
>
>> And what's the version of the btrfs-progs?
>
> The Debian package version is 6.6.3-1.2+b1.
>

It may be easier to debug by trying a newer version of btrfs-progs.

And since I'm not sure if it's the unalignment causing problems, you may
want to resize the fs by:

# btrfs device resize -1M <mnt>

Then resize to max (which should always align the fs correctly):

# btrfs device resize max <mnt>

And then check if the size is aligned to 4K and if the problem has changed.

Thanks,
Qu

  reply	other threads:[~2024-07-11  3:48 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
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 [this message]
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=ad3498e5-d41a-40ce-be73-c5d9de4f85a1@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --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