Add DRBD8 static resync speed disk parameter
authorAndrea Spadaccini <spadaccio@google.com>
Mon, 21 Nov 2011 14:51:11 +0000 (14:51 +0000)
committerAndrea Spadaccini <spadaccio@google.com>
Thu, 1 Dec 2011 11:04:06 +0000 (11:04 +0000)
Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/bdev.py
lib/cmdlib.py
lib/constants.py

index b9fc651..2182beb 100644 (file)
@@ -1373,8 +1373,7 @@ class DRBD8(BaseDRBD):
     if result.failed:
       _ThrowError("drbd%d: can't attach local disk: %s", minor, result.output)
 
-  @classmethod
-  def _AssembleNet(cls, minor, net_info, protocol,
+  def _AssembleNet(self, minor, net_info, protocol,
                    dual_pri=False, hmac=None, secret=None):
     """Configure the network part of the device.
 
@@ -1383,7 +1382,7 @@ class DRBD8(BaseDRBD):
     if None in net_info:
       # we don't want network connection and actually want to make
       # sure its shutdown
-      cls._ShutdownNet(minor)
+      self._ShutdownNet(minor)
       return
 
     # Workaround for a race condition. When DRBD is doing its dance to
@@ -1392,7 +1391,8 @@ class DRBD8(BaseDRBD):
     # sync speed only after setting up both sides can race with DRBD
     # connecting, hence we set it here before telling DRBD anything
     # about its peer.
-    cls._SetMinorSyncSpeed(minor, constants.SYNC_SPEED)
+    sync_speed = self.params.get(constants.RESYNC_RATE)
+    self._SetMinorSyncSpeed(minor, sync_speed)
 
     if netutils.IP6Address.IsValid(lhost):
       if not netutils.IP6Address.IsValid(rhost):
@@ -1407,7 +1407,7 @@ class DRBD8(BaseDRBD):
     else:
       _ThrowError("drbd%d: Invalid ip %s" % (minor, lhost))
 
-    args = ["drbdsetup", cls._DevPath(minor), "net",
+    args = ["drbdsetup", self._DevPath(minor), "net",
             "%s:%s:%s" % (family, lhost, lport),
             "%s:%s:%s" % (family, rhost, rport), protocol,
             "-A", "discard-zero-changes",
@@ -1424,7 +1424,7 @@ class DRBD8(BaseDRBD):
                   minor, result.fail_reason, result.output)
 
     def _CheckNetworkConfig():
-      info = cls._GetDevInfo(cls._GetShowData(minor))
+      info = self._GetDevInfo(self._GetShowData(minor))
       if not "local_addr" in info or not "remote_addr" in info:
         raise utils.RetryAgain()
 
@@ -1758,7 +1758,8 @@ class DRBD8(BaseDRBD):
       # the device
       self._SlowAssemble()
 
-    self.SetSyncSpeed(constants.SYNC_SPEED)
+    sync_speed = self.params.get(constants.RESYNC_RATE)
+    self.SetSyncSpeed(sync_speed)
 
   def _SlowAssemble(self):
     """Assembles the DRBD device from a (partially) configured device.
index 8016f1a..71fac54 100644 (file)
@@ -8055,10 +8055,19 @@ def _ComputeLDParams(disk_template, disk_params):
     raise errors.ProgrammerError("Unknown disk template %s" % disk_template)
 
   result = list()
+  dt_params = disk_params[disk_template]
   if disk_template == constants.DT_DRBD8:
-    result.append(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8])
+    params = {
+      constants.RESYNC_RATE: dt_params[constants.DRBD_RESYNC_RATE]
+      }
+
+    drbd_params = \
+      objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8], params)
+
+    result.append(drbd_params)
     result.append(constants.DISK_LD_DEFAULTS[constants.LD_LV])
     result.append(constants.DISK_LD_DEFAULTS[constants.LD_LV])
+
   elif (disk_template == constants.DT_FILE or
         disk_template == constants.DT_SHARED_FILE):
     result.append(constants.DISK_LD_DEFAULTS[constants.LD_FILE])
index 827db0a..f5ad7f1 100644 (file)
@@ -597,7 +597,7 @@ MAX_TAGS_PER_OBJ = 4096
 
 # others
 DEFAULT_BRIDGE = "xen-br0"
-SYNC_SPEED = 60 * 1024
+CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
 IP4_ADDRESS_ANY = "0.0.0.0"
 IP6_ADDRESS_LOCALHOST = "::1"
@@ -897,12 +897,16 @@ NDS_PARAMETER_TYPES = {
 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
 
 # Logical Disks parameters
+RESYNC_RATE = "resync-rate"
 DISK_LD_TYPES = {
+  RESYNC_RATE: VTYPE_INT,
   }
 DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
 
 # Disk template parameters
+DRBD_RESYNC_RATE = "resync-rate"
 DISK_DT_TYPES = {
+  DRBD_RESYNC_RATE: VTYPE_INT,
   }
 
 DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
@@ -1671,6 +1675,7 @@ NDC_DEFAULTS = {
 
 DISK_LD_DEFAULTS = {
   LD_DRBD8: {
+    RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
     },
   LD_LV: {
     },
@@ -1684,6 +1689,7 @@ DISK_DT_DEFAULTS = {
   DT_PLAIN: {
     },
   DT_DRBD8: {
+    DRBD_RESYNC_RATE: DISK_LD_DEFAULTS[LD_DRBD8][RESYNC_RATE]
     },
   DT_DISKLESS: {
     },