From 1dc109724b053d6825dae6bbd84026162253b8d7 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 1 Jul 2009 11:08:13 +0200
Subject: [PATCH] Increase maximum accepted size for a DRBD meta dev

With the change to stripped LVs, the actual size of a meta device (which
is small) can be more than we expected (for non-stripped LVs). This
patch increases from 160MB to 1GB the accepted size, and updates the
comment with the rationale behind this change.

Note that we do want even meta devices stripped, since it can increase
metadata update.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>
---
 lib/bdev.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/bdev.py b/lib/bdev.py
index 5f94d5078..006e5e3cf 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -828,7 +828,13 @@ class BaseDRBD(BlockDev):
     bytes = sectors * 512
     if bytes < 128 * 1024 * 1024: # less than 128MiB
       _ThrowError("Meta device too small (%.2fMib)", (bytes / 1024 / 1024))
-    if bytes > (128 + 32) * 1024 * 1024: # account for an extra (big) PE on LVM
+    # the maximum *valid* size of the meta device when living on top
+    # of LVM is hard to compute: it depends on the number of stripes
+    # and the PE size; e.g. a 2-stripe, 64MB PE will result in a 128MB
+    # (normal size), but an eight-stripe 128MB PE will result in a 1GB
+    # size meta device; as such, we restrict it to 1GB (a little bit
+    # too generous, but making assumptions about PE size is hard)
+    if bytes > 1024 * 1024 * 1024:
       _ThrowError("Meta device too big (%.2fMiB)", (bytes / 1024 / 1024))
 
   def Rename(self, new_id):
-- 
GitLab