mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
lockd: fix error cases when built without lvmlockd
When lvm is built without lvmlockd support, vgcreate using a shared lock type would succeed and create a local VG (the --shared option was effectively ignored). Make it fail. Fix the same issue when using vgchange to change a VG to a shared lock type. Make the error messages consistent.
This commit is contained in:
parent
b93b85378d
commit
268f53ed0d
@ -167,6 +167,14 @@ static inline int lockd_start_wait(struct cmd_context *cmd)
|
||||
|
||||
static inline int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *vg_lock_type)
|
||||
{
|
||||
/*
|
||||
* When lvm is built without lvmlockd support, creating a VG with
|
||||
* a shared lock type should fail.
|
||||
*/
|
||||
if (is_lockd_type(vg_lock_type)) {
|
||||
log_error("Using a shared lock type requires lvmlockd.");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -220,6 +228,7 @@ static inline int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg
|
||||
|
||||
static inline const char *lockd_running_lock_type(struct cmd_context *cmd)
|
||||
{
|
||||
log_error("Using a shared lock type requires lvmlockd.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -927,7 +927,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||
} else if (arg_is_set(cmd, shared_ARG)) {
|
||||
if (use_lvmlockd) {
|
||||
if (!(lock_type = lockd_running_lock_type(cmd))) {
|
||||
log_error("Failed to detect a running lock manager to select lock_type.");
|
||||
log_error("Failed to detect a running lock manager to select lock type.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -936,7 +936,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
log_error("The --shared option requires lvmlockd (use_lvmlockd=1).");
|
||||
log_error("Using a shared lock type requires lvmlockd.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -961,13 +961,13 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||
case LOCK_TYPE_SANLOCK:
|
||||
case LOCK_TYPE_DLM:
|
||||
if (!use_lvmlockd) {
|
||||
log_error("lock_type %s requires use_lvmlockd configuration setting", lock_type);
|
||||
log_error("Using a shared lock type requires lvmlockd.");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case LOCK_TYPE_CLVM:
|
||||
if (!use_clvmd) {
|
||||
log_error("lock_type clvm requires locking_type 3 configuration setting");
|
||||
log_error("Using clvm requires locking_type 3.");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1007,6 +1007,16 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
/* The default vg lock mode is ex, but these options only need sh. */
|
||||
|
||||
if (!lvmlockd_use() && arg_is_set(cmd, locktype_ARG)) {
|
||||
log_error("Using lock type requires lvmlockd.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lvmlockd_use() && (arg_is_set(cmd, lockstart_ARG) || arg_is_set(cmd, lockstop_ARG))) {
|
||||
log_error("Using lock start and lock stop requires lvmlockd.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG))
|
||||
cmd->lockd_vg_default_sh = 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user