From 9fc687cdfc6e48a39568f660d664fc173c582ac4 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Fri, 13 Jul 2007 19:30:21 -0700
Subject: [PATCH] storage.py: handle num_segments != power-of-two without an
 assertion

---
 src/allmydata/storage.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py
index b5acdee4..80196807 100644
--- a/src/allmydata/storage.py
+++ b/src/allmydata/storage.py
@@ -185,7 +185,8 @@ class WriteBucketProxy:
         self._segment_size = segment_size
         self._num_segments = num_segments
 
-        self._segment_hash_size = (2*num_segments - 1) * HASH_SIZE
+        effective_segments = mathutil.next_power_of_k(num_segments,2)
+        self._segment_hash_size = (2*effective_segments - 1) * HASH_SIZE
         # how many share hashes are included in each share? This will be
         # about ln2(num_shares).
         self._share_hash_size = num_share_hashes * (2+HASH_SIZE)
-- 
2.45.2