Assemble DRBD using the known size
authorIustin Pop <iustin@google.com>
Wed, 3 Jun 2009 12:21:06 +0000 (14:21 +0200)
committerIustin Pop <iustin@google.com>
Wed, 3 Jun 2009 16:09:54 +0000 (18:09 +0200)
This patch changes DRBD disk attachment to force the wanted size, as opposed to
letting the device auto-discover its size.

This should make the disks more resilient with regard to small differences in
size (e.g. due to LVM rounding). This still works with regard to disk
growth, but the instances needs to be fully restarted (including disks)
in that case.

This passes a full burning without problems, but it's still a tricky
change - if the config.data is not synced with the reality, we might
tell DRBD a wrong size. At least this will fail outright (and not
introduce silent errors), as DRBD (per a quick check at the sources)
tracks the size in the meta-dev and also does not allow shrinking
consistent devices.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/bdev.py

index af4f407..ee6a38e 100644 (file)
@@ -1032,12 +1032,15 @@ class DRBD8(BaseDRBD):
     return retval
 
   @classmethod
-  def _AssembleLocal(cls, minor, backend, meta):
+  def _AssembleLocal(cls, minor, backend, meta, size):
     """Configure the local part of a DRBD device.
 
     """
     args = ["drbdsetup", cls._DevPath(minor), "disk",
-            backend, meta, "0", "-e", "detach", "--create-device"]
+            backend, meta, "0",
+            "-d", "%sm" % size,
+            "-e", "detach",
+            "--create-device"]
     result = utils.RunCmd(args)
     if result.failed:
       _ThrowError("drbd%d: can't attach local disk: %s", minor, result.output)
@@ -1114,7 +1117,7 @@ class DRBD8(BaseDRBD):
     self._CheckMetaSize(meta.dev_path)
     self._InitMeta(self._FindUnusedMinor(), meta.dev_path)
 
-    self._AssembleLocal(self.minor, backend.dev_path, meta.dev_path)
+    self._AssembleLocal(self.minor, backend.dev_path, meta.dev_path, self.size)
     self._children = devices
 
   def RemoveChildren(self, devices):
@@ -1397,7 +1400,7 @@ class DRBD8(BaseDRBD):
       if match_r and "local_dev" not in info:
         # no local disk, but network attached and it matches
         self._AssembleLocal(minor, self._children[0].dev_path,
-                            self._children[1].dev_path)
+                            self._children[1].dev_path, self.size)
         if self._MatchesNet(self._GetDevInfo(self._GetShowData(minor))):
           break
         else:
@@ -1448,7 +1451,7 @@ class DRBD8(BaseDRBD):
     minor = self._aminor
     if self._children and self._children[0] and self._children[1]:
       self._AssembleLocal(minor, self._children[0].dev_path,
-                          self._children[1].dev_path)
+                          self._children[1].dev_path, self.size)
     if self._lhost and self._lport and self._rhost and self._rport:
       self._AssembleNet(minor,
                         (self._lhost, self._lport, self._rhost, self._rport),