master - allocation: Allow approximate allocation when specifying size in percent
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b6e3b5e5ea682b4b6f7c77a447ccadc7f3c99c3 Commit: 4b6e3b5e5ea682b4b6f7c77a447ccadc7f3c99c3 Parent: f4658b53d7f3292c802f33f5fd0cca807870049f Author: Jonathan Brassow <[email protected]> AuthorDate: Thu Feb 13 21:10:28 2014 -0600 Committer: Jonathan Brassow <[email protected]> CommitterDate: Thu Feb 13 21:10:28 2014 -0600
allocation: Allow approximate allocation when specifying size in percent
Introduce a new parameter called "approx_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 -i 2 -l 100%FREE -n lv vg
--- lib/metadata/lv_alloc.h | 2 +- lib/metadata/lv_manip.c | 75 ++++++++++++++++++++++++---------- lib/metadata/metadata-exported.h | 4 +- lib/metadata/mirror.c | 6 +- lib/metadata/raid_manip.c | 4 +- lib/metadata/thin_manip.c | 2 +- test/shell/lvcreate-raid.sh | 84 ++++++++++++++++++++++++++++++++++++++ test/shell/lvcreate-raid10.sh | 8 ++++ tools/lvcreate.c | 2 + 9 files changed, 157 insertions(+), 30 deletions(-)
lib/metadata/lv_alloc.h +1 -1
@@ -54,7 +54,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg, 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 approx_alloc, struct dm_list *parallel_areas); int lv_add_segment(struct alloc_handle *ah,
lib/metadata/lv_manip.c +53 -22
166 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 approx_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 approx_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_context *cmd, struct logical_volume *lv, 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 *cmd, struct logical_volume *lv, 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 *cmd, struct logical_volume *lv, 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(struct logical_volume *lv,if (!(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 logical_volume *data_lv,if (!(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
@@ -677,7 +677,7 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents, seg_mirrors, seg->region_size, extents - lv->le_count,NULL , - pvh, lv->alloc)) + pvh, lv->alloc, 0)) return_0;return 1 ;
test/shell/lvcreate-raid.sh +84 -0
87 lines not on this page · raw message
test/shell/lvcreate-raid10.sh +8 -0
@@ -46,6 +46,14 @@ aux wait_for_sync $vg $lv2 lvremove -ff $vg +# Test 100%FREE option +# 37 extents / device +# 1 image = 36 extents (1 for meta) +# 3 images = 108 extents = 54.00m +lvcreate --type raid10 -i 3 -l 100%FREE -n raid10 $vg +check lv_field $vg/raid10 size "54.00m" +lvremove -ff $vg + # # FIXME: Add tests that specify particular PVs to use for creation #
tools/lvcreate.c +2 -0
@@ -363,6 +363,8 @@ static int _update_extents_params(struct volume_group *vg, }else lp->pvh = &vg->pvs; +if (lcp->percent) + lp->approx_alloc =1 ;switch (lcp->percent) {case PERCENT_VG : lp->extents =percent_of_extents (lp->extents, vg->extent_count,0 );