diff options
author | David Teigland <teigland@redhat.com> | 2015-07-13 13:48:39 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2015-07-13 14:07:57 -0500 |
commit | 3da88b89172b588bef69d62e18ed5db127b2c845 (patch) | |
tree | b369b86839d4039127328503e13ef5f4c28263ac /tools/vgexport.c | |
parent | 9cfa27f9c56edad26c2830562233b48e06bb4802 (diff) | |
download | lvm2-3da88b89172b588bef69d62e18ed5db127b2c845.tar.gz |
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.
Diffstat (limited to 'tools/vgexport.c')
-rw-r--r-- | tools/vgexport.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/vgexport.c b/tools/vgexport.c index 7e90e5c14..566cc96e4 100644 --- a/tools/vgexport.c +++ b/tools/vgexport.c @@ -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; |