From 5aeea69c01b34d8cf1dc1af0e382ad8e2d295291 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 25 Mar 2010 18:16:54 +0000 Subject: [PATCH] Add some assertions to allocation code. --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 13bb37ceb..f30082bd6 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.63 - ================================ + Add some assertions to allocation code. Introduce pv_area_used into allocation algorithm and add debug messages. Add activation/monitoring to lvm.conf. Add --monitor and --ignoremonitoring to lvcreate. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 008a2cf7e..77f30e96f 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -600,6 +600,11 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd, if (segtype_is_virtual(segtype)) return ah; + if (!(area_count + log_area_count)) { + log_error(INTERNAL_ERROR "_alloc_init called for non-virtual segment with no disk space."); + return NULL; + } + if (!(ah->mem = dm_pool_create("allocation", 1024))) { log_error("allocation pool creation failed"); return NULL; @@ -744,6 +749,11 @@ static int _alloc_parallel_area(struct alloc_handle *ah, uint32_t needed, uint32_t total_area_count = ah->area_count + (log_needs_allocating ? ah->log_area_count : 0); struct alloced_area *aa; + if (!total_area_count) { + log_error(INTERNAL_ERROR "_alloc_parallel_area called without any allocation to do."); + return 1; + } + remaining = needed - *allocated; area_len = remaining / ah->area_multiple; -- 2.43.5