]> sourceware.org Git - lvm2.git/commitdiff
When using local file locking, skip clustered VGs.
authorAlasdair Kergon <agk@redhat.com>
Sat, 2 Sep 2006 01:18:17 +0000 (01:18 +0000)
committerAlasdair Kergon <agk@redhat.com>
Sat, 2 Sep 2006 01:18:17 +0000 (01:18 +0000)
Add fallback_to_clustered_locking and fallback_to_local_locking parameters.

18 files changed:
WHATS_NEW
doc/example.conf
lib/config/defaults.h
lib/locking/locking.c
tools/lvconvert.c
tools/lvcreate.c
tools/lvrename.c
tools/lvresize.c
tools/pvchange.c
tools/pvmove.c
tools/pvresize.c
tools/reporter.c
tools/toollib.c
tools/vgextend.c
tools/vgmerge.c
tools/vgreduce.c
tools/vgrename.c
tools/vgsplit.c

index ee8e263614164033f4d2abe2992a8b25cc014230..a15ba61376d7866b6f9a9f26ea54fbfb662c774e 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.02.10 - 
 ==================================
+  When using local file locking, skip clustered VGs.
+  Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
   lvm.static uses built-in cluster locking instead of external locking.
   Don't attempt to load shared libraries if built statically.
   Change default locking_lib to liblvm2clusterlock.so.
index c4c6a07a44825ca4ff15ced21189843ded6d5ae4..e7195afab5362456e1b2d8c6ca20e5cda222e492 100644 (file)
@@ -207,11 +207,26 @@ global {
     # Location of proc filesystem
     proc = "/proc"
 
-    # Type of locking to use. Defaults to file-based locking (1).
+    # Type of locking to use. Defaults to local file-based locking (1).
     # Turn locking off by setting to 0 (dangerous: risks metadata corruption
     # if LVM2 commands get run concurrently).
+    # Type 2 uses the external shared library locking_library.
+    # Type 3 uses built-in clustered locking.
     locking_type = 1
 
+    # If using external locking (type 2) and initialisation fails,
+    # with this set to 1 an attempt will be made to use the built-in
+    # clustered locking.
+    # If you are using a customised locking_library you should set this to 0.
+    fallback_to_clustered_locking = 1
+
+    # If an attempt to initialise type 2 or type 3 locking failed, perhaps
+    # because cluster components such as clvmd are not running, with this set
+    # to 1 an attempt will be made to use local file-based locking (type 1).
+    # If this succeeds, only commands against local volume groups will proceed.
+    # Volume Groups marked as clustered will be ignored.
+    fallback_to_local_locking = 1
+
     # Local non-LV directory that holds file-based locks while commands are
     # in progress.  A directory like /tmp that may get wiped on reboot is OK.
     locking_dir = "/var/lock/lvm"
index 31686f227458b72e60ffe93b7b6a3c604d9f99ef..45610464b61dc822126e933e65e2416af2c7dccb 100644 (file)
@@ -33,6 +33,8 @@
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
+#define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
+#define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
 
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
 #define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
index dfe6c6a95eb8e01142061b9f1ce338ec06dc2cb3..25065d4d054280ec94ad8eba48f9bc5a8236bda4 100644 (file)
@@ -20,6 +20,7 @@
 #include "activate.h"
 #include "toolcontext.h"
 #include "memlock.h"
+#include "defaults.h"
 
 #include <signal.h>
 #include <sys/stat.h>
@@ -147,6 +148,10 @@ int init_locking(int type, struct cmd_context *cmd)
                                break;
                        return 1;
                }
+               if (!find_config_tree_int(cmd, "locking/fallback_to_clustered_locking",
+                                         DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING))
+                       break;
+               log_very_verbose("Falling back to clustered locking.");
                /* Fall through */
 #endif
 
@@ -163,6 +168,16 @@ int init_locking(int type, struct cmd_context *cmd)
                return 0;
        }
 
+       if ((type == 2 || type == 3) &&
+            find_config_tree_int(cmd, "locking/fallback_to_local_locking",
+                                DEFAULT_FALLBACK_TO_LOCAL_LOCKING)) {
+               log_print("WARNING: Falling back to local file-based locking.");
+               log_print("Volume Groups with the clustered attribute will "
+                         "be inaccessible.");
+               if (init_file_locking(&_locking, cmd))
+                       return 1;
+       }
+
        if (!ignorelockingfailure())
                return 0;
 
index 0aa0c90846cd1646e54247b0d752704830f0fecb..03f4673a6f9d6ff9b22e8ffbffce80a825927a37 100644 (file)
@@ -565,6 +565,12 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
                goto error;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", lp.vg_name);
+               goto error;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", lp.vg_name);
                goto error;
index a7e1aac0f660cb783145270e594b4d50c7b4514d..a8964d215ec34941abc73bcc6dfc783abebfcd61 100644 (file)
@@ -486,6 +486,12 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                return 0;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", lp->vg_name);
+               return 0;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", lp->vg_name);
                return 0;
index 29683d794ec60a0a3b1af406d3d30943236735e3..f29b52b9f16476dfd3a9d0491b3eb4b5c7ac1a7d 100644 (file)
@@ -109,6 +109,12 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
                goto error;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg->name);
+               goto error;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vg->name);
                goto error;
index 52e0596978b39519a6c16b8b9ae154b7aa16219c..a226b90528099a0e79e700f8c696e29a4f805333 100644 (file)
@@ -138,6 +138,12 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
                return ECMD_FAILED;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg->name);
+               return ECMD_FAILED;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group %s is exported", vg->name);
                return ECMD_FAILED;
index 7056ddd21fcdfeb577fc8541d5117b081992c0d8..a4c0aa4534aa8c48caf069057daf4715e6ed8f66 100644 (file)
@@ -67,6 +67,12 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
                        return 0;
                }
 
+               if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+                   !lockingfailed()) {
+                       log_error("Skipping clustered volume group %s", vg->name);
+                       return 0;
+               }
+
                if (vg->status & EXPORTED_VG) {
                        unlock_vg(cmd, pv->vg_name);
                        log_error("Volume group \"%s\" is exported", vg->name);
index 5e9d3cf0035f3b42656bbed6f8a7a0e69cdd55d0..7c3d94375e5538f3b555f1622a90dabe0be2ab5d 100644 (file)
@@ -66,6 +66,12 @@ static struct volume_group *_get_vg(struct cmd_context *cmd, const char *vgname)
                return NULL;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vgname);
+               return NULL;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vgname);
                unlock_vg(cmd, vgname);
index 5458426dbc8625465694408a00cb734c9d58cafa..3de3ab945f195b0718383ae730994b91b09c58ab 100644 (file)
@@ -77,6 +77,13 @@ static int _pvresize_single(struct cmd_context *cmd,
                        return ECMD_FAILED;
                }
 
+               if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+                   !lockingfailed()) {
+                       unlock_vg(cmd, vg_name);
+                       log_error("Skipping clustered volume group %s", vg->name);
+                       return ECMD_FAILED;
+               }
+
                if (vg->status & EXPORTED_VG) {
                        unlock_vg(cmd, vg_name);
                        log_error("Volume group \"%s\" is exported", vg->name);
index 5bfd50cb4287b9e347e8fe5802368f3231573197..f1257d5a378e255ce113a448b9f38c8aeb8f1603 100644 (file)
@@ -68,13 +68,20 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
 
        if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) {
                log_error("Can't read %s: skipping", pv->vg_name);
-               unlock_vg(cmd, pv->vg_name);
-               return ECMD_FAILED;
+               goto out;
+       }
+
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg->name);
+               ret = ECMD_FAILED;
+               goto out;
        }
 
        if (!report_object(handle, vg, NULL, pv, NULL, pvseg))
                ret = ECMD_FAILED;
 
+out:
        unlock_vg(cmd, pv->vg_name);
        return ret;
 }
@@ -109,14 +116,22 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
 
                if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) {
                        log_error("Can't read %s: skipping", pv->vg_name);
-                       unlock_vg(cmd, pv->vg_name);
-                       return ECMD_FAILED;
+                       goto out;
+               }
+
+               if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+                   !lockingfailed()) {
+                       log_error("Skipping clustered volume group %s",
+                                 vg->name);
+                       ret = ECMD_FAILED;
+                       goto out;
                }
        }
 
        if (!report_object(handle, vg, NULL, pv, NULL, NULL))
                ret = ECMD_FAILED;
 
+out:
        if (pv->vg_name)
                unlock_vg(cmd, pv->vg_name);
 
index a9c924b91ded6d3f1cc89f7ac54f694633471f7b..91b335df8f08556c0b41bf67e9fc3b4a9e478e0d 100644 (file)
@@ -329,9 +329,20 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
                        if (!vg)
                                log_error("Volume group \"%s\" "
                                          "not found", vgname);
-                       else
+                       else {
+                               if ((vg->status & CLUSTERED) &&
+                                   !locking_is_clustered() &&
+                                   !lockingfailed()) {
+                                       log_error("Skipping clustered volume "
+                                                 "group %s", vgname);
+                                       if (ret_max < ECMD_FAILED)
+                                               ret_max = ECMD_FAILED;
+                                       continue;
+                               }
                                log_error("Volume group \"%s\" "
                                          "inconsistent", vgname);
+                       }
+
                        if (!vg || !(vg = recover_vg(cmd, vgname, lock_type))) {
                                if (ret_max < ECMD_FAILED)
                                        ret_max = ECMD_FAILED;
@@ -339,6 +350,15 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
                        }
                }
 
