Skip to content

Feature request: Add more balancing filters #993

@Forza-tng

Description

@Forza-tng

It think it would be useful to have additional balancing filters for more fine-grained control over what chunks that should be balanced.

My use-case is an unbalanced conversion from RAID1 to RAID10:

Data,RAID10: Size:55031.33GiB, Used:54990.07GiB (99.93%)
   /dev/sdg1    10404.27GiB
   /dev/sdc1    10403.27GiB
   /dev/sdk1    10404.27GiB
   /dev/sdp1    10404.27GiB
   /dev/sdx1    10403.27GiB
   /dev/sdad1   10404.27GiB
   /dev/sdab1   10404.27GiB
   /dev/sdz1    10403.27GiB
   /dev/sdw1    10403.27GiB
   /dev/sdy1    10404.27GiB
   /dev/sda1    6024.00GiB

Case 1

Using btrfs inspect-internal dump-tree --device we can see for each chunk item what stripe is on what device. For example, item 178421878161408 does not have a stripe on devid 27, which is /dev/sda1.

        item 7 key (FIRST_CHUNK_TREE CHUNK_ITEM 178416509452288) itemoff 14683 itemsize 368
                length 5368709120 owner 2 stripe_len 65536 type DATA|RAID10
                io_align 65536 io_width 65536 sector_size 4096
                num_stripes 10 sub_stripes 2
                        stripe 0 devid 15 offset 10659036135424
                        dev_uuid ac4afb76-8475-4af4-9bf4-5b8ce0e912dd
                        stripe 1 devid 16 offset 10659036135424
                        dev_uuid c52a732e-73e9-460d-b075-61584b44a617
                        stripe 2 devid 18 offset 9819370029056
                        dev_uuid b586966c-9b7a-42db-843c-1a6d0f420a18
                        stripe 3 devid 17 offset 9829033705472
                        dev_uuid 221850f8-2585-44fc-a6ac-7dc7e51b6f3e
                        stripe 4 devid 14 offset 9835711037440
                        dev_uuid d501f99f-7f76-4dcd-a6b2-efa64f4a8bde
                        stripe 5 devid 13 offset 9818329841664
                        dev_uuid c15a9ec1-4c99-4bcd-b272-37d9b5c58de1
                        stripe 6 devid 11 offset 9829033705472
                        dev_uuid 56b79aac-0892-4f34-a610-ddc7706bc6d1
                        stripe 7 devid 20 offset 9833777463296
                        dev_uuid 64d099f1-46f6-42fa-b89d-1544c92ab7b9
                        stripe 8 devid 19 offset 9828408754176
                        dev_uuid b258e15c-988a-418f-8eb8-c3978d5434b5
                        stripe 9 devid 27 offset 10711649484800
                        dev_uuid d1fe6aa3-b1bf-4c4d-aff7-c88f3d3b5970
        item 8 key (FIRST_CHUNK_TREE CHUNK_ITEM 178421878161408) itemoff 14315 itemsize 368
                length 5368709120 owner 2 stripe_len 65536 type DATA|RAID10
                io_align 65536 io_width 65536 sector_size 4096
                num_stripes 10 sub_stripes 2
                        stripe 0 devid 14 offset 9837858521088
                        dev_uuid d501f99f-7f76-4dcd-a6b2-efa64f4a8bde
                        stripe 1 devid 15 offset 10661183619072
                        dev_uuid ac4afb76-8475-4af4-9bf4-5b8ce0e912dd
                        stripe 2 devid 16 offset 10653667426304
                        dev_uuid c52a732e-73e9-460d-b075-61584b44a617
                        stripe 3 devid 18 offset 9830107447296
                        dev_uuid b586966c-9b7a-42db-843c-1a6d0f420a18
                        stripe 4 devid 12 offset 9833362227200
                        dev_uuid baa68f83-b3c4-4d39-a3ab-9ee6d2c62b41
                        stripe 5 devid 17 offset 9831181189120
                        dev_uuid 221850f8-2585-44fc-a6ac-7dc7e51b6f3e
                        stripe 6 devid 20 offset 9825187528704
                        dev_uuid 64d099f1-46f6-42fa-b89d-1544c92ab7b9
                        stripe 7 devid 13 offset 9829067259904
                        dev_uuid c15a9ec1-4c99-4bcd-b272-37d9b5c58de1
                        stripe 8 devid 11 offset 9831181189120
                        dev_uuid 56b79aac-0892-4f34-a610-ddc7706bc6d1
                        stripe 9 devid 19 offset 9830556237824
                        dev_uuid b258e15c-988a-418f-8eb8-c3978d5434b5

Case 2

I also discovered some chunk items with a different size than what I would have expected. Here we see 1040MB instead of 5GB. This means each stripe is 208MB (1040/5). This will become a problem as the filesystem fills up, creating fragmentation on the chunk level that can be difficult or slow to get out of.

        item 4 key (FIRST_CHUNK_TREE CHUNK_ITEM 186116328849408) itemoff 14443 itemsize 368
                length 1090519040 owner 2 stripe_len 65536 type DATA|RAID10
                io_align 65536 io_width 65536 sector_size 4096
                num_stripes 10 sub_stripes 2
                        stripe 0 devid 12 offset 2965927624704
                        dev_uuid baa68f83-b3c4-4d39-a3ab-9ee6d2c62b41
                        stripe 1 devid 19 offset 266507124736
                        dev_uuid b258e15c-988a-418f-8eb8-c3978d5434b5
                        stripe 2 devid 17 offset 2842195656704
                        dev_uuid 221850f8-2585-44fc-a6ac-7dc7e51b6f3e
                        stripe 3 devid 20 offset 267580866560
                        dev_uuid 64d099f1-46f6-42fa-b89d-1544c92ab7b9
                        stripe 4 devid 18 offset 2911133237248
                        dev_uuid b586966c-9b7a-42db-843c-1a6d0f420a18
                        stripe 5 devid 16 offset 2913280720896
                        dev_uuid c52a732e-73e9-460d-b075-61584b44a617
                        stripe 6 devid 11 offset 2958159773696
                        dev_uuid 56b79aac-0892-4f34-a610-ddc7706bc6d1
                        stripe 7 devid 15 offset 2914354462720
                        dev_uuid ac4afb76-8475-4af4-9bf4-5b8ce0e912dd
                        stripe 8 devid 13 offset 2956045844480
                        dev_uuid c15a9ec1-4c99-4bcd-b272-37d9b5c58de1
                        stripe 9 devid 14 offset 2969350176768
                        dev_uuid d501f99f-7f76-4dcd-a6b2-efa64f4a8bde

Balance Filters

  • For case 1, I see that an exclusion filter would be very useful. We could simply mask devid 27 for the devid filter:
btrfs balance start -ddevid=!27
  • For case 2, a filter for chunk size would be useful, possibly combined with a exclusion mask.
btrfs balance start -dchunk_len=1090519040
btrfs balance start -dchunk_len=!5G

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementkernelsomething in kernel has to be done too

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions