1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-23 21:35:29 +03:00

Add vg_set_clustered() - move logic from vgchange.

Similar to other vg_set_* functions, we create a vg_set_clustered() function
which does a few checks and sets a flag.  This is where we check for
any limitations of clusters.
This commit is contained in:
Dave Wysochanski 2009-10-31 17:30:52 +00:00
parent 0350c4f0f6
commit f736563a7a
3 changed files with 23 additions and 16 deletions

View File

@ -462,6 +462,7 @@ int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc);
int vg_set_clustered(struct volume_group *vg, int clustered);
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
struct volume_group *vg_to);

View File

@ -1127,6 +1127,26 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
return 1;
}
int vg_set_clustered(struct volume_group *vg, int clustered)
{
struct lv_list *lvl;
if (clustered) {
dm_list_iterate_items(lvl, &vg->lvs) {
if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
log_error("Volume group %s contains snapshots "
"that are not yet supported.",
vg->name);
return 0;
}
}
}
if (clustered)
vg->status |= CLUSTERED;
else
vg->status &= ~CLUSTERED;
return 1;
}
/*
* Separate metadata areas after splitting a VG.

View File

@ -245,7 +245,6 @@ static int _vgchange_clustered(struct cmd_context *cmd,
struct volume_group *vg)
{
int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
struct lv_list *lvl;
if (clustered && (vg_is_clustered(vg))) {
log_error("Volume group \"%s\" is already clustered",
@ -259,26 +258,13 @@ static int _vgchange_clustered(struct cmd_context *cmd,
return ECMD_FAILED;
}
if (clustered) {
dm_list_iterate_items(lvl, &vg->lvs) {
if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
log_error("Volume group %s contains snapshots "
"that are not yet supported.",
vg->name);
return ECMD_FAILED;
}
}
}
if (!archive(vg)) {
stack;
return ECMD_FAILED;
}
if (clustered)
vg->status |= CLUSTERED;
else
vg->status &= ~CLUSTERED;
if (!vg_set_clustered(vg, clustered))
return ECMD_FAILED;
if (!vg_write(vg) || !vg_commit(vg)) {
stack;