Skip to contentSkip to conversation

Fail allocation if number of extents not divisible by area count

PATCH New Milan Broz 2 participants 2 messages Jun 21, 2011

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 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

---
 lib/metadata/lv_manip.c    |    7 +++++++
 test/t-lvconvert-mirror.sh |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)
lib/metadata/lv_manip.c +7 -0
index 3f36077..6cbb132 100644
@@ -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)
test/t-lvconvert-mirror.sh +5 -0
index 64c407b..ee986e4 100644
@@ -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
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 Fail allocation if number of extents not divisible by area count

Quoted 1 line · Milan Broz

Allocation should fail early if this condition is not met.

Ack, as discussed.

(Really, the tools layer should be dealing with these cases so they don't reach this code. E.g. lvresize checks and rounds the size.)

Alasdair