From 3477dd6c193c7147181c7f706ad87e17d58dedde Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 23 Jun 2011 10:53:24 +0000 Subject: [PATCH] Fail allocation if number of extents not divisible by area count Allocation should fail early if this condition is not met. Quick fix for https://bugzilla.redhat.com/show_bug.cgi?id=707779 --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 7 +++++++ test/t-lvconvert-mirror.sh | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 7ebbb63c6..c7142e3c8 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Reject allocation if number of extents is not divisible by area count. Fix issue preventing cluster mirror creation. Disable udev fallback by default and add activation/udev_fallback to lvm.conf. Call vg_mark_partial_lvs() before VG structure is returned from the cache. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 3f3607705..6cbb13279 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1716,6 +1716,13 @@ static int _allocate(struct alloc_handle *ah, return 1; } + if (ah->area_multiple > 1 && + (ah->new_extents - alloc_state.allocated) % ah->area_count) { + log_error("Number of extents requested (%d) needs to be divisible by %d.", + ah->new_extents - alloc_state.allocated, ah->area_count); + return 0; + } + alloc_state.log_area_count_still_needed = ah->log_area_count; if (ah->alloc == ALLOC_CONTIGUOUS) diff --git a/test/t-lvconvert-mirror.sh b/test/t-lvconvert-mirror.sh index 64c407b7e..ee986e48e 100644 --- a/test/t-lvconvert-mirror.sh +++ b/test/t-lvconvert-mirror.sh @@ -248,3 +248,8 @@ lvconvert -m1 -i1 $vg/$lv1 lvreduce -f -l1 $vg/$lv1 lvextend -f -l10 $vg/$lv1 lvremove -ff $vg/$lv1 + +# extents must be divisible +lvcreate -l15 -n $lv1 $vg +not lvconvert -m1 --corelog --stripes 2 $vg/$lv1 +lvremove -ff $vg/$lv1 -- 2.43.5