Commit 89b70f39 authored by Iustin Pop's avatar Iustin Pop

Add a crude disable for DRBD barriers

Ideally we want to/will have per-device DRBD controls of disk/metadata
flushes. In the meantime, we want at least a disable of the barrier
functionality for cases where one has battery-backed caches.

Background: DRBD has four mechanism of handling ordered disk-writes.
From the drbdsetup man-page, these are: barrier, flush, drain and none.
DRBD prior to 8.2 only has drain and none. This patch makes all 8.x
versions of DRBD disable all methods, and revert to none, in case one
fully trusts batteries (either UPS for the whole system or battery for
NVRAM).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d80cb8c4
......@@ -445,6 +445,7 @@ lib/_autoconf.py: Makefile stamp-directories
echo "TOOLSDIR = '$(toolsdir)'"; \
echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
echo "PKGLIBDIR = '$(pkglibdir)'"; \
echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
} > $@
$(REPLACE_VARS_SED): Makefile
......
......@@ -108,7 +108,7 @@ AC_ARG_WITH([kvm-path],
[kvm_path="/usr/bin/kvm"])
AC_SUBST(KVM_PATH, $kvm_path)
# ---with-lvm-stripecount=...
# --with-lvm-stripecount=...
AC_ARG_WITH([lvm-stripecount],
[AS_HELP_STRING([--with-lvm-stripecount=NUM],
[the number of stripes to use for LVM volumes]
......@@ -118,6 +118,19 @@ AC_ARG_WITH([lvm-stripecount],
[lvm_stripecount="1"])
AC_SUBST(LVM_STRIPECOUNT, $lvm_stripecount)
# --enable-drbd-barriers
AC_ARG_ENABLE([drbd-barriers],
[AS_HELP_STRING([--enable-drbd-barriers],
[enable the DRBD barrier functionality (>= 8.0.12) (default: enabled)])],
[[if test "$enableval" != no; then
DRBD_BARRIERS=True
else
DRBD_BARRIERS=False
fi
]],
[DRBD_BARRIERS=True])
AC_SUBST(DRBD_BARRIERS, $DRBD_BARRIERS)
# Check common programs
AC_PROG_INSTALL
AC_PROG_LN_S
......
......@@ -1215,6 +1215,24 @@ class DRBD8(BaseDRBD):
"--create-device"]
if size:
args.extend(["-d", "%sm" % size])
if not constants.DRBD_BARRIERS: # disable barriers, if configured so
version = cls._GetVersion()
# various DRBD versions support different disk barrier options;
# what we aim here is to revert back to the 'drain' method of
# disk flushes and to disable metadata barriers, in effect going
# back to pre-8.0.7 behaviour
vmaj = version['k_major']
vmin = version['k_minor']
vrel = version['k_point']
assert vmaj == 8
if vmin == 0: # 8.0.x
if vrel >= 12:
args.extend(['-i', '-m'])
elif vmin == 2: # 8.2.x
if vrel >= 7:
args.extend(['-i', '-m'])
elif vmaj >= 3: # 8.3.x or newer
args.extend(['-i', '-a', 'm'])
result = utils.RunCmd(args)
if result.failed:
_ThrowError("drbd%d: can't attach local disk: %s", minor, result.output)
......
......@@ -255,6 +255,7 @@ LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
# drbd constants
DRBD_HMAC_ALG = "md5"
DRBD_NET_PROTOCOL = "C"
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
# file backend driver
FD_LOOP = "loop"
......
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