diff options
author | David Teigland <teigland@redhat.com> | 2018-09-12 15:59:47 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2018-09-12 16:30:50 -0500 |
commit | 0aeca60aaa65bde99115ec7ca92a93a885d3afb1 (patch) | |
tree | bc9cadf6f20db06f6c593223fd188ea37335a4ce /lib/locking | |
parent | 17bd91e33e0d37d8cca03b42cee20251d7fa5e80 (diff) | |
download | lvm2-0aeca60aaa65bde99115ec7ca92a93a885d3afb1.tar.gz |
fix readonly activation override options
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.
Diffstat (limited to 'lib/locking')
-rw-r--r-- | lib/locking/locking.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 3276283ce..a23b2725e 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -86,9 +86,9 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags) /* * 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 * @@ -98,7 +98,8 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags) * * 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 * @@ -111,6 +112,12 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags) * * 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 @@ -214,10 +221,28 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str * 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; } |