Fixing the chunk allocator to allow it to better utilize the devices
PATCH 1/1 Fixing the chunk allocator to allow it to better utilize the devices
The chunk allocator had several small bugs that prevented it to use the devices fully in multi-device setups.find_free_dev_extent didn't return max_avail correctly if the largest hole was at the end of the device. Also it disregarded alloc_start in certain situations.
It has also been restructured for better readability.
__btrs_alloc_chunk now uses the returned max_avail to determine the maximum chunk available for its again-loop, instead of the total amount of free space of the device, which might not be available in one piece. It also uses the devices in a round robin fashion, which help balancing the devices better.
Signed-off-by Arne Jansen <[email protected]>
--- fs/btrfs/extent-tree.c | 4 +- fs/btrfs/volumes.c | 135 +++++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 66 deletions(-)
fs/btrfs/extent-tree.c +2 -2
@@ -8049,7 +8049,7 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)mutex_lock (&root->fs_info->chunk_mutex);list_for_each_entry (device, &fs_devices->alloc_list, dev_alloc_list) {u64 min_free =btrfs_block_group_used (&block_group->item); -u64 dev_offset, max_avail; +u64 dev_offset;/* * check to make sure we can actually find a chunk with enough
@@ -8057,7 +8057,7 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)*/ if (device->total_bytes > device->bytes_used + min_free) { ret =find_free_dev_extent (NULL , device, min_free, - &dev_offset, &max_avail); + &dev_offset,NULL );if (!ret)break ; ret =-1 ;
fs/btrfs/volumes.c +71 -64
240 lines not on this page · raw message
Signature · 1 line
1.7.2.2