From a94033446fca2d1339c62361f4d9ab443048f370 Mon Sep 17 00:00:00 2001
From: Arne Goedeke <el@laramies.com>
Date: Fri, 22 Aug 2014 17:53:46 +0200
Subject: [PATCH] block_allocator: do not round up powers of 2

The family of round_up* functions rounds up to the next power of two.
This made most block allocators initial areas twice as big as intended.
---
 src/block_allocator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/block_allocator.c b/src/block_allocator.c
index 59f13024b8..f59dab0e66 100644
--- a/src/block_allocator.c
+++ b/src/block_allocator.c
@@ -127,7 +127,8 @@ PMOD_EXPORT void ba_low_init_aligned(struct block_allocator * a) {
 	a->l.doffset = sizeof(struct ba_page);
     }
 
-    a->l.blocks = round_up32(a->l.blocks);
+    if (a->l.blocks & (a->l.blocks - 1))
+        a->l.blocks = round_up32(a->l.blocks);
     a->l.block_size = block_size;
     a->l.offset = block_size * (a->l.blocks-1);
 }
-- 
GitLab