master - lockd: allow vgexport and vgimport
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3da88b89172b588bef69d62e18ed5db127b2c845 Commit: 3da88b89172b588bef69d62e18ed5db127b2c845 Parent: 9cfa27f9c56edad26c2830562233b48e06bb4802 Author: David Teigland <[email protected]> AuthorDate: Mon Jul 13 13:48:39 2015 -0500 Committer: David Teigland <[email protected]> CommitterDate: Mon Jul 13 14:07:57 2015 -0500
lockd: allow vgexport and vgimport
The "exported" state of the VG can be useful with lockd VGs because the exported state keeps a VG from being used in general. It's a way to keep a VG protected and out of the way.
Also fix the command flags: ALL_VGS_IS_DEFAULT is not true for vgimport/vgexport, since they both return errors immediately if no VG args are specified. LOCKD_VG_SH is not true for vgexport beause it must use an ex lock to write the VG.
--- tools/commands.h | 4 ++-- tools/vgchange.c | 12 +++++++++--- tools/vgexport.c | 25 ++++++++++++++++++------- tools/vgimport.c | 4 +++- 4 files changed, 32 insertions(+), 13 deletions(-)
tools/commands.h +2 -2
@@ -1191,7 +1191,7 @@ xx(vgdisplay,xx (vgexport,"Unregister volume group(s) from the system" , -ALL_VGS_IS_DEFAULT |LOCKD_VG_SH , +0 ,"vgexport\n" "\t[-a|--all]\n" "\t[--commandprofile ProfileName]\n"
@@ -1229,7 +1229,7 @@ xx(vgextend,xx (vgimport,"Register exported volume group with system" , -ALL_VGS_IS_DEFAULT , +0 ,"vgimport\n" "\t[-a|--all]\n" "\t[--commandprofile ProfileName]\n"
tools/vgchange.c +9 -3
@@ -888,7 +888,8 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, { systemid_ARG, &_vgchange_system_id }, }; -if (vg_is_exported (vg)) { +if (vg_is_exported (vg) && + !(arg_is_set (cmd, lockstop_ARG) ||arg_is_set (cmd, lockstart_ARG))) {log_error ("Volume group \"%s\" is exported" , vg_name);return ECMD_FAILED ; }
@@ -1052,6 +1053,7 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)int vgchange (struct cmd_context *cmd,int argc,char **argv) { +uint32_t flags =0 ;int ret; int noupdate =
@@ -1185,8 +1187,12 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)if (!_lockd_vgchange (cmd, argc, argv)) return_ECMD_FAILED; - ret =process_each_vg (cmd, argc, argv, update ?READ_FOR_UPDATE :0 , -NULL , &vgchange_single); +if (update) + flags |=READ_FOR_UPDATE ; +if (arg_is_set (cmd, lockstart_ARG) ||arg_is_set (cmd, lockstop_ARG)) + flags |=READ_ALLOW_EXPORTED ; + + ret =process_each_vg (cmd, argc, argv, flags,NULL , &vgchange_single);/* Wait for lock-start ops that were initiated in vgchange_lockstart. */
tools/vgexport.c +18 -7
@@ -22,19 +22,30 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)), {struct pv_list *pvl; -/* vgexport/vgimport have to use with shared VGs. */ -if (is_lockd_type (vg->lock_type)) { -log_error ("Volume group \"%s\" has lock_type %s that cannot be exported" , - vg_name, vg->lock_type); - goto bad; - } -if (lvs_in_vg_activated (vg)) {log_error ("Volume group \"%s\" has active logical volumes" , vg_name); goto bad; } +if (is_lockd_type (vg->lock_type)) { +struct lv_list *lvl; + dm_list_iterate_items(lvl, &vg->lvs) { +if (!lockd_lv_uses_lock (lvl->lv)) +continue ; + +if (!lockd_lv (cmd, lvl->lv,"ex" ,0 )) { +log_error ("LV %s/%s must be inactive on all hosts before vgexport." , + vg->name,display_lvname (lvl->lv)); + goto bad; + } + +if (!lockd_lv (cmd, lvl->lv,"un" ,0 )) + goto bad; + } + } + +if (!archive (vg)) goto_bad;
tools/vgimport.c +3 -1
@@ -37,7 +37,9 @@ static int vgimport_single(struct cmd_context *cmd, goto_bad; vg->status &= ~EXPORTED_VG ; - vg->system_id = cmd->system_id ?dm_pool_strdup (vg->vgmem, cmd->system_id) :NULL ; + +if (!is_lockd_type (vg->lock_type)) + vg->system_id = cmd->system_id ?dm_pool_strdup (vg->vgmem, cmd->system_id) :NULL ; dm_list_iterate_items(pvl, &vg->pvs) { pv = pvl->pv;