Revision 8584e922 lib/bdev.py

b/lib/bdev.py
228 228

  
229 229
    @param params: dictionary of LD level disk parameters related to the
230 230
    synchronization.
231
    @rtype: list
232
    @return: a list of error messages, emitted both by the current node and by
233
    children. An empty list means no errors.
231 234

  
232 235
    """
233
    result = True
236
    result = []
234 237
    if self._children:
235 238
      for child in self._children:
236
        result = result and child.SetSyncParams(params)
239
        result.extend(child.SetSyncParams(params))
237 240
    return result
238 241

  
239 242
  def PauseResumeSync(self, pause):
......
1475 1478
    # sync speed only after setting up both sides can race with DRBD
1476 1479
    # connecting, hence we set it here before telling DRBD anything
1477 1480
    # about its peer.
1478
    self._SetMinorSyncParams(minor, self.params)
1481
    sync_errors = self._SetMinorSyncParams(minor, self.params)
1482
    if sync_errors:
1483
      _ThrowError("drbd%d: can't set the synchronization parameters: %s" %
1484
                  (minor, utils.CommaJoin(sync_errors)))
1479 1485

  
1480 1486
    if netutils.IP6Address.IsValid(lhost):
1481 1487
      if not netutils.IP6Address.IsValid(rhost):
......
1584 1590
    @param minor: the drbd minor whose settings we change
1585 1591
    @type params: dict
1586 1592
    @param params: LD level disk parameters related to the synchronization
1587
    @rtype: boolean
1588
    @return: the success of the operation
1593
    @rtype: list
1594
    @return: a list of error messages
1589 1595

  
1590 1596
    """
1591 1597

  
......
1598 1604
      # By definition we are using 8.x, so just check the rest of the version
1599 1605
      # number
1600 1606
      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
1607
        msg = ("The current DRBD version (8.%d.%d) does not support the "
1608
               "dynamic resync speed controller" % (vmin, vrel))
1609
        logging.error(msg)
1610
        return [msg]
1611

  
1612
      if params[constants.LDP_PLAN_AHEAD] == 0:
1613
        msg = ("A value of 0 for c-plan-ahead disables the dynamic sync speed"
1614
               " controller at DRBD level. If you want to disable it, please"
1615
               " set the dynamic-resync disk parameter to False.")
1616
        logging.error(msg)
1617
        return [msg]
1604 1618

  
1605 1619
      # add the c-* parameters to args
1606
      # TODO(spadaccio) use the actual parameters
1607
      args.extend(["--c-plan-ahead", "20"])
1620
      args.extend(["--c-plan-ahead", params[constants.LDP_PLAN_AHEAD],
1621
                   "--c-fill-target", params[constants.LDP_FILL_TARGET],
1622
                   "--c-delay-target", params[constants.LDP_DELAY_TARGET],
1623
                   "--c-max-rate", params[constants.LDP_MAX_RATE],
1624
                   "--c-min-rate", params[constants.LDP_MIN_RATE],
1625
                  ])
1608 1626

  
1609 1627
    else:
1610 1628
      args.extend(["-r", "%d" % params[constants.LDP_RESYNC_RATE]])
......
1612 1630
    args.append("--create-device")
1613 1631
    result = utils.RunCmd(args)
1614 1632
    if result.failed:
1615
      logging.error("Can't change syncer rate: %s - %s",
1616
                    result.fail_reason, result.output)
1617
    return not result.failed
1633
      msg = ("Can't change syncer rate: %s - %s" %
1634
             (result.fail_reason, result.output))
1635
      logging.error(msg)
1636
      return msg
1637

  
1638
    return []
1618 1639

  
1619 1640
  def SetSyncParams(self, params):
1620 1641
    """Set the synchronization parameters of the DRBD syncer.
1621 1642

  
1622 1643
    @type params: dict
1623 1644
    @param params: LD level disk parameters related to the synchronization
1624
    @rtype: boolean
1625
    @return: the success of the operation
1645
    @rtype: list
1646
    @return: a list of error messages, emitted both by the current node and by
1647
    children. An empty list means no errors
1626 1648

  
1627 1649
    """
1628 1650
    if self.minor is None:
1629
      logging.info("Not attached during SetSyncParams")
1630
      return False
1651
      err = "Not attached during SetSyncParams"
1652
      logging.info(err)
1653
      return [err]
1654

  
1631 1655
    children_result = super(DRBD8, self).SetSyncParams(params)
1632
    return self._SetMinorSyncParams(self.minor, params) and children_result
1656
    children_result.extend(self._SetMinorSyncParams(self.minor, params))
1657
    return children_result
1633 1658

  
1634 1659
  def PauseResumeSync(self, pause):
1635 1660
    """Pauses or resumes the sync of a DRBD device.
......
1866 1891
      # the device
1867 1892
      self._SlowAssemble()
1868 1893

  
1869
    self.SetSyncParams(self.params)
1894
    sync_errors = self.SetSyncParams(self.params)
1895
    if sync_errors:
1896
      _ThrowError("drbd%d: can't set the synchronization parameters: %s" %
1897
                  (self.minor, utils.CommaJoin(sync_errors)))
1870 1898

  
1871 1899
  def _SlowAssemble(self):
1872 1900
    """Assembles the DRBD device from a (partially) configured device.

Also available in: Unified diff