mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
vgchange/lvchange: enforce the shared VG lock from lvmlockd
The vgchange/lvchange activation commands read the VG, and don't write it, so they acquire a shared VG lock from lvmlockd. When other commands fail to acquire a shared VG lock from lvmlockd, a warning is printed and they continue without it. (Without it, the VG metadata they display from lvmetad may not be up to date.) vgchange/lvchange -a shouldn't continue without the shared lock for a couple reasons: . Usually they will just continue on and fail to acquire the LV locks for activation, so continuing is pointless. . More importantly, without the sh VG lock, the VG metadata used by the command may be stale, and the LV locks shown in the VG metadata may no longer be current. In the case of sanlock, this would result in odd, unpredictable errors when lvmlockd doesn't find the expected lock on disk. In the case of dlm, the invalid LV lock could be granted for the non-existing LV. The solution is to not continue after the shared lock fails, in the same way that a command fails if an exclusive lock fails.
This commit is contained in:
parent
b785a50da4
commit
b4be988732
@ -107,6 +107,7 @@ struct cmd_context {
|
||||
unsigned lockd_vg_disable:1;
|
||||
unsigned lockd_lv_disable:1;
|
||||
unsigned lockd_vg_default_sh:1;
|
||||
unsigned lockd_vg_enforce_sh:1;
|
||||
|
||||
struct dev_types *dev_types;
|
||||
|
||||
|
@ -4803,7 +4803,7 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
|
||||
* no lock.
|
||||
*/
|
||||
if (lockd_state & LDST_FAIL) {
|
||||
if (lockd_state & LDST_EX) {
|
||||
if ((lockd_state & LDST_EX) || cmd->lockd_vg_enforce_sh) {
|
||||
log_error("Cannot access VG %s due to failed lock.", vg->name);
|
||||
*failure |= FAILED_LOCK_MODE;
|
||||
return 0;
|
||||
|
@ -1294,8 +1294,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
* are cases where lvchange does not modify the vg, so they can use
|
||||
* the sh lock mode.
|
||||
*/
|
||||
if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG))
|
||||
if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG)) {
|
||||
cmd->lockd_vg_default_sh = 1;
|
||||
cmd->lockd_vg_enforce_sh = 1;
|
||||
}
|
||||
|
||||
return process_each_lv(cmd, argc, argv,
|
||||
update ? READ_FOR_UPDATE : 0, NULL,
|
||||
|
@ -1017,8 +1017,10 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG))
|
||||
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG)) {
|
||||
cmd->lockd_vg_default_sh = 1;
|
||||
cmd->lockd_vg_enforce_sh = 1;
|
||||
}
|
||||
|
||||
/* Starting a vg lockspace means there are no locks available yet. */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user