mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
9cfa27f9c5
commit
3da88b8917
@ -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"
|
||||
|
@ -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. */
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user