btrfs-progs: btrfs dev usa as non-root is wrong and should just abort
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
Signature · 2 lines
My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/
Quoted 15 lines · 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
Quoted 5 lines
$ 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..
Quoted 2 lines
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: noData,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
Quoted 7 lines
Signature · 3 lines
-- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/
Quoted 7 lines · On Thursday, 11 July 2024 02:29:38 AEST Boris Burkov wrote:
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:
I'm surprised that it worked for anyone, my experience was that it fails on all systems and I had assumed that was the general experience.
Quoted 3 lines
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.,
For me btrfs fi usa gives me almost everything as non-root. A bogus value for device slack is the only thing wrong.
# btrfs fi usa /
Overall:
Device size: 476.37GiB
Device allocated: 222.07GiB
Device unallocated: 254.29GiB
Device missing: 0.00B
Device slack: 1.50KiB
Used: 209.94GiB
Free (estimated): 263.99GiB (min: 136.84GiB)
Free (statfs, df): 263.99GiB
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 385.50MiB (used: 0.00B)
Multiple profiles: noData,single: Size:216.01GiB, Used:206.31GiB (95.51%)
/dev/mapper/root 216.01GiB
Metadata,DUP: Size:3.00GiB, Used:1.81GiB (60.50%)
/dev/mapper/root 6.00GiB
System,DUP: Size:32.00MiB, Used:48.00KiB (0.15%)
/dev/mapper/root 64.00MiB
Unallocated:
/dev/mapper/root 254.29GiB
$ btrfs fi usa /
WARNING: cannot read detailed chunk info, per-device usage will not be shown,
run as root
Overall:
Device size: 476.37GiB
Device allocated: 222.07GiB
Device unallocated: 254.29GiB
Device missing: 0.00B
Device slack: 16.00EiB
Used: 209.94GiB
Free (estimated): 263.99GiB (min: 136.84GiB)
Free (statfs, df): 263.99GiB
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 385.50MiB (used: 0.00B)
Multiple profiles: noData,single: Size:216.01GiB, Used:206.31GiB (95.51%)
Metadata,DUP: Size:3.00GiB, Used:1.81GiB (60.50%)
System,DUP: Size:32.00MiB, Used:48.00KiB (0.15%)
Signature · 2 lines
My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/
Quoted 15 lines · 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
Quoted 8 lines
$ 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.37GiBMind 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.
And what's the version of the btrfs-progs?
Thanks,
Qu
Quoted 28 lines · On Thursday, 11 July 2024 07:13:25 AEST Qu Wenruo wrote:
Quoted 16 lines · 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: 1Device size: 476.37GiB
Device slack: 1.50KiB
Data,single: 216.01GiB
Metadata,DUP: 6.00GiB
System,DUP: 64.00MiB
Unallocated: 254.29GiBQuoted 8 lines
$ btrfs dev usa / WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root /dev/mapper/root, ID: 1Device size: 952.73MiB
Device slack: 16.00EiB
Unallocated: 476.37GiBMind to post the raw result?
Quoted 7 lines
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 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
Quoted 1 line
And what's the version of the btrfs-progs?
The Debian package version is 6.6.3-1.2+b1.
Signature · 2 lines
My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/
Quoted 34 lines · Russell Coker
Quoted 33 lines · On Thursday, 11 July 2024 07:13:25 AEST Qu Wenruo wrote:
Quoted 16 lines · 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: 1Device size: 476.37GiB
Device slack: 1.50KiB
Data,single: 216.01GiB
Metadata,DUP: 6.00GiB
System,DUP: 64.00MiB
Unallocated: 254.29GiBQuoted 8 lines
$ btrfs dev usa / WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root /dev/mapper/root, ID: 1Device size: 952.73MiB
Device slack: 16.00EiB
Unallocated: 476.37GiBMind 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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 14 lines
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
Quoted 4 lines
Quoted 1 line
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
Quoted 9 lines · On Thursday, 11 July 2024 13:47:59 AEST Qu Wenruo wrote:
Quoted 4 lines
# btrfs dev usa -b / /dev/mapper/root, ID: 1Device size: 511493395968The device size is 4K aligned.
I guess it's some older fs? As newer mkfs would always round down to the sector size.
My recollection is that I had run mkfs on a system running Debian/Bookworm which had different hardware and then used dd to copy it to this one.
Quoted 21 lines
Quoted 11 lines
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: 1Quoted 7 lines
Device size: 999010539 Device slack: 18446743563215167723 Unallocated: 511493394432Quoted 2 lines
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.
Quoted 8 lines
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>
root@cupcakke:/tmp# btrfs fi resize 1:-1M / Resize device id 1 (/dev/mapper/root) from 476.37GiB to 476.36GiB root@cupcakke:/tmp# btrfs fi resize 1:max / Resize device id 1 (/dev/mapper/root) from 476.36GiB to max
etbe@cupcakke:/tmp$ 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
etbe@cupcakke:/tmp$ 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
That doesn't seem to have changed anything.
Signature · 2 lines
My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/
Quoted 49 lines · Russell Coker
Quoted 9 lines · On Thursday, 11 July 2024 13:47:59 AEST Qu Wenruo wrote:
Quoted 4 lines
# btrfs dev usa -b / /dev/mapper/root, ID: 1Device size: 511493395968The device size is 4K aligned.
I guess it's some older fs? As newer mkfs would always round down to the sector size.
My recollection is that I had run mkfs on a system running Debian/Bookworm which had different hardware and then used dd to copy it to this one.
Quoted 21 lines
Quoted 11 lines
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: 1Quoted 7 lines
Device size: 999010539 Device slack: 18446743563215167723 Unallocated: 511493394432Quoted 2 lines
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.
Quoted 8 lines
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>root@cupcakke:/tmp# btrfs fi resize 1:-1M / Resize device id 1 (/dev/mapper/root) from 476.37GiB to 476.36GiB root@cupcakke:/tmp# btrfs fi resize 1:max / Resize device id 1 (/dev/mapper/root) from 476.36GiB to max
Quoted 7 lines
etbe@cupcakke:/tmp$ 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: 511493394432What about the usage output using root privilege?
Just want to be sure that the fs is properly resized to be 4K aligned.
Quoted 11 lines
etbe@cupcakke:/tmp$ 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.37GiBThat doesn't seem to have changed anything.
And what about newer progs?
Thanks,
Qu