allocation: Allow "fuzzy" allocation when specifying size in percent
PATCH 1/1 allocation: Allow "fuzzy" allocation when specifying size in percent
This patch is still a bit rough around the edges and needs accompanying tests before in can be checked-in. If there are no objections to it, I'll clean it up a bit more and add the tests.
brassow
Introduce a new parameter called "fuzzy_alloc" that is set when the desired size of a new LV is specified in percentage terms. If set, the allocation code tries to get as much space as it can but does not fail if can at least get some.
One of the practical implications is that users can now specify 100%FREE when creating RAID LVs, like this:
~> lvcreate --type raid5 -l 100%FREE -n lv vg
(The stripe count is computed implicitly due to a previous patch, and the full size of the PVs in the VG is used.)
** This patch is not yet well tested and needs review **
lib/metadata/lv_alloc.h +1 -1
@@ -54,7 +54,7 @@ struct alloc_handle *allocate_extents(st uint32_t mirrors, uint32_t log_count, uint32_t log_region_size, uint32_t extents, struct dm_list *allocatable_pvs, - alloc_policy_t alloc, + alloc_policy_t alloc, int fuzzy_alloc, struct dm_list *parallel_areas); int lv_add_segment(struct alloc_handle *ah,
lib/metadata/lv_manip.c +50 -22
163 lines not on this page · raw message
lib/metadata/metadata-exported.h +3 -1
@@ -672,7 +672,8 @@ int lv_extend(struct logical_volume *lv, uint32_t stripes, uint32_t stripe_size, uint32_t mirrors, uint32_t region_size, uint32_t extents, const char *thin_pool_name, - struct dm_list *allocatable_pvs, alloc_policy_t alloc); + struct dm_list *allocatable_pvs, alloc_policy_t alloc, + int fuzzy_alloc);/* lv must be part of lv->vg->lvs */ int lv_remove (struct logical_volume *lv);
@@ -810,6 +811,7 @@ struct lvcreate_params {uint32_t permission;/* all */ uint32_t read_ahead;/* all */ +int fuzzy_alloc;/* all */ alloc_policy_t alloc;/* all */ struct dm_list tags;/* all */
lib/metadata/mirror.c +3 -3
@@ -1676,7 +1676,7 @@ int add_mirrors_to_segments(struct cmd_c region_size);if (!(ah =allocate_extents (lv->vg,NULL , segtype,1 , mirrors,0 ,0 , - lv->le_count, allocatable_pvs, alloc, + lv->le_count, allocatable_pvs, alloc,0 , parallel_areas))) {log_error ("Unable to allocate mirror extents for %s." , lv->name);return 0 ;
@@ -1944,7 +1944,7 @@ int add_mirror_log(struct cmd_context *c ah =allocate_extents (lv->vg,NULL , segtype,0 ,0 , log_count - old_log_count, region_size, lv->le_count, allocatable_pvs, - alloc, parallel_areas); + alloc,0 , parallel_areas);if (!ah) {log_error ("Unable to allocate extents for mirror log." );return 0 ;
@@ -2008,7 +2008,7 @@ int add_mirror_images(struct cmd_context ah =allocate_extents (lv->vg,NULL , segtype, stripes, mirrors, log_count, region_size, lv->le_count, - allocatable_pvs, alloc, parallel_areas); + allocatable_pvs, alloc,0 , parallel_areas);if (!ah) {log_error ("Unable to allocate extents for mirror(s)." );return 0 ;
lib/metadata/raid_manip.c +2 -2
@@ -419,7 +419,7 @@ static int _alloc_image_components(strucif (!(ah =allocate_extents (lv->vg,NULL , segtype,0 , count, count, region_size, extents, pvs, - lv->alloc, parallel_areas))) + lv->alloc,0 , parallel_areas))) return_0;for (s =0 ; s < count; s++) {
@@ -483,7 +483,7 @@ static int _alloc_rmeta_for_lv(struct loif (!(ah =allocate_extents (data_lv->vg,NULL , seg->segtype,0 ,1 ,0 , seg->region_size,1 /*RAID_METADATA_AREA_LEN*/ , - &allocatable_pvs, data_lv->alloc,NULL ))) + &allocatable_pvs, data_lv->alloc,0 ,NULL ))) return_0; if (!_alloc_image_component(data_lv, base_name, ah, 0,
lib/metadata/thin_manip.c +1 -1
@@ -678,7 +678,7 @@ int handle_pool_metadata_spare(struct vo seg_mirrors, seg->region_size, extents - lv->le_count,NULL , - pvh, lv->alloc)) + pvh, lv->alloc, 0)) return_0;return 1 ;
tools/lvcreate.c +2 -0
@@ -363,6 +363,8 @@ static int _update_extents_params(struct }else lp->pvh = &vg->pvs; +if (lcp->percent) + lp->fuzzy_alloc =1 ;switch (lcp->percent) {case PERCENT_VG : lp->extents =percent_of_extents (lp->extents, vg->extent_count,0 );
test/shell/lvcreate-raid.sh +9 -0
@@ -110,3 +110,12 @@ lv_devices $vg raid6 6 lvcreate --type raid10 -l2 -n raid10 $vg lv_devices $vg raid10 6 lvremove -ff $vg + +# Create RAID using 100%FREE +############################ +lvcreate --type raid1 -l 100%FREE -n raid1 $vg +lvremove -ff $vg +lvcreate --type raid5 -l 100%FREE -n raid5 $vg +lvremove -ff $vg +lvcreate --type raid6 -l 100%FREE -n raid6 $vg +lvremove -ff $vg
test/shell/lvcreate-raid10.sh +4 -0
@@ -46,6 +46,10 @@ aux wait_for_sync $vg $lv2 lvremove -ff $vg +# Test 100%FREE option (requires implicit stripe/mirror calculation) +lvcreate --type raid10 -l 100%FREE -n raid10 $vg +lvremove -ff $vg + # # FIXME: Add tests that specify particular PVs to use for creation #
PATCH 1/1 allocation: Allow "fuzzy" allocation when specifying size in percent
Dne 11.2.2014 00:29, Jonathan Brassow napsal(a):
Quoted 12 lines
This patch is still a bit rough around the edges and needs accompanying tests before in can be checked-in. If there are no objections to it, I'll clean it up a bit more and add the tests.
brassow
Introduce a new parameter called "
fuzzy_alloc" that is set when the desired size of a new LV is specified in percentage terms. If set, the allocation code tries to get as much space as it can but does not fail if can at least get some.
Quoted 7 lines
One of the practical implications is that users can now specify 100%FREE when creating RAID LVs, like this:
~> lvcreate --type raid5 -l 100%FREE -n lv vg(The stripe count is computed implicitly due to a previous patch, and the full size of the PVs in the VG is used.)
I wouldn't call it 'fuzzy' - I guess we've discussed something like - extent exact or up-to given number of extents allocation
Zdenek