On Mon, Dec 24, 2018 at 10:21 AM <joshua@xxxxxxxxxxx> wrote:
>
> I generally use this command to check my drive usage: `btrfs fi usage -T /mnt/data` But this time
> it didn't give me useful information:
>
> I decided to begin replacing a few of my drives with larger drives, so I could remove a lot of my
> smaller drives. I ran this command:
> 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/sda 2.57TiB 3.00GiB - 164.52GiB
> {-snip-}
>
> I then started the replace with this command: `btrfs replace start 4 /dev/sdu /mnt/data`
> Everything went well, so I checked again:
> root@CENTAUR:~# btrfs fi usage -T /mnt/data
> 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-}
>
> For a brief moment I was confused, and ran this command to double-check:
> root@CENTAUR:~# btrfs fi sh
> Label: 'DATA' uuid: ddafe51b-e1e8-4f4b-bcca-057f53b59a8d
> Total devices 17 FS bytes used 20.84TiB
> {-snip-}
> devid 4 size 2.73TiB used 2.57TiB path /dev/sdu
> {-snip-}
>
> Oh right, I have to run resize! So I run resize, and everything works exactly as expected.
>
> However, shouldn't `btrfs fi usage -T` only report the usable space in the unallocated column?
> `btrfs fi sh` only reports the available space correctly.
> Perhaps there is a reason for this behavior? If not, it's a little confusing, and should really be
> brought into line with `btrfs fi sh` IMO.
>
> For reference, here is what I ran afterwards:
>
> root@CENTAUR:~# btrfs fi resize 4:max /mnt/data
> Resize '/mnt/data' of '4:max'
> root@CENTAUR:~# btrfs fi sh
> Label: 'DATA' uuid: ddafe51b-e1e8-4f4b-bcca-057f53b59a8d
> Total devices 17 FS bytes used 20.84TiB
> {-snip-}
> devid 4 size 9.10TiB used 2.57TiB path /dev/sdu
> {-snip-}
>
> root@CENTAUR:~# btrfs fi usage -T /mnt/data
> Overall:
> Device size: 73.68TiB
> Device allocated: 41.73TiB
> Device unallocated: 31.95TiB
> Device missing: 0.00B
> Used: 41.69TiB
> Free (estimated): 15.99TiB (min: 15.99TiB)
> 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-}
>
> So everything is as I expect it to be afterwards- All ready to begin removing multiple drives.
I'm not really following this. An fs resize is implied by any device
add, remove or replace command. In the case of replace, it will
efficiently copy the device being replaced to the designated drive,
and then once that succeeds resize the file system to reflect the size
of the replacement device. I'm also confused why devid 4 seems to be
present before and after your device replace, so I have to wonder if
your copy paste really worked out as intended? And also, what version
of kernel and btrfs-progs are you using?
What do you mean by "usable space" and "available space"? It is
possibly confusing, the new and old tools intentional do things
differently, but it really depends on what you're referring to. I
suggest going to the faq and check out these two sections:
https://btrfs.wiki.kernel.org/index.php/FAQ
4.7.1 Understanding free space, using the original tools
4.7.2 Understanding free space, using the new tools
"unallocated" and "allocated" are specific terms that refer to block
groups (chunks). Space that's unallocated has no block groups, space
that's allocated is reserved for block groups; and inside each block
group there can be unused space. "Free space" is considered to be the
unused space in block groups plus unallocated space.
btrfs filesystem show is confusing because "used" seems to be a term
used twice. The decoder ring is:
'fi show' "FS bytes used" as equal to 'fi usage' "Used"; and
'fi show' "devid ... used" as equal to 'fi usage' "Device allocated".
--
Chris Murphy