]> xenbits.xensource.com Git - libvirt.git/commitdiff
sanlock: fix locking for readonly devices
authorDavid Weber <wb@munzinger.de>
Mon, 14 May 2012 09:53:02 +0000 (09:53 +0000)
committerEric Blake <eblake@redhat.com>
Mon, 14 May 2012 22:44:09 +0000 (16:44 -0600)
Add ignore param for readonly and shared disk in sanlock

AUTHORS
src/locking/libvirt_sanlock.aug
src/locking/lock_driver_sanlock.c
src/locking/sanlock.conf
src/locking/test_libvirt_sanlock.aug

diff --git a/AUTHORS b/AUTHORS
index 979d3e9dc521169991c076a8b8cf5ab888adb92c..db8a031e34e6e514b208fdf40f7638eeeeb27ea8 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -237,6 +237,7 @@ Patches have also been contributed by:
   Eugen Feller         <eugen.feller@inria.fr>
   Dmitry Guryanov      <dguryanov@parallels.com>
   William Jon McCann   <william.jon.mccann@gmail.com>
+  David Weber          <wb@munzinger.de>
 
   [....send patches to get your name here....]
 
index 5f5f8a12732e3b76761d7a738fe82e5177d002ac..d65b002efe67b98d5251f6fcbe5833ddb27328a5 100644 (file)
@@ -21,6 +21,7 @@ module Libvirt_sanlock =
              | bool_entry "auto_disk_leases"
              | int_entry "host_id"
              | bool_entry "require_lease_for_disks"
+             | bool_entry "ignore_readonly_and_shared_disks"
    let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
    let empty = [ label "#empty" . eol ]
 
index d344d6ae4626bd028186cc4b12261071ad450088..146aefd6489b7bad73bccf8a77e59c7f9a499e59 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * lock_driver_sanlock.c: A lock driver for Sanlock
  *
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -65,6 +65,7 @@ struct _virLockManagerSanlockDriver {
     bool requireLeaseForDisks;
     int hostID;
     bool autoDiskLease;
+    bool ignoreReadonlyShared;
     char *autoDiskLeasePath;
 };
 
@@ -114,6 +115,10 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
     CHECK_TYPE("auto_disk_leases", VIR_CONF_LONG);
     if (p) driver->autoDiskLease = p->l;
 
+    p = virConfGetValue(conf, "ignore_readonly_and_shared_disks");
+    CHECK_TYPE("ignore_readonly_and_shared_disks", VIR_CONF_LONG);
+    if (p) driver->ignoreReadonlyShared = p->l;
+
     p = virConfGetValue(conf, "disk_lease_dir");
     CHECK_TYPE("disk_lease_dir", VIR_CONF_STRING);
     if (p && p->str) {
@@ -625,6 +630,12 @@ static int virLockManagerSanlockAddResource(virLockManagerPtr lock,
         return -1;
     }
 
+    if ((flags & (VIR_LOCK_MANAGER_RESOURCE_READONLY |
+                  VIR_LOCK_MANAGER_RESOURCE_SHARED)) &&
+        driver->ignoreReadonlyShared) {
+            return 0;
+    }
+
     if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY) {
         virLockError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                      _("Readonly leases are not supported"));
index efc35ee7285f9e9865532b27a2d78366f7246b2a..19ab2b31887d36c83791ed98148f656bc7fe9479 100644 (file)
 # to enabled, otherwise it defaults to disabled.
 #
 #require_lease_for_disks = 1
+
+#
+# Enable this flag to have sanlock ignore readonly and shared disks.
+# If disabled, then this rejects attempts to share resources until
+# sanlock gains support for shared locks.
+#
+#ignore_readonly_and_shared_disks = 1
index b5169e110df2fb8dc1a95640731674d639ced27d..90ab59fe3a5e6749178f8ce3b8fad22b90ce73d0 100644 (file)
@@ -4,6 +4,7 @@ module Test_libvirt_sanlock =
 disk_lease_dir = \"/var/lib/libvirt/sanlock\"
 host_id = 1
 require_lease_for_disks = 1
+ignore_readonly_and_shared_disks = 1
 "
 
    test Libvirt_sanlock.lns get conf =
@@ -11,3 +12,4 @@ require_lease_for_disks = 1
 { "disk_lease_dir" = "/var/lib/libvirt/sanlock" }
 { "host_id" = "1" }
 { "require_lease_for_disks" = "1" }
+{ "ignore_readonly_and_shared_disks" = "1" }