+               if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+                   !lockingfailed()) {
+                       unlock_vg(cmd, vgname);
+                       log_error("Skipping clustered volume group %s", vgname);
+                       if (ret_max < ECMD_FAILED)
+                               ret_max = ECMD_FAILED;
+                       continue;
+               }
+
                tags_arg = &tags;
                list_init(&lvnames);    /* LVs to be processed in this VG */
                list_iterate_items(sll, &arg_lvnames) {
@@ -438,6 +458,13 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
                return ECMD_FAILED;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg_name);
+               unlock_vg(cmd, vg_name);
+               return ECMD_FAILED;
+       }
+
        if (!list_empty(tags)) {
                /* Only process if a tag matches or it's on arg_vgnames */
                if (!str_list_match_item(arg_vgnames, vg_name) &&
@@ -680,6 +707,15 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
                                }
                                if (!consistent)
                                        continue;
+
+                               if ((vg->status & CLUSTERED) &&
+                                   !locking_is_clustered() &&
+                                   !lockingfailed()) {
+                                       log_error("Skipping clustered volume "
+                                                 "group %s", sll->str);
+                                       continue;
+                               }
+
                                ret = process_each_pv_in_vg(cmd, vg, &tags,
                                                            handle,
                                                            process_single);
@@ -1045,6 +1081,10 @@ struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
 {
        int consistent = 1;
 
+       /* Don't attempt automatic recovery without proper locking */
+       if (lockingfailed())
+               return NULL;
+
        lock_type &= ~LCK_TYPE_MASK;
        lock_type |= LCK_WRITE;
 
index a94c5788fba4dd02ff51123bd02b5a38f3d475bd..7ec7008bae2ddb2911137f544d056e16ceb2cf52 100644 (file)
@@ -53,6 +53,12 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
                goto error;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg->name);
+               goto error;
+       }
+
        if (vg->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vg->name);
                goto error;
index 73b7fa81320f82baa08471e091a43033bdeb6ed0..761ef88370cbad5ff8e0ca2a730caf0e99c4819b 100644 (file)
@@ -41,6 +41,13 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
                return ECMD_FAILED;
        }
 
+       if ((vg_to->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg_name_to);
+               unlock_vg(cmd, vg_name_to);
+               return ECMD_FAILED;
+       }
+
        if (vg_to->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vg_to->name);
                unlock_vg(cmd, vg_name_to);
@@ -66,6 +73,12 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
                goto error;
        }
 
+        if ((vg_from->status & CLUSTERED) && !locking_is_clustered() &&
+            !lockingfailed()) {
+                log_error("Skipping clustered volume group %s", vg_name_from);
+                goto error;
+        }
+
        if (vg_from->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vg_from->name);
                goto error;
index 86ff7fde741ff6fc95fb0a2bacfdc6f6200d84e1..058908562c27dc7837056d32216cbd7443f2076f 100644 (file)
@@ -476,6 +476,13 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
                return ECMD_FAILED;
        }
 
+       if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg->name);
+               unlock_vg(cmd, vg_name);
+               return ECMD_FAILED;
+       }
+
        if (arg_count(cmd, removemissing_ARG)) {
                if (vg && consistent) {
                        log_error("Volume group \"%s\" is already consistent",
@@ -491,6 +498,13 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
                        unlock_vg(cmd, vg_name);
                        return ECMD_FAILED;
                }
+               if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+                   !lockingfailed()) {
+                       log_error("Skipping clustered volume group %s",
+                                 vg->name);
+                       unlock_vg(cmd, vg_name);
+                       return ECMD_FAILED;
+               }
                if (!archive(vg)) {
                        init_partial(0);
                        unlock_vg(cmd, vg_name);
index 95eec95145a2f0ad32f6ac96d76d7a7eb4f1e07f..7a724a593260eeb0c5e248a09fb91ce839b94033 100644 (file)
@@ -102,6 +102,13 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
                return ECMD_FAILED;
        }
 
+       if ((vg_old->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg_old->name);
+               unlock_vg(cmd, vg_name_old);
+               return ECMD_FAILED;
+       }
+
        if (vg_old->status & EXPORTED_VG)
                log_info("Volume group \"%s\" is exported", vg_old->name);
 
index 42cecf6889caf531c314686917756b7956ad9140..75dde775042d1ba8c5182048eed68fce06a07a6f 100644 (file)
@@ -196,6 +196,13 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
                return ECMD_FAILED;
        }
 
+       if ((vg_from->status & CLUSTERED) && !locking_is_clustered() &&
+           !lockingfailed()) {
+               log_error("Skipping clustered volume group %s", vg_from->name);
+               unlock_vg(cmd, vg_name_from);
+               return ECMD_FAILED;
+       }
+
        if (vg_from->status & EXPORTED_VG) {
                log_error("Volume group \"%s\" is exported", vg_from->name);
                unlock_vg(cmd, vg_name_from);
This page took 0.064613 seconds and 5 git commands to generate.