On Fri, May 01, 2020 at 10:25:44PM -0700, Phil Karn wrote: > I'm still not sure I understand what "balance" really does. I've run > it quite a few times, with increasing percentage limits as > recommended, but my drives never end up with equal amounts of data. > Maybe that's because I've got an oddball configuration involving > drives of two different sizes and (temporarily at least) an odd number > of drives. It *sounds* like it ought to do what you describe, but what > I read sounds more like an internal defragmentation operation on data > and metadata storage areas. Is it both? btrfs balance is mostly used to _free_ space (its other major use case is to convert raid profiles). Some raid levels (the mirroring and single profiles) allocate with the goal of equalizing free space on all drives, others (the striping profiles) equalize occupied space on all drives. raid10 does a bit of both. If you have a mixed striping and mirroring profile (e.g. raid5 data with raid1 metadata) then two opposing allocation policies happen at once, and the space used and free on each disk is determined by the two algorithms fighting it out. balance coalesces free space areas into larger contiguous chunks by reallocating all the existing data as if you had copied the files and deleted the originals in logical extent order. Sometimes people call this "defrag free space" but the use of the word "defrag" can be confusing. balance is not btrfs defrag. defrag is concerned with making data extents contiguous, while balance is concerned with making free space contiguous. > On Fri, May 1, 2020 at 9:48 PM Paul Jones <paul@xxxxxxxxxxxxxxx> wrote: > > > Delete seems to work like a balance. I've had a totally unbalanced > raid 1 array and after removing a single almost full drive all the > remaining drives are magically 50% full, down from 90% and up from > 10%. It's a bit stressful when there is a missing disk as you can only > delete a missing disk, not replace it. > > It would be nice if BTRFS had some more smarts so it knows when to > "balance" data, and when to simply "move/copy" a single copy of data. > > > > > > Paul.
