mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmlockd: skip more vgremove steps with lockopt force
vgremove with --lockopt force should skip lvmlockd-related steps and allow a forced vg cleanup, in addition to using --nolocking to skip normal locking calls.
This commit is contained in:
parent
4dc009c872
commit
58e75f6178
@ -1223,10 +1223,22 @@ static int _lockd_all_lvs(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
/* vgremove before the vg is removed */
|
/* vgremove before the vg is removed */
|
||||||
|
|
||||||
int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg,
|
int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
int changing)
|
int changing, const char *lockopt, int yes)
|
||||||
{
|
{
|
||||||
int lock_type_num = get_lock_type_from_string(vg->lock_type);
|
int lock_type_num = get_lock_type_from_string(vg->lock_type);
|
||||||
|
|
||||||
|
if (lockopt && strstr(lockopt, "force")) {
|
||||||
|
if (!yes && yes_no_prompt("Force unprotected removal of shared VG? [y/n]: ") == 'n') {
|
||||||
|
log_error("VG not removed.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (vg->sanlock_lv) {
|
||||||
|
_deactivate_sanlock_lv(cmd, vg);
|
||||||
|
_remove_sanlock_lv(cmd, vg);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that no LVs are active on other hosts.
|
* Check that no LVs are active on other hosts.
|
||||||
* When removing (not changing), each LV is locked
|
* When removing (not changing), each LV is locked
|
||||||
|
@ -56,7 +56,7 @@ void lvmlockd_disconnect(void);
|
|||||||
/* vgcreate/vgremove use init/free */
|
/* vgcreate/vgremove use init/free */
|
||||||
|
|
||||||
int lockd_init_vg(struct cmd_context *cmd, struct volume_group *vg, const char *lock_type, int lv_lock_count);
|
int lockd_init_vg(struct cmd_context *cmd, struct volume_group *vg, const char *lock_type, int lv_lock_count);
|
||||||
int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg, int changing);
|
int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg, int changing, const char *lockopt, int yes);
|
||||||
void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg);
|
void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg);
|
||||||
|
|
||||||
/* vgrename */
|
/* vgrename */
|
||||||
|
@ -1215,7 +1215,7 @@ static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
* lockd type to ..., first undo lockd type
|
* lockd type to ..., first undo lockd type
|
||||||
*/
|
*/
|
||||||
if (is_lockd_type(vg->lock_type)) {
|
if (is_lockd_type(vg->lock_type)) {
|
||||||
if (!lockd_free_vg_before(cmd, vg, 1))
|
if (!lockd_free_vg_before(cmd, vg, 1, NULL, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
lockd_free_vg_final(cmd, vg);
|
lockd_free_vg_final(cmd, vg);
|
||||||
|
@ -70,7 +70,7 @@ static int _vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
|||||||
!lvremove_single(cmd, vg->pool_metadata_spare_lv, &void_handle))
|
!lvremove_single(cmd, vg->pool_metadata_spare_lv, &void_handle))
|
||||||
return_ECMD_FAILED;
|
return_ECMD_FAILED;
|
||||||
|
|
||||||
if (!lockd_free_vg_before(cmd, vg, 0))
|
if (!lockd_free_vg_before(cmd, vg, 0, arg_str_value(cmd, lockopt_ARG, NULL), arg_is_set(cmd, yes_ARG)))
|
||||||
return_ECMD_FAILED;
|
return_ECMD_FAILED;
|
||||||
|
|
||||||
if (!force && !vg_remove_check(vg))
|
if (!force && !vg_remove_check(vg))
|
||||||
|
Loading…
Reference in New Issue
Block a user