Commit 65fc2388 authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Make DRBD replication protocol configurable



Add a new disk parameter which allows to choose the DRBD replication
protocol. The protocol is fixed to "C" during dual primary mode though.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent d352b796
......@@ -583,7 +583,8 @@ LDS_BLOCK = compat.UniqueFrozenset([
# drbd constants
DRBD_HMAC_ALG = "md5"
DRBD_NET_PROTOCOL = "C"
DRBD_DEFAULT_NET_PROTOCOL = "C"
DRBD_MIGRATION_NET_PROTOCOL = "C"
DRBD_STATUS_FILE = "/proc/drbd"
#: Size of DRBD meta block device
......@@ -1208,6 +1209,7 @@ LDP_NO_META_FLUSH = "disable-meta-flush"
LDP_DEFAULT_METAVG = "default-metavg"
LDP_DISK_CUSTOM = "disk-custom"
LDP_NET_CUSTOM = "net-custom"
LDP_PROTOCOL = "protocol"
LDP_DYNAMIC_RESYNC = "dynamic-resync"
LDP_PLAN_AHEAD = "c-plan-ahead"
LDP_FILL_TARGET = "c-fill-target"
......@@ -1223,6 +1225,7 @@ DISK_LD_TYPES = {
LDP_DEFAULT_METAVG: VTYPE_STRING,
LDP_DISK_CUSTOM: VTYPE_STRING,
LDP_NET_CUSTOM: VTYPE_STRING,
LDP_PROTOCOL: VTYPE_STRING,
LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
LDP_PLAN_AHEAD: VTYPE_INT,
LDP_FILL_TARGET: VTYPE_INT,
......@@ -1243,6 +1246,7 @@ DRBD_META_BARRIERS = "meta-barriers"
DRBD_DEFAULT_METAVG = "metavg"
DRBD_DISK_CUSTOM = "disk-custom"
DRBD_NET_CUSTOM = "net-custom"
DRBD_PROTOCOL = "protocol"
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
DRBD_PLAN_AHEAD = "c-plan-ahead"
DRBD_FILL_TARGET = "c-fill-target"
......@@ -1260,6 +1264,7 @@ DISK_DT_TYPES = {
DRBD_DEFAULT_METAVG: VTYPE_STRING,
DRBD_DISK_CUSTOM: VTYPE_STRING,
DRBD_NET_CUSTOM: VTYPE_STRING,
DRBD_PROTOCOL: VTYPE_STRING,
DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
DRBD_PLAN_AHEAD: VTYPE_INT,
DRBD_FILL_TARGET: VTYPE_INT,
......@@ -2184,6 +2189,7 @@ DISK_LD_DEFAULTS = {
LDP_DEFAULT_METAVG: DEFAULT_VG,
LDP_DISK_CUSTOM: "",
LDP_NET_CUSTOM: "",
LDP_PROTOCOL: DRBD_DEFAULT_NET_PROTOCOL,
LDP_DYNAMIC_RESYNC: False,
# The default values for the DRBD dynamic resync speed algorithm
......@@ -2225,6 +2231,7 @@ DISK_DT_DEFAULTS = {
DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
......
......@@ -865,6 +865,7 @@ class Disk(ConfigObject):
constants.LDP_DEFAULT_METAVG: dt_params[constants.DRBD_DEFAULT_METAVG],
constants.LDP_DISK_CUSTOM: dt_params[constants.DRBD_DISK_CUSTOM],
constants.LDP_NET_CUSTOM: dt_params[constants.DRBD_NET_CUSTOM],
constants.LDP_PROTOCOL: dt_params[constants.DRBD_PROTOCOL],
constants.LDP_DYNAMIC_RESYNC: dt_params[constants.DRBD_DYNAMIC_RESYNC],
constants.LDP_PLAN_AHEAD: dt_params[constants.DRBD_PLAN_AHEAD],
constants.LDP_FILL_TARGET: dt_params[constants.DRBD_FILL_TARGET],
......
......@@ -377,8 +377,8 @@ class DRBD8Dev(base.BlockDev):
base.ThrowError("drbd%d: can't attach local disk: %s",
minor, result.output)
def _AssembleNet(self, minor, net_info, protocol,
dual_pri=False, hmac=None, secret=None):
def _AssembleNet(self, minor, net_info, dual_pri=False, hmac=None,
secret=None):
"""Configure the network part of the device.
@type minor: int
......@@ -386,8 +386,6 @@ class DRBD8Dev(base.BlockDev):
@type net_info: (string, int, string, int)
@param net_info: tuple containing the local address, local port, remote
address and remote port
@type protocol: string
@param protocol: either "ipv4" or "ipv6"
@type dual_pri: boolean
@param dual_pri: whether two primaries should be allowed or not
@type hmac: string
......@@ -403,6 +401,11 @@ class DRBD8Dev(base.BlockDev):
self._ShutdownNet(minor)
return
if dual_pri:
protocol = constants.DRBD_MIGRATION_NET_PROTOCOL
else:
protocol = self.params[constants.LDP_PROTOCOL]
# Workaround for a race condition. When DRBD is doing its dance to
# establish a connection with its peer, it also sends the
# synchronization speed over the wire. In some cases setting the
......@@ -747,8 +750,8 @@ class DRBD8Dev(base.BlockDev):
self._AssembleNet(self.minor,
(self._lhost, self._lport, self._rhost, self._rport),
constants.DRBD_NET_PROTOCOL, dual_pri=multimaster,
hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
dual_pri=multimaster, hmac=constants.DRBD_HMAC_ALG,
secret=self._secret)
def Attach(self):
"""Check if our minor is configured.
......@@ -818,8 +821,8 @@ class DRBD8Dev(base.BlockDev):
if match_l and not match_r and "local_addr" not in info:
# disk matches, but not attached to network, attach and recheck
self._AssembleNet(minor, net_data, constants.DRBD_NET_PROTOCOL,
hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
self._AssembleNet(minor, net_data, hmac=constants.DRBD_HMAC_ALG,
secret=self._secret)
if self._MatchesNet(self._GetShowInfo(minor)):
break
else:
......@@ -855,8 +858,8 @@ class DRBD8Dev(base.BlockDev):
# note: _AssembleNet also handles the case when we don't want
# local storage (i.e. one or more of the _[lr](host|port) is
# None)
self._AssembleNet(minor, net_data, constants.DRBD_NET_PROTOCOL,
hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
self._AssembleNet(minor, net_data, hmac=constants.DRBD_HMAC_ALG,
secret=self._secret)
if self._MatchesNet(self._GetShowInfo(minor)):
break
else:
......@@ -884,7 +887,6 @@ class DRBD8Dev(base.BlockDev):
if self._lhost and self._lport and self._rhost and self._rport:
self._AssembleNet(minor,
(self._lhost, self._lport, self._rhost, self._rport),
constants.DRBD_NET_PROTOCOL,
hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
self._SetFromMinor(minor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment