mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-21 05:57:48 +03:00
When using local file locking, skip clustered VGs.
Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
This commit is contained in:
parent
a45da5f676
commit
dc4d7417f7
@ -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.
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user