master - lvmlockd: add full changing of lock type
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de4db6a93b9e3be1968b1d1b7e2de8f1f88bacf0 Commit: de4db6a93b9e3be1968b1d1b7e2de8f1f88bacf0 Parent: d797f4d5903bf33618be38c543b8e7822a74b506 Author: David Teigland <[email protected]> AuthorDate: Mon Aug 24 15:06:23 2015 -0500 Committer: David Teigland <[email protected]> CommitterDate: Thu Aug 27 10:27:24 2015 -0500
lvmlockd: add full changing of lock type
Remove the existing lock type using the same functions used to remove the lockd components during vgremove. This results in a "clean" VG and lvmlockd state after the vgchange, i.e. no bits left over from previous lock type.
--- lib/locking/lvmlockd.c | 45 +++++++++++++++++++++++++++++++-------------- lib/locking/lvmlockd.h | 2 +- tools/vgchange.c | 41 ++++++++++++++++++++++++++--------------- tools/vgremove.c | 2 +- 4 files changed, 59 insertions(+), 31 deletions(-)
lib/locking/lvmlockd.c +31 -14
@@ -868,10 +868,37 @@ int lockd_init_vg(struct cmd_context *cmd, struct volume_group *vg, } } +static int _lockd_all_lvs (struct cmd_context *cmd,struct volume_group *vg) +{ +struct lv_list *lvl; + + dm_list_iterate_items(lvl, &vg->lvs) { +if (!lockd_lv (cmd, lvl->lv,"ex" ,0 )) { +log_error ("LV %s/%s must be inactive on all hosts." , + vg->name, lvl->lv->name); +return 0 ; + } + +if (!lockd_lv (cmd, lvl->lv,"un" ,0 )) { +log_error ("Failed to unlock LV %s/%s." , vg->name, lvl->lv->name); +return 0 ; + } + } + +return 1 ; +} +/* 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) { +/* Check that no LVs are active on other hosts. */ +if (changing && !_lockd_all_lvs (cmd, vg)) { +log_error ("Cannot change VG %s with active LVs" , vg->name); +return 0 ; + } +switch (get_lock_type_from_string (vg->lock_type)) {case LOCK_TYPE_NONE :case LOCK_TYPE_CLVM :
@@ -2374,7 +2401,6 @@ int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,int lockd_rename_vg_before (struct cmd_context *cmd,struct volume_group *vg) { -struct lv_list *lvl;daemon_reply reply;int result;int ret;
@@ -2392,18 +2418,9 @@ int lockd_rename_vg_before(struct cmd_context *cmd, struct volume_group *vg) }/* Check that no LVs are active on other hosts. */ - - dm_list_iterate_items(lvl, &vg->lvs) { -if (!lockd_lv (cmd, lvl->lv,"ex" ,0 )) { -log_error ("LV %s/%s must be inactive on all hosts before vgrename." , - vg->name, lvl->lv->name); -return 0 ; - } - -if (!lockd_lv (cmd, lvl->lv,"un" ,0 )) { -log_error ("Failed to unlock LV %s/%s." , vg->name, lvl->lv->name); -return 0 ; - } +if (!_lockd_all_lvs (cmd, vg)) { +log_error ("Cannot rename VG %s with active LVs" , vg->name); +return 0 ; }/*
lib/locking/lvmlockd.h +1 -1
@@ -54,7 +54,7 @@ void lvmlockd_disconnect(void);/* 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_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);void lockd_free_vg_final (struct cmd_context *cmd,struct volume_group *vg);/* vgrename */
tools/vgchange.c +26 -15
71 lines not on this page · raw message
tools/vgremove.c +1 -1
@@ -68,7 +68,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name, } } -if (!lockd_free_vg_before (cmd, vg)) +if (!lockd_free_vg_before (cmd, vg,0 )) return_ECMD_FAILED;if (!force && !vg_remove_check (vg))