HomeFreeBSD

Allocate disk space fairly in the presence of vdevs of unequal size.

Description

Allocate disk space fairly in the presence of vdevs of unequal size.

The metaslab allocator device selection algorithm contains a bias
mechanism whose goal is to achieve roughly equal disk space usage across
all top-level vdevs.

It seems that the initial rationale for this code was to allow newly
added (empty) vdevs to "come up to speed" faster in an attempt to make
the pool quickly converge to a steady state where all vdevs are equally
utilized.

While the code seems to work reasonably well for this use case, there
is another scenario in which this algorithm fails miserably: the case
where top-level vdevs don't have the same sizes (capacities). ZFS
allows this, and it is a good feature to have, so that users who simply
want to build a pool with the disks they happen to have lying around can
do so even if the disks have heteregenous sizes.

Here's a script that simulates a pool with two vdevs, with one 4X larger
than the other:

dd if=/dev/zero of=/tmp/d1 bs=1 count=1 seek=134217728
dd if=/dev/zero of=/tmp/d2 bs=1 count=1 seek=536870912
zpool create testspace /tmp/d1 /tmp/d2
dd if=/dev/zero of=/testspace/foobar bs=1M count=256
zpool iostat -v testspace

Before this commit, the script would output the following:

               capacity
pool        alloc   free
----------  -----  -----
testspace    252M   375M
  /tmp/d1    104M  18.5M
  /tmp/d2    148M   356M
----------  -----  -----

This demonstrates that the current code handles this situation very
poorly: d1 shows 85% usage despite the pool itself being only 40% full.
d1 is quite saturated at this point, and is slowing down the entire pool
due to saturation, fragmentation and the like.

In contrast, here's the result with the code in this commit:

                capacity
 pool        alloc   free
 ----------  -----  -----
 testspace    252M   375M
   /tmp/d1   56.7M  66.3M
   /tmp/d2    195M   309M
----------  -----  ------

This looks much better. d1 is 46% used, which is close to the overall
pool utilization (40%). The code still doesn't result in perfectly
balanced allocation, probably because of the way mg_bias is applied
which does not guarantee perfect accuracy, but this is still much better
than before.

Signed-off-by: Etienne Dechamps <etienne@edechamps.fr>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3389

Details

Provenance
Etienne Dechamps <etienne@edechamps.fr>Authored on May 10 2015, 2:39 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Jun 22 2015, 9:18 PM
Parents
rG218b4e0a7608: Add zfs_sb_prune_aliases() function
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rGbb3250d07ec8: Allocate disk space fairly in the presence of vdevs of unequal size. (authored by Etienne Dechamps <etienne@edechamps.fr>).Jun 22 2015, 9:18 PM