Skip to contentSkip to conversation

master - cleanup: explicit prohibition for virtual segs

PATCH Zdenek Kabelac 1 participant 1 message Jan 14, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2567d03e95bb4e46cd845c2ae8b518ec4989b939
Commit:        2567d03e95bb4e46cd845c2ae8b518ec4989b939
Parent:        4310dfd4e141bb83320148d245f3ab2cae778f6e
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Wed Jan 6 13:54:15 2016 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100

cleanup: explicit prohibition for virtual segs

Internal _alloc_init() is only called from allocate_extents(), which already does prevent usage of virtual segments.

So mark as internal error early and do not process it any further.

---
 lib/metadata/lv_manip.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
lib/metadata/lv_manip.c +6 -9
index 1396b86..6897801 100644
@@ -3128,19 +3128,20 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
 	uint32_t s, area_count, alloc_count, parity_count, total_extents;
 	size_t size = 0;
 
+	if (segtype_is_virtual(segtype)) {
+		log_error(INTERNAL_ERROR "_alloc_init called for virtual segment.");
+		return NULL;
+	}
+
 	/* FIXME Caller should ensure this */
 	if (mirrors && !stripes)
 		stripes = 1;
-
-	if (segtype_is_virtual(segtype))
-		area_count = 0;
 	else if (mirrors > 1)
 		area_count = mirrors * stripes;
 	else
 		area_count = stripes;
 
-	if (!segtype_is_virtual(segtype) &&
-	    !(area_count + metadata_area_count)) {
+	if (!(area_count + metadata_area_count)) {
 		log_error(INTERNAL_ERROR "_alloc_init called for non-virtual segment with no disk space.");
 		return NULL;
 	}
@@ -3186,10 +3187,6 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
 
 	ah->cmd = cmd;
 	ah->mem = mem;
-
-	if (segtype_is_virtual(segtype))
-		return ah;
-
 	ah->area_count = area_count;
 	ah->parity_count = parity_count;
 	ah->region_size = region_size;