]> sourceware.org Git - lvm2.git/commitdiff
Disallow toggling the cluster attribute of a volume group if there
authorJonathan Earl Brassow <jbrassow@redhat.com>
Fri, 14 May 2010 15:19:42 +0000 (15:19 +0000)
committerJonathan Earl Brassow <jbrassow@redhat.com>
Fri, 14 May 2010 15:19:42 +0000 (15:19 +0000)
are active mirrors or snapshots.

We don't have the mechanisms in place to change the device-mapper
tables for those targets that have behavioral differences between
cluster and single machine instances.  Allowing users to change
the attribute but not changing the target's behavior can lead to
data corruption.

The following bugs are fixed/avoided by this patch:
235123 - vgchange -c [ny] do not change target types when necessary
289331 - RFE: switching from cluster domain to local domain needs to deactivate volume somehow
289541 - when changing from local to cluster, volumes can not appear to be deactivated

WHATS_NEW
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
lib/metadata/mirror.c

index 771a3f6f0e60f2cc116d1ffabe765a358f395920..f584ca6fd8bd783319fe8b749cf9b7abf9405eb8 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.65 - 
 =================================
+  Disallow cluster attr toggling if there are active mirrors or snapshots.
   Use /bin/bash for scripts with bashisms.
   Skip internal lvm devices in scan if ignore suspended devices is requested.
   Do not merge old device cache after we run full scan. (2.02.56)
index 3c5f8a36ac0099f202b3beb487725719a359c70d..fe3266a88dcd571d75225070b7d9459b609b9909 100644 (file)
@@ -691,6 +691,7 @@ int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
 
 int is_temporary_mirror_layer(const struct logical_volume *lv);
 struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
+int lv_is_mirrored(const struct logical_volume *lv);
 uint32_t lv_mirror_count(const struct logical_volume *lv);
 uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
                                     uint32_t region_size);
index 16d80a2e44dddab18dbb778771bc9a9007b23c17..12cb5e41f24156e85274fb3bff40e03f4597d484 100644 (file)
@@ -1208,8 +1208,19 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
 int vg_set_clustered(struct volume_group *vg, int clustered)
 {
        struct lv_list *lvl;
-       if (clustered) {
-               dm_list_iterate_items(lvl, &vg->lvs) {
+
+       /*
+        * We do not currently support switching the cluster attribute
+        * on active mirrors or snapshots.
+        */
+       dm_list_iterate_items(lvl, &vg->lvs) {
+               if (lv_is_mirrored(lvl->lv) && lv_is_active(lvl->lv)) {
+                       log_error("Mirror logical volumes must be inactive "
+                                 "when changing the cluster attribute.");
+                       return 0;
+               }
+
+               if (clustered) {
                        if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
                                log_error("Volume group %s contains snapshots "
                                          "that are not yet supported.",
@@ -1217,6 +1228,13 @@ int vg_set_clustered(struct volume_group *vg, int clustered)
                                return 0;
                        }
                }
+
+               if ((lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) &&
+                   lv_is_active(lvl->lv)) {
+                       log_error("Snapshot logical volumes must be inactive "
+                                 "when changing the cluster attribute.");
+                       return 0;
+               }
        }
 
        if (clustered)
index 757c095da4bc141705efda5e3bbc65c3a70a7852..7ea26d5f0abff0d648c043d0da2c491ddee74854 100644 (file)
@@ -72,6 +72,14 @@ struct logical_volume *find_temporary_mirror(const struct logical_volume *lv)
        return NULL;
 }
 
+int lv_is_mirrored(const struct logical_volume *lv)
+{
+       if (lv->status & MIRRORED)
+               return 1;
+
+       return 0;
+}
+
 /*
  * Returns the number of mirrors of the LV
  */
This page took 0.049081 seconds and 5 git commands to generate.