From 89b70f39e6f200538c08dfafe734ee9845a46ccb Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 25 Jan 2010 13:10:25 +0100 Subject: [PATCH] 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: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- Makefile.am | 1 + configure.ac | 15 ++++++++++++++- lib/bdev.py | 18 ++++++++++++++++++ lib/constants.py | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 513d67bda..202a14377 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 441bd3a0d..ab3d93577 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/bdev.py b/lib/bdev.py index 722f12cfc..d9718a781 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -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) diff --git a/lib/constants.py b/lib/constants.py index c20e65bde..74f330395 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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" -- GitLab