Add a crude disable for DRBD barriers
authorIustin Pop <iustin@google.com>
Mon, 25 Jan 2010 12:10:25 +0000 (13:10 +0100)
committerIustin Pop <iustin@google.com>
Mon, 25 Jan 2010 16:23:00 +0000 (17:23 +0100)
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
configure.ac
lib/bdev.py
lib/constants.py

index 513d67b..202a143 100644 (file)
@@ -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
index 441bd3a..ab3d935 100644 (file)
@@ -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
index 722f12c..d9718a7 100644 (file)
@@ -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)
index c20e65b..74f3303 100644 (file)
@@ -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"