diff options
-rw-r--r-- | lib/metadata/segtype.c | 16 | ||||
-rw-r--r-- | lib/metadata/segtype.h | 2 | ||||
-rw-r--r-- | tools/lvconvert.c | 16 | ||||
-rw-r--r-- | tools/lvcreate.c | 6 | ||||
-rw-r--r-- | tools/vgchange.c | 12 |
5 files changed, 51 insertions, 1 deletions
diff --git a/lib/metadata/segtype.c b/lib/metadata/segtype.c index 02dff4cbd..ebaf4a484 100644 --- a/lib/metadata/segtype.c +++ b/lib/metadata/segtype.c @@ -34,3 +34,19 @@ struct segment_type *get_segtype_from_string(struct cmd_context *cmd, return segtype; } + +int segtype_allowed_in_cluster_vg(const struct segment_type *segtype) +{ + if (segtype_is_striped(segtype)) + return 1; + if (segtype_is_raid(segtype)) + return 1; + if (segtype_is_thin(segtype)) + return 1; + if (segtype_is_mirror(segtype)) + return 1; + if (segtype_is_virtual(segtype)) + return 1; + + return 0; +} diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index 4635681cd..732da9ed2 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -136,6 +136,8 @@ struct segtype_handler { struct segment_type *get_segtype_from_string(struct cmd_context *cmd, const char *str); +int segtype_allowed_in_cluster_vg(const struct segment_type *segtype); + struct segtype_library; int lvm_register_segtype(struct segtype_library *seglib, struct segment_type *segtype); diff --git a/tools/lvconvert.c b/tools/lvconvert.c index f22c84ba8..5758c9125 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -3310,13 +3310,27 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, return_ECMD_FAILED; } } + if (lp->merge) { if ((lv_is_thin_volume(lv) && !_lvconvert_merge_thin_snapshot(cmd, lv, lp)) || (!lv_is_thin_volume(lv) && !_lvconvert_merge_old_snapshot(cmd, lv, lp))) { log_print_unless_silent("Unable to merge LV \"%s\" into its origin.", lv->name); return ECMD_FAILED; } - } else if (lp->snapshot) { + return ECMD_PROCESSED; + } + + /* + * Converting to a new type. + */ + + if (vg_is_clustered(lv->vg) && !segtype_allowed_in_cluster_vg(lp->segtype)) { + log_error("LV segtype %s is not allowed in a cluster VG.", + lp->segtype->name); + return ECMD_FAILED; + } + + if (lp->snapshot) { if (!_lvconvert_snapshot(cmd, lv, lp)) return_ECMD_FAILED; } else if (segtype_is_pool(lp->segtype) || lp->thin || lp->cache) { diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 6b8c4b5ff..94089fbcc 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -1432,6 +1432,12 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv) if (!_read_activation_params(cmd, vg, &lp)) goto_out; + if (vg_is_clustered(vg) && !segtype_allowed_in_cluster_vg(lp.segtype)) { + log_error("LV segtype %s is not allowed in a cluster VG.", + lp.segtype->name); + goto_out; + } + /* Resolve segment types with opened VG */ if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp, &lcp)) goto_out; diff --git a/tools/vgchange.c b/tools/vgchange.c index af59f3a55..b66d13769 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -303,6 +303,7 @@ static int _vgchange_resizeable(struct cmd_context *cmd, static int _vgchange_clustered(struct cmd_context *cmd, struct volume_group *vg) { + struct lv_list *lvl; int clustered = arg_int_value(cmd, clustered_ARG, 0); if (clustered && (vg_is_clustered(vg))) { @@ -317,6 +318,17 @@ static int _vgchange_clustered(struct cmd_context *cmd, return 0; } + if (clustered) { + dm_list_iterate_items(lvl, &vg->lvs) { + if (!segtype_allowed_in_cluster_vg(first_seg(lvl->lv)->segtype)) { + log_error("LV %s segtype %s is not allowed in cluster VG.", + display_lvname(lvl->lv), + first_seg(lvl->lv)->segtype->name); + return 0; + } + } + } + if (clustered && !arg_count(cmd, yes_ARG)) { if (!clvmd_is_running()) { if (yes_no_prompt("LVM cluster daemon (clvmd) is not" |