master - raid/misc: Allow creation of parallel areas by LV vs segment
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b35fb0b15af1d87693be286f0630e95622056a77 Commit: b35fb0b15af1d87693be286f0630e95622056a77 Parent: 1f1675b059d65768524398791b2e505b7dfe2497 Author: Jonathan Brassow <[email protected]> AuthorDate: Wed Jun 25 21:20:41 2014 -0500 Committer: Jonathan Brassow <[email protected]> CommitterDate: Wed Jun 25 21:20:41 2014 -0500
raid/misc: Allow creation of parallel areas by LV vs segment
I've changed build_parallel_areas_from_lv to take a new parameter that allows the caller to build parallel areas by LV vs by segment. Previously, the function created a list of parallel areas for each segment in the given LV. When it came time for allocation, the parallel areas were honored on a segment basis. This was problematic for RAID because any new RAID image must avoid being placed on any PVs used by other images in the RAID. For example, if we have a linear LV that has half its space on one PV and half on another, we do not want an up-convert to use either of those PVs. It should especially not wind up with the following, where the first portion of one LV is paired up with the second portion of the other:
------PV1------- ------PV2------- [ 2of2 image_1 ] [ 1of2 image_1 ] [ 1of2 image_0 ] [ 2of2 image_0 ] ---------------- ----------------
Previously, it was possible for this to happen. The change makes it so that the returned parallel areas list contains one "super" segment (seg_pvs) with a list of all the PVs from every actual segment in the given LV and covering the entire logical extent range.
This change allows RAID conversions to function properly when there are existing images that contain multiple segments that span more than one PV.
--- WHATS_NEW | 1 + lib/metadata/lv_alloc.h | 3 +- lib/metadata/lv_manip.c | 55 +++++++++++++++++++++-------- lib/metadata/mirror.c | 6 ++-- lib/metadata/raid_manip.c | 2 +- test/shell/lvconvert-raid-allocation.sh | 57 +++++++++++++++++++++++++++++++ test/shell/lvconvert-raid.sh | 22 ------------ 7 files changed, 104 insertions(+), 42 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.108 - ================================= + New RAID images now avoid allocation on any PVs in the same parent RAID LV. Always reevaluate filters just before creating PV. Version 2.02.107 - 23rd June 2014
lib/metadata/lv_alloc.h +2 -1
@@ -86,6 +86,7 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,void alloc_destroy (struct alloc_handle *ah);struct dm_list *build_parallel_areas_from_lv (struct logical_volume *lv, -unsigned use_pvmove_parent_lv); +unsigned use_pvmove_parent_lv, +unsigned create_single_list);#endif
lib/metadata/lv_manip.c +40 -15
88 lines not on this page · raw message
lib/metadata/mirror.c +3 -3
@@ -1687,7 +1687,7 @@ static int _add_mirrors_that_preserve_segments(struct logical_volume *lv,uint32_t adjusted_region_size;int r =1 ; -if (!(parallel_areas =build_parallel_areas_from_lv (lv,1 ))) +if (!(parallel_areas =build_parallel_areas_from_lv (lv,1 ,0 ))) return_0;if (!(segtype =get_segtype_from_string (cmd,"mirror" )))
@@ -1971,7 +1971,7 @@ int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,return 1 ; } -if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ))) +if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ,0 ))) return_0;if (!(segtype =get_segtype_from_string (cmd,"mirror" )))
@@ -2044,7 +2044,7 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,* allocate destination extents */ -if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ))) +if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ,0 ))) return_0;if (!(segtype =get_segtype_from_string (cmd,"mirror" )))
lib/metadata/raid_manip.c +1 -1
@@ -392,7 +392,7 @@ static int _alloc_image_components(struct logical_volume *lv,if (!lvl_array) return_0; -if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ))) +if (!(parallel_areas =build_parallel_areas_from_lv (lv,0 ,1 ))) return_0;if (seg_is_linear (seg))
test/shell/lvconvert-raid-allocation.sh new file +57 -0
57 lines not on this page · raw message
test/shell/lvconvert-raid.sh +0 -22
@@ -202,26 +202,4 @@ for i in {1..3}; do lvremove -ff $vg done -# Setup 2-way RAID1 LV to spread across 4 devices. -# For each image: -# - metadata LV + 1 image extent (2 total extents) on one PV -# - 2 image extents on the other PV -# Then attempt allocation of another image from 2 extents on -# a 5th PV and the remainder of the rest of already used PVs. -# -# This should fail because there is insufficient space on the -# non-parallel PV (i.e. there is not enough space for the image -# if it doesn't share a PV with another image). -lvcreate --type raid1 -m 1 -l 3 -n $lv1 $vg \ - "$dev1:0-1" "$dev2:0-1" "$dev3:0-1" "$dev4:0-1" -aux wait_for_sync $vg $lv1 -# Should not be enough non-overlapping space. -not lvconvert -m +1 $vg/$lv1 \ - "$dev5:0-1" "$dev1" "$dev2" "$dev3" "$dev4" -# Should work due to '--alloc anywhere' -lvconvert -m +1 --alloc anywhere $vg/$lv1 \ - "$dev5:0-1" "$dev1" "$dev2" "$dev3" "$dev4" -lvremove -ff $vg - - vgremove -ff $vg