Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
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.
# 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"
#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"
#include "activate.h"
#include "toolcontext.h"
#include "memlock.h"
+#include "defaults.h"
#include <signal.h>
#include <sys/stat.h>
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
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;
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;
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;
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;
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;
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);
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);
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);
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;
}
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);
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;
}
}
+ 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) {
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) &&
}
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);
{
int consistent = 1;
+ /* Don't attempt automatic recovery without proper locking */
+ if (lockingfailed())
+ return NULL;
+
lock_type &= ~LCK_TYPE_MASK;
lock_type |= LCK_WRITE;
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;
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);
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;
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",
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);
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);
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);