]> sourceware.org Git - lvm2.git/commitdiff
Thin pool activation change
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 28 Oct 2011 20:28:00 +0000 (20:28 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 28 Oct 2011 20:28:00 +0000 (20:28 +0000)
To ensure we properly handle LV cluster locking - explicitely do
not allow to change the availability of the thin pool that is in use
for some thin LV.

As soon as the thin volume is created the only way to activate pool
is via implicit dependency.

Ignore thinpool open count for lv/vgchange operations.

lib/activate/activate.c
lib/metadata/lv_manip.c
lib/metadata/metadata-exported.h
tools/lvchange.c
tools/toollib.c
tools/vgchange.c

index 2b44b19264d4d59599234e75b271a95d7159f5f4..a96e78113f4ea2e6559e4d34e1af1e06b237e7a9 100644 (file)
@@ -782,7 +782,7 @@ int lvs_in_vg_opened(const struct volume_group *vg)
                return 0;
 
        dm_list_iterate_items(lvl, &vg->lvs)
-               if (lv_is_visible(lvl->lv))
+               if (lv_is_visible(lvl->lv) && !lv_is_used_thin_pool(lvl->lv))
                        count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
 
        log_debug("Counted %d open LVs in VG %s", count, vg->name);
index 1ea874d6b8727cd07dfda8ef8837216b6b4a8b7e..8667cfd47a4906c4bb48cf8adc035000ddf6d32a 100644 (file)
@@ -3210,7 +3210,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
                }
        }
 
-       if (lv_is_thin_pool(lv) && dm_list_size(&lv->segs_using_this_lv)) {
+       if (lv_is_used_thin_pool(lv)) {
                /* remove thin LVs first */
                if ((force == PROMPT) &&
                    yes_no_prompt("Do you really want to remove all thin volumes when removing"
@@ -4139,23 +4139,26 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
        } else if (seg_is_thin_volume(lp)) {
                pool_lv = first_seg(lv)->pool_lv;
 
+               /* Ensure unused thin pool is not active */
+               if (!lv_is_used_thin_pool(pool_lv) &&
+                   !deactivate_lv(cmd, pool_lv)) {
+                       log_error("Failed to deactivate unused pool %s.",
+                                 pool_lv->name);
+                       return NULL;
+               }
+
+               /*
+                * From now the thin pool de/activation is made
+                * only via implicit thin volume dependency.
+                */
+
                if (!(first_seg(lv)->device_id =
                      get_free_pool_device_id(first_seg(pool_lv))))
                        return_NULL;
 
-               if (!activate_lv(pool_lv->vg->cmd, pool_lv)) {
-                       log_error("Failed to activate %s/%s to send message.",
-                                 pool_lv->vg->name, pool_lv->name);
-                       return NULL;
-               }
-
                if (!attach_pool_message(first_seg(pool_lv),
                                         DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
                        return_NULL;
-               /*
-                * FIXME: Skipping deactivate_lv(pool_lv) as it is going to be needed anyway
-                * but revert_new_lv should revert to deactivated state.
-                */
        }
 
        if (lp->log_count &&
index 734cd061dc7596f2ab42158dc2b352d694d82891..38ea0312ea4df85fc9870cb649bde9963a249c3e 100644 (file)
 
 #define lv_is_thin_volume(lv)  ((lv)->status & THIN_VOLUME ? 1 : 0)
 #define lv_is_thin_pool(lv)    ((lv)->status & THIN_POOL ? 1 : 0)
+#define lv_is_used_thin_pool(lv)       (lv_is_thin_pool(lv) && !dm_list_empty(&(lv)->segs_using_this_lv))
 #define lv_is_thin_pool_data(lv)       ((lv)->status & THIN_POOL_DATA ? 1 : 0)
 #define lv_is_thin_pool_metadata(lv)   ((lv)->status & THIN_POOL_METADATA ? 1 : 0)
 #define lv_is_mirrored(lv)     ((lv)->status & MIRRORED ? 1 : 0)
index 1a5cce6b47d966a50378e0966527850bd7f1af30..09377ab18db4db0332e785457367b832548b367b 100644 (file)
@@ -532,6 +532,12 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
                return ECMD_FAILED;
        }
 
+       if (lv_is_used_thin_pool(lv) &&
+           (arg_count(cmd, available_ARG))) {
+               log_error("Can't change pool volume \"%s\".", lv->name);
+               return ECMD_FAILED;
+       }
+
        if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)) &&
            arg_count(cmd, available_ARG)) {
                log_error("Can't change snapshot logical volume \"%s\"",
index aba52dc2dc5e9a1de07da83cdf747f6677e98153..219674736c0c24fc8ef664a02181d7dcc9f4a883 100644 (file)
@@ -126,6 +126,11 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
                if (lv_is_virtual_origin(lvl->lv) && !arg_count(cmd, all_ARG))
                        continue;
 
+               /* Only unused thin pool can change its availability */
+               if (!lvargs_supplied && lv_is_used_thin_pool(lvl->lv) &&
+                   arg_count(cmd, available_ARG))
+                       continue;
+
                /*
                 * Only let hidden LVs through it --all was used or the LVs 
                 * were specifically named on the command line.
index fd4e42084ba415b275014c1e2829fdec99ebf5c1..8cb0e230fd114f096a33edea90819ce62165c070 100644 (file)
@@ -100,6 +100,10 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
                if (!lv_is_visible(lv))
                        continue;
 
+               /* Never manipulate with thin pools in use */
+               if (lv_is_used_thin_pool(lv))
+                       continue;
+
                /* If LV is sparse, activate origin instead */
                if (lv_is_cow(lv) && lv_is_virtual_origin(origin_from_cow(lv)))
                        lv = origin_from_cow(lv);
This page took 0.044959 seconds and 5 git commands to generate.