Revision 8584e922
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. |
b/lib/cmdlib.py | ||
---|---|---|
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 | 8248 |
constants.LDP_DYNAMIC_RESYNC: dt_params[constants.DRBD_DYNAMIC_RESYNC], |
8249 |
constants.LDP_PLAN_AHEAD: dt_params[constants.DRBD_PLAN_AHEAD], |
|
8250 |
constants.LDP_FILL_TARGET: dt_params[constants.DRBD_FILL_TARGET], |
|
8251 |
constants.LDP_DELAY_TARGET: dt_params[constants.DRBD_DELAY_TARGET], |
|
8252 |
constants.LDP_MAX_RATE: dt_params[constants.DRBD_MAX_RATE], |
|
8253 |
constants.LDP_MIN_RATE: dt_params[constants.DRBD_MIN_RATE], |
|
8249 | 8254 |
} |
8250 | 8255 |
|
8251 | 8256 |
drbd_params = \ |
b/lib/constants.py | ||
---|---|---|
966 | 966 |
LDP_DISK_CUSTOM = "disk-custom" |
967 | 967 |
LDP_NET_CUSTOM = "net-custom" |
968 | 968 |
LDP_DYNAMIC_RESYNC = "dynamic-resync" |
969 |
LDP_PLAN_AHEAD = "c-plan-ahead" |
|
970 |
LDP_FILL_TARGET = "c-fill-target" |
|
971 |
LDP_DELAY_TARGET = "c-delay-target" |
|
972 |
LDP_MAX_RATE = "c-max-rate" |
|
973 |
LDP_MIN_RATE = "c-min-rate" |
|
969 | 974 |
DISK_LD_TYPES = { |
970 | 975 |
LDP_RESYNC_RATE: VTYPE_INT, |
971 | 976 |
LDP_STRIPES: VTYPE_INT, |
... | ... | |
975 | 980 |
LDP_DISK_CUSTOM: VTYPE_STRING, |
976 | 981 |
LDP_NET_CUSTOM: VTYPE_STRING, |
977 | 982 |
LDP_DYNAMIC_RESYNC: VTYPE_BOOL, |
983 |
LDP_PLAN_AHEAD: VTYPE_INT, |
|
984 |
LDP_FILL_TARGET: VTYPE_INT, |
|
985 |
LDP_DELAY_TARGET: VTYPE_INT, |
|
986 |
LDP_MAX_RATE: VTYPE_INT, |
|
987 |
LDP_MIN_RATE: VTYPE_INT, |
|
978 | 988 |
} |
979 | 989 |
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys()) |
980 | 990 |
|
... | ... | |
989 | 999 |
DRBD_DISK_CUSTOM = "disk-custom" |
990 | 1000 |
DRBD_NET_CUSTOM = "net-custom" |
991 | 1001 |
DRBD_DYNAMIC_RESYNC = "dynamic-resync" |
1002 |
DRBD_PLAN_AHEAD = "c-plan-ahead" |
|
1003 |
DRBD_FILL_TARGET = "c-fill-target" |
|
1004 |
DRBD_DELAY_TARGET = "c-delay-target" |
|
1005 |
DRBD_MAX_RATE = "c-max-rate" |
|
1006 |
DRBD_MIN_RATE = "c-min-rate" |
|
992 | 1007 |
LV_STRIPES = "stripes" |
993 | 1008 |
DISK_DT_TYPES = { |
994 | 1009 |
DRBD_RESYNC_RATE: VTYPE_INT, |
... | ... | |
1000 | 1015 |
DRBD_DISK_CUSTOM: VTYPE_STRING, |
1001 | 1016 |
DRBD_NET_CUSTOM: VTYPE_STRING, |
1002 | 1017 |
DRBD_DYNAMIC_RESYNC: VTYPE_BOOL, |
1018 |
DRBD_PLAN_AHEAD: VTYPE_INT, |
|
1019 |
DRBD_FILL_TARGET: VTYPE_INT, |
|
1020 |
DRBD_DELAY_TARGET: VTYPE_INT, |
|
1021 |
DRBD_MAX_RATE: VTYPE_INT, |
|
1022 |
DRBD_MIN_RATE: VTYPE_INT, |
|
1003 | 1023 |
LV_STRIPES: VTYPE_INT, |
1004 | 1024 |
} |
1005 | 1025 |
|
... | ... | |
1781 | 1801 |
LDP_DISK_CUSTOM: "", |
1782 | 1802 |
LDP_NET_CUSTOM: "", |
1783 | 1803 |
LDP_DYNAMIC_RESYNC: False, |
1804 |
|
|
1805 |
# The default values for the DRBD dynamic resync speed algorithm are taken |
|
1806 |
# from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we |
|
1807 |
# don't need to set to 0, because we have a separate option to enable it) |
|
1808 |
# and for c-max-rate, that we cap to the default value for the static resync |
|
1809 |
# rate. |
|
1810 |
LDP_PLAN_AHEAD: 20, # ds |
|
1811 |
LDP_FILL_TARGET: 0, # sectors |
|
1812 |
LDP_DELAY_TARGET: 1, # ds |
|
1813 |
LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s |
|
1814 |
LDP_MIN_RATE: 4 * 1024, # KiB/s |
|
1784 | 1815 |
}, |
1785 | 1816 |
LD_LV: { |
1786 | 1817 |
LDP_STRIPES: _autoconf.LVM_STRIPECOUNT |
... | ... | |
1791 | 1822 |
}, |
1792 | 1823 |
} |
1793 | 1824 |
|
1825 |
# readability shortcuts |
|
1826 |
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV] |
|
1827 |
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8] |
|
1828 |
|
|
1794 | 1829 |
DISK_DT_DEFAULTS = { |
1795 | 1830 |
DT_PLAIN: { |
1796 | 1831 |
LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES], |
1797 | 1832 |
}, |
1798 | 1833 |
DT_DRBD8: { |
1799 |
DRBD_RESYNC_RATE: DISK_LD_DEFAULTS[LD_DRBD8][LDP_RESYNC_RATE], |
|
1800 |
DRBD_DATA_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES], |
|
1801 |
DRBD_META_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES], |
|
1802 |
DRBD_DISK_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][LDP_BARRIERS], |
|
1803 |
DRBD_META_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NO_META_FLUSH], |
|
1804 |
DRBD_DEFAULT_METAVG: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DEFAULT_METAVG], |
|
1805 |
DRBD_DISK_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DISK_CUSTOM], |
|
1806 |
DRBD_NET_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NET_CUSTOM], |
|
1807 |
DRBD_DYNAMIC_RESYNC: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DYNAMIC_RESYNC], |
|
1834 |
DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE], |
|
1835 |
DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES], |
|
1836 |
DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES], |
|
1837 |
DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS], |
|
1838 |
DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH], |
|
1839 |
DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG], |
|
1840 |
DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM], |
|
1841 |
DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM], |
|
1842 |
DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC], |
|
1843 |
DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD], |
|
1844 |
DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET], |
|
1845 |
DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET], |
|
1846 |
DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE], |
|
1847 |
DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE], |
|
1808 | 1848 |
}, |
1809 | 1849 |
DT_DISKLESS: { |
1810 | 1850 |
}, |
... | ... | |
1816 | 1856 |
}, |
1817 | 1857 |
} |
1818 | 1858 |
|
1859 |
# we don't want to export the shortcuts |
|
1860 |
del _LV_DEFAULTS, _DRBD_DEFAULTS |
|
1861 |
|
|
1819 | 1862 |
NICC_DEFAULTS = { |
1820 | 1863 |
NIC_MODE: NIC_MODE_BRIDGED, |
1821 | 1864 |
NIC_LINK: DEFAULT_BRIDGE, |
Also available in: Unified diff