These patches aim to add 2 new subcommands that:
-> provide information about block groups
-> help to decide whether balance can reduce the no. of data block groups and if
 it can, provides the block group object id for "-dvrange"

[PATCH 1/3] btrfs-progs: Generic functions to retrieve chunks and their bg info
[PATCH 2/3] btrfs-progs: Add a command to show bg info
[PATCH 3/3] btrfs-progs: Add command to check if balance op is req

Now, you can run:
-------------------------------------------------------------------------------
$ btrfs inspect-internal balance_check /mnt/btrfs
               Start                 Len                Used
            12582912             8.00MiB           128.00KiB
           136708096           208.00MiB            74.00MiB

Total data bgs: 2
Total free space: 141.88MiB
For min used bg 12582912 used = 128.00KiB free = 7.88MiB
run 'btrfs balance start -dvrange=12582912..12582913 <mountpoint>'

$ btrfs balance start -dvrange=12582912..12582913 /mnt/btrfs
Done, had to relocate 1 out of 4 chunks

$ btrfs inspect-internal balance_check /mnt/btrfs
               Start                 Len                Used
           136708096           208.00MiB            74.12MiB
Data block groups in fs = 1, no need to do balance.

$ btrfs inspect-internal bg_analysis /mnt/btrfs

                Type               Start                 Len                Used
              SYSTEM            20971520             8.00MiB            16.00KiB
            METADATA            29360128           102.38MiB           192.00KiB
                DATA           136708096           208.00MiB            74.12MiB
-------------------------------------------------------------------------------

Thanks to the suggestion by Hans van Kranenburg, and the python-btrfs module,
an efficient alternative to retrieving block groups could be used:
Now, it first looks at the chunk tree, and for every chunk listed it looks up an
exact match in the extent tree.

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to