This fixes a problem in commit
e6bb780d242, in which the
back compat handling for the old locking_type=4 was
incorrectly translated to mean the same thing as --readonly,
which prevented activation because activation uses an
exclusive vg lock. Previously, locking_type=4 allowed
activation.
If we see locking_type 4 in an old config, translate it to
the new combination of --readonly and --sysinit, which we
now define to mean the --readonly behavior with an exception
to allow activation.
/*
* A mess of options have been introduced over time to override
- * or tweak the behavior of file locking. These options are
- * allowed in different but overlapping sets of commands
- * (see command-lines.in)
+ * or tweak the behavior of file locking, and indirectly other
+ * behaviors. These options are allowed in different but
+ * overlapping sets of commands (see command-lines.in)
*
* --nolocking
*
*
* Command will grant any read lock request, without trying
* to acquire an actual file lock. Command will refuse any
- * write lock request.
+ * write lock request. (Activation, which uses a write lock,
+ * is not allowed.)
*
* --ignorelockingfailure
*
*
* The same as ignorelockingfailure.
*
+ * --sysinit --readonly
+ *
+ * The combination of these two flags acts like --readonly,
+ * refusing write lock requests, but makes an exception to
+ * allow activation.
+ *
* global/metadata_read_only
*
* The command acquires actual read locks and refuses
* When --readonly is set, grant read lock requests without trying to
* acquire an actual lock, and refuse write lock requests.
*/
- if (_file_locking_readonly) {
+ if (_file_locking_readonly && !_file_locking_sysinit) {
+ if (lck_type != LCK_WRITE)
+ goto out_hold;
+
+ log_error("Operation prohibited while --readonly is set.");
+ goto out_fail;
+ }
+
+ /*
+ * When --readonly and --sysinit are set, grant read lock requests without
+ * trying to acquire an actual lock, and refuse write lock requests except
+ * in the case of activation which is permitted.
+ */
+ if (_file_locking_readonly && _file_locking_sysinit) {
if (lck_type != LCK_WRITE)
goto out_hold;
+ if (cmd->is_activating) {
+ log_warn("Allowing activation with --readonly --sysinit.");
+ goto out_hold;
+ }
+
log_error("Operation prohibited while --readonly is set.");
goto out_fail;
}
lvchange --activate Active VG|LV|Tag|Select ...
OO: --activationmode ActivationMode, --partial, --poll Bool, --monitor Bool,
---ignoreactivationskip, --ignorelockingfailure, --sysinit, OO_LVCHANGE
+--ignoreactivationskip, --ignorelockingfailure, --sysinit, --readonly, OO_LVCHANGE
IO: --ignoreskippedcluster
ID: lvchange_activate
DESC: Activate or deactivate an LV.
vgchange --activate Active
OO: --activationmode ActivationMode, --ignoreactivationskip, --partial, --sysinit,
---ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE
+--readonly, --ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE
OP: VG|Tag|Select ...
IO: --ignoreskippedcluster
ID: vgchange_activate
int locking_type;
int nolocking = 0;
int readonly = 0;
+ int sysinit = 0;
int monitoring;
char *arg_new, *arg;
int i;
log_warn("WARNING: see lvmlockd(8) for information on using cluster/clvm VGs.");
if ((locking_type == 0) || (locking_type == 5)) {
- log_warn("WARNING: locking_type is deprecated, using --nolocking.");
+ log_warn("WARNING: locking_type (%d) is deprecated, using --nolocking.", locking_type);
nolocking = 1;
} else if (locking_type == 4) {
- log_warn("WARNING: locking_type is deprecated, using --readonly.");
+ log_warn("WARNING: locking_type (%d) is deprecated, using --sysinit --readonly.", locking_type);
+ sysinit = 1;
readonly = 1;
} else if (locking_type != 1) {
- log_warn("WARNING: locking_type is deprecated, using file locking.");
+ log_warn("WARNING: locking_type (%d) is deprecated, using file locking.", locking_type);
}
if (arg_is_set(cmd, nolocking_ARG) || _cmd_no_meta_proc(cmd))
nolocking = 1;
+ if (arg_is_set(cmd, sysinit_ARG))
+ sysinit = 1;
+
if (arg_is_set(cmd, readonly_ARG))
readonly = 1;
if (!_cmd_no_meta_proc(cmd))
log_warn("WARNING: File locking is disabled.");
} else {
- if (!init_locking(cmd, arg_is_set(cmd, sysinit_ARG), readonly, arg_is_set(cmd, ignorelockingfailure_ARG))) {
+ if (!init_locking(cmd, sysinit, readonly, arg_is_set(cmd, ignorelockingfailure_ARG))) {
ret = ECMD_FAILED;
goto_out;
}