On Thu, Dec 27, 2018 at 1:33 PM <joshua@xxxxxxxxxxx> wrote:
>
> Perhaps my original assumptions were incorrect, but I had originally assumed that since both the
> commands I ran were 'btrfs fi' commands, that they would be reporting on the same things, just in
> different formats. (btrfs fi show & btrfs fi usage)
> I also assumed, (perhaps incorrectly) that since they were "filesystem" commands, (btrfs fi) they
> would be reporting on the amounts directly available to btrfs.
>
> Regardless, after running replace, but before running resize, 'btrfs fi show' reported the
> following:
> devid 4 size 2.73TiB used 2.57TiB path /dev/sdu
devid size should match super block dev_item.total_bytes, and devid
used should match super block dev_item.bytes_used
dev_item.total_bytes normally matches the bytes for the block device
in question; but due to resize it might not match.
> However, 'btrfs fi usage -T /mnt/data' reported the following:
> Overall:
> Device size: 67.31TiB
> Device allocated: 41.73TiB
> Device unallocated: 25.58TiB
> Device missing: 0.00B
> Used: 41.69TiB
> Free (estimated): 12.81TiB (min: 12.81TiB)
> Data ratio: 2.00
> Metadata ratio: 2.00
> Global reserve: 512.00MiB (used: 0.00B)
>
> Data Metadata System
> Id Path RAID1 RAID1 RAID1 Unallocated
> -- -------- -------- -------- -------- -----------
> 4 /dev/sdu 2.57TiB 3.00GiB - 6.53TiB
> {-snip-}
> -- -------- -------- -------- -------- -----------
> Total 20.84TiB 31.00GiB 32.00MiB 31.95TiB
> Used 20.82TiB 29.60GiB 2.98MiB
>
> Of particular interest here is that the data in the header (Overall) is no different than before
> the replace, so it is fully aware the space is not (yet) usable, and thus reporting it correctly.
> Just the Unallocated column is potentially misleading (and the totals at the bottom)
OK let me see if I get this right. You're saying it's confusing that
'btrfs fi sh' "devid size" does not change when doing a device
replace; whereas 'btrfs fi us' device specific "unallocated" does
change, even though you haven't yet done a resize.
I kinda sorta agree. While "unallocated" becomes 6.53TiB for this
device, the idea it's unallocated suggests it could be allocated,
which before a resize it cannot be allocated.
Someone would have to dig into the btrfs-progs code and see how
"unallocated" is computed per device, maybe there's a rationalization
in the comments. I'd say it's confusing if unallocated for a device is
greater than either 'btrfs fi sh' "devid size" or dev_item.total_bytes
found in the super for that device.
> I should note that every device in this particular Array/Pool is not using partitions; I'm using
> btrfs directly on the device. Perhaps this is why btrfs is handling it this way? I wonder how it
> behaves on a partitioned FileSystem.
It behaves the same. Whether partitioned or not, Btrfs sees it as a
block device.
--
Chris Murphy