Revision f2f57b6e lib/bdev.py
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. |
Also available in: Unified diff