From c0ca88c287cc57c45f041b163008641fae99f3ab Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 30 Nov 2001 09:19:46 +0000 Subject: [PATCH] o Comparison function was sorting things in ascending rather than descending order. o free off the sort array when finished with it. --- lib/metadata/lv_manip.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 336d4be4b..fe6cd72a4 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -94,10 +94,10 @@ static int _comp_area(const void *l, const void *r) struct pv_area *rhs = *((struct pv_area **) r); if (lhs->count < rhs->count) - return -1; + return 1; else if (lhs->count > rhs->count) - return 1; + return -1; return 0; } @@ -106,6 +106,7 @@ static int _alloc_striped(struct logical_volume *lv, struct list *pvms, uint32_t allocated, uint32_t stripes, uint32_t stripe_size) { + int r = 0; struct list *pvmh; struct pv_area **areas; int pv_count = 0, index; @@ -135,26 +136,27 @@ static int _alloc_striped(struct logical_volume *lv, struct pv_area); } - if (index < stripes) - goto no_space; + if (index < stripes) { + log_error("Insufficient free extents (suitable for " + "striping) to allocate logical volume " + "%s: %u required", + lv->name, lv->le_count); + goto out; + } /* sort the areas so we allocate from the biggest */ qsort(areas, index, sizeof(*areas), _comp_area); if (!_alloc_stripe_area(lv, stripes, areas, &allocated)) { stack; - return 0; + goto out; } } + r = 1; - return 1; - - no_space: - - log_error("Insufficient free extents (suitable for striping) to " - "allocate logical volume %s: %u required", - lv->name, lv->le_count); - return 0; + out: + dbg_free(areas); + return r; }