]> sourceware.org Git - lvm2.git/commitdiff
Fix locking query compatibility with old external locking libraries.
authorMilan Broz <mbroz@redhat.com>
Wed, 20 May 2009 12:58:03 +0000 (12:58 +0000)
committerMilan Broz <mbroz@redhat.com>
Wed, 20 May 2009 12:58:03 +0000 (12:58 +0000)
lib/activate/activate.c
lib/locking/.exported_symbols
lib/locking/external_locking.c
lib/locking/locking.c

index 9619f7adcb06a47cdf7a883f14e47b9164a191c1..efc3b61bcfe44a2d1af3fe7852dc218eecff8b1e 100644 (file)
@@ -694,13 +694,30 @@ int lvs_in_vg_opened(const struct volume_group *vg)
  */
 int lv_is_active(struct logical_volume *lv)
 {
+       int ret;
+
        if (_lv_active(lv->vg->cmd, lv, 0))
                return 1;
 
        if (!vg_is_clustered(lv->vg))
                return 0;
 
-       return remote_lock_held(lv->lvid.s);
+       if ((ret = remote_lock_held(lv->lvid.s)) >= 0)
+               return ret;
+
+       /*
+        * Old compatibility code if locking doesn't support lock query
+        * FIXME: check status to not deactivate already activate device
+        */
+       if (activate_lv_excl(lv->vg->cmd, lv)) {
+               deactivate_lv(lv->vg->cmd, lv);
+                       return 0;
+       }
+
+       /*
+        * Exclusive local activation failed so assume it is active elsewhere.
+        */
+       return 1;
 }
 
 /*
index 757a082ede2d40634bd5b76f9fa8d2cffa5d5782..ec92d131f07421d2330ecf067722b62adef15450 100644 (file)
@@ -1,4 +1,5 @@
 locking_init
 locking_end
 lock_resource
+lock_resource_query
 reset_locking
index 1bff650d6cfcf80605333ff5c1399987905437e3..73cb15269bb2dcd3ea42d2a0d2d37007e14ce582 100644 (file)
@@ -26,6 +26,7 @@ static int (*_lock_fn) (struct cmd_context * cmd, const char *resource,
                        uint32_t flags) = NULL;
 static int (*_init_fn) (int type, struct config_tree * cft,
                        uint32_t *flags) = NULL;
+static int (*_lock_query_fn) (const char *resource, int *mode) = NULL;
 
 static int _lock_resource(struct cmd_context *cmd, const char *resource,
                          uint32_t flags)
@@ -88,6 +89,10 @@ int init_external_locking(struct locking_type *locking, struct cmd_context *cmd)
                return 0;
        }
 
+       if (!(_lock_query_fn = dlsym(_locking_lib, "lock_resource_query")))
+               log_warn("WARNING: %s: _lock_resource_query() missing: "
+                        "Using inferior activation method.", libname);
+
        log_verbose("Loaded external locking library %s", libname);
        return _init_fn(2, cmd->cft, &locking->flags);
 }
index d57726dab5cfff5a3416e9f58556a50774783cee..d711a767b282065db88feed76b080e825d9e9bb2 100644 (file)
@@ -489,11 +489,13 @@ int remote_lock_held(const char *vol)
        if (!locking_is_clustered())
                return 0;
 
+       if (!_locking.lock_resource_query)
+               return -1;
+
        /*
         * If an error occured, expect that volume is active
         */
-       if (!_locking.lock_resource_query ||
-           !_locking.lock_resource_query(vol, &mode)) {
+       if (!_locking.lock_resource_query(vol, &mode)) {
                stack;
                return 1;
        }
This page took 0.035686 seconds and 5 git commands to generate.