From f736563a7aaeb35d30b552037b4606f58e61bbd7 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Sat, 31 Oct 2009 17:30:52 +0000 Subject: [PATCH] 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. --- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 20 ++++++++++++++++++++ tools/vgchange.c | 18 ++---------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index bb1234acf..3f3f115a9 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -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); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 6dd801c6c..c6eaedf18 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -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. diff --git a/tools/vgchange.c b/tools/vgchange.c index 07d52621e..d6af3b008 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -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;