Revision f2f57b6e

b/lib/bdev.py
221 221
    """
222 222
    raise NotImplementedError
223 223

  
224
  def SetSyncSpeed(self, speed):
225
    """Adjust the sync speed of the mirror.
224
  def SetSyncParams(self, params):
225
    """Adjust the synchronization parameters of the mirror.
226 226

  
227 227
    In case this is not a mirroring device, this is no-op.
228 228

  
229
    @param params: dictionary of LD level disk parameters related to the
230
    synchronization.
231

  
229 232
    """
230 233
    result = True
231 234
    if self._children:
232 235
      for child in self._children:
233
        result = result and child.SetSyncSpeed(speed)
236
        result = result and child.SetSyncParams(params)
234 237
    return result
235 238

  
236 239
  def PauseResumeSync(self, pause):
......
238 241

  
239 242
    In case this is not a mirroring device, this is no-op.
240 243

  
241
    @param pause: Wheater to pause or resume
244
    @param pause: Whether to pause or resume
242 245

  
243 246
    """
244 247
    result = True
......
1472 1475
    # sync speed only after setting up both sides can race with DRBD
1473 1476
    # connecting, hence we set it here before telling DRBD anything
1474 1477
    # about its peer.
1475
    sync_speed = self.params.get(constants.LDP_RESYNC_RATE)
1476
    self._SetMinorSyncSpeed(minor, sync_speed)
1478
    self._SetMinorSyncParams(minor, self.params)
1477 1479

  
1478 1480
    if netutils.IP6Address.IsValid(lhost):
1479 1481
      if not netutils.IP6Address.IsValid(rhost):
......
1573 1575
    self._children = []
1574 1576

  
1575 1577
  @classmethod
1576
  def _SetMinorSyncSpeed(cls, minor, kbytes):
1577
    """Set the speed of the DRBD syncer.
1578
  def _SetMinorSyncParams(cls, minor, params):
1579
    """Set the parameters of the DRBD syncer.
1578 1580

  
1579 1581
    This is the low-level implementation.
1580 1582

  
1581 1583
    @type minor: int
1582 1584
    @param minor: the drbd minor whose settings we change
1583
    @type kbytes: int
1584
    @param kbytes: the speed in kbytes/second
1585
    @type params: dict
1586
    @param params: LD level disk parameters related to the synchronization
1585 1587
    @rtype: boolean
1586 1588
    @return: the success of the operation
1587 1589

  
1588 1590
    """
1589
    result = utils.RunCmd(["drbdsetup", cls._DevPath(minor), "syncer",
1590
                           "-r", "%d" % kbytes, "--create-device"])
1591

  
1592
    args = ["drbdsetup", cls._DevPath(minor), "syncer"]
1593
    if params[constants.LDP_DYNAMIC_RESYNC]:
1594
      version = cls._GetVersion(cls._GetProcData())
1595
      vmin = version["k_minor"]
1596
      vrel = version["k_point"]
1597

  
1598
      # By definition we are using 8.x, so just check the rest of the version
1599
      # number
1600
      if vmin != 3 or vrel < 9:
1601
        logging.error("The current DRBD version (8.%d.%d) does not support the"
1602
                      " dynamic resync speed controller", vmin, vrel)
1603
        return False
1604

  
1605
      # add the c-* parameters to args
1606
      # TODO(spadaccio) use the actual parameters
1607
      args.extend(["--c-plan-ahead", "20"])
1608

  
1609
    else:
1610
      args.extend(["-r", "%d" % params[constants.LDP_RESYNC_RATE]])
1611

  
1612
    args.append("--create-device")
1613
    result = utils.RunCmd(args)
1591 1614
    if result.failed:
1592 1615
      logging.error("Can't change syncer rate: %s - %s",
1593 1616
                    result.fail_reason, result.output)
1594 1617
    return not result.failed
1595 1618

  
1596
  def SetSyncSpeed(self, kbytes):
1597
    """Set the speed of the DRBD syncer.
1619
  def SetSyncParams(self, params):
1620
    """Set the synchronization parameters of the DRBD syncer.
1598 1621

  
1599
    @type kbytes: int
1600
    @param kbytes: the speed in kbytes/second
1622
    @type params: dict
1623
    @param params: LD level disk parameters related to the synchronization
1601 1624
    @rtype: boolean
1602 1625
    @return: the success of the operation
1603 1626

  
1604 1627
    """
1605 1628
    if self.minor is None:
1606
      logging.info("Not attached during SetSyncSpeed")
1629
      logging.info("Not attached during SetSyncParams")
1607 1630
      return False
1608
    children_result = super(DRBD8, self).SetSyncSpeed(kbytes)
1609
    return self._SetMinorSyncSpeed(self.minor, kbytes) and children_result
1631
    children_result = super(DRBD8, self).SetSyncParams(params)
1632
    return self._SetMinorSyncParams(self.minor, params) and children_result
1610 1633

  
1611 1634
  def PauseResumeSync(self, pause):
1612 1635
    """Pauses or resumes the sync of a DRBD device.
......
1843 1866
      # the device
1844 1867
      self._SlowAssemble()
1845 1868

  
1846
    sync_speed = self.params.get(constants.LDP_RESYNC_RATE)
1847
    self.SetSyncSpeed(sync_speed)
1869
    self.SetSyncParams(self.params)
1848 1870

  
1849 1871
  def _SlowAssemble(self):
1850 1872
    """Assembles the DRBD device from a (partially) configured device.
b/lib/cmdlib.py
8245 8245
      constants.LDP_DEFAULT_METAVG: dt_params[constants.DRBD_DEFAULT_METAVG],
8246 8246
      constants.LDP_DISK_CUSTOM: dt_params[constants.DRBD_DISK_CUSTOM],
8247 8247
      constants.LDP_NET_CUSTOM: dt_params[constants.DRBD_NET_CUSTOM],
8248
      constants.LDP_DYNAMIC_RESYNC: dt_params[constants.DRBD_DYNAMIC_RESYNC],
8248 8249
      }
8249 8250

  
8250 8251
    drbd_params = \
b/lib/constants.py
965 965
LDP_DEFAULT_METAVG = "default-metavg"
966 966
LDP_DISK_CUSTOM = "disk-custom"
967 967
LDP_NET_CUSTOM = "net-custom"
968
LDP_DYNAMIC_RESYNC = "dynamic-resync"
968 969
DISK_LD_TYPES = {
969 970
  LDP_RESYNC_RATE: VTYPE_INT,
970 971
  LDP_STRIPES: VTYPE_INT,
......
973 974
  LDP_DEFAULT_METAVG: VTYPE_STRING,
974 975
  LDP_DISK_CUSTOM: VTYPE_STRING,
975 976
  LDP_NET_CUSTOM: VTYPE_STRING,
977
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
976 978
  }
977 979
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
978 980

  
979
# Disk template parameters
981
# Disk template parameters (can be set/changed by the user via gnt-cluster and
982
# gnt-group)
980 983
DRBD_RESYNC_RATE = "resync-rate"
981 984
DRBD_DATA_STRIPES = "data-stripes"
982 985
DRBD_META_STRIPES = "meta-stripes"
......
985 988
DRBD_DEFAULT_METAVG = "metavg"
986 989
DRBD_DISK_CUSTOM = "disk-custom"
987 990
DRBD_NET_CUSTOM = "net-custom"
991
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
988 992
LV_STRIPES = "stripes"
989 993
DISK_DT_TYPES = {
990 994
  DRBD_RESYNC_RATE: VTYPE_INT,
......
995 999
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
996 1000
  DRBD_DISK_CUSTOM: VTYPE_STRING,
997 1001
  DRBD_NET_CUSTOM: VTYPE_STRING,
1002
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
998 1003
  LV_STRIPES: VTYPE_INT,
999 1004
  }
1000 1005

  
......
1775 1780
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1776 1781
    LDP_DISK_CUSTOM: "",
1777 1782
    LDP_NET_CUSTOM: "",
1783
    LDP_DYNAMIC_RESYNC: False,
1778 1784
    },
1779 1785
  LD_LV: {
1780 1786
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
......
1798 1804
    DRBD_DEFAULT_METAVG: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DEFAULT_METAVG],
1799 1805
    DRBD_DISK_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DISK_CUSTOM],
1800 1806
    DRBD_NET_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NET_CUSTOM],
1807
    DRBD_DYNAMIC_RESYNC: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DYNAMIC_RESYNC],
1801 1808
    },
1802 1809
  DT_DISKLESS: {
1803 1810
    },

Also available in: Unified diff