]> sourceware.org Git - lvm2.git/commitdiff
Update and fix monitoring of thin pool devices
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 23 Mar 2012 09:58:04 +0000 (09:58 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 23 Mar 2012 09:58:04 +0000 (09:58 +0000)
Code adds better support for monitoring of thin pool devices.
update_pool_lv uses DMEVENTD_MONITOR_IGNORE to not manipulate with monitoring.
vgchange & lvchange are checking real thin pool device for existance
as we are using   _tpool  real device and visible LV pool device might not
be even active (_tpool is activated implicitely for any thin volume).
monitor_dev_for_events is another _lv_postorder like code it might be worth
to think about reusing it here - for now update the code to properly
monitory thin volume deps.
For unmonitoring add extra code to check the usage of thin pool - in case it's in use
unmonitoring of thin volume is skipped.

WHATS_NEW
lib/activate/activate.c
lib/activate/activate.h
lib/metadata/thin_manip.c
tools/lvchange.c
tools/vgchange.c

index f0c834df60d4334adedc4910de1cc0a215ad2b29..fc9c4786ea0969da10463791da1ce90b0a86fd73 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Update and fix monitoring of thin pool devices.
   Check hash insert success in lock_vg clvmd.
   Check for buffer overwrite in get_cluster_type() clvmd.
   Fix global/detect_internal_vg_cache_corruption config check.
index e6b40ba5749abb255d7ec3abe87c590e3b49c1f4..d2cc5bfb9ecc32dcd1da76502567c95133d6ad4f 100644 (file)
@@ -1221,6 +1221,8 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
        int (*monitor_fn) (struct lv_segment *s, int e);
        uint32_t s;
        static const struct lv_activate_opts zlaopts = { 0 };
+       static const struct lv_activate_opts thinopts = { .skip_in_use = 1 };
+       struct lvinfo info;
 
        if (!laopts)
                laopts = &zlaopts;
@@ -1235,6 +1237,19 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
        if (monitor && !dmeventd_monitor_mode())
                return 1;
 
+       /*
+        * Allow to unmonitor thin pool via explicit pool unmonitor
+        * or unmonitor before the last thin pool user deactivation
+        * Skip unmonitor, if invoked via unmonitor of thin volume
+        * and there is another thin pool user (open_count > 1)
+        */
+       if (laopts->skip_in_use && lv_info(lv->vg->cmd, lv, 1, &info, 1, 0) &&
+           (info.open_count != 1)) {
+               log_debug("Skipping unmonitor of opened %s (open:%d)",
+                         lv->name, info.open_count);
+               return 1;
+       }
+
        /*
         * In case of a snapshot device, we monitor lv->snapshot->lv,
         * not the actual LV itself.
@@ -1279,6 +1294,21 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
                        }
                }
 
+               /*
+                * If requested unmonitoring of thin volume, request test
+                * if there is no other thin pool user
+                *
+                * FIXME: code here looks like _lv_postorder()
+                */
+               if (seg->pool_lv &&
+                   !monitor_dev_for_events(cmd, seg->pool_lv,
+                                           (!monitor) ? &thinopts : NULL, monitor))
+                       r = 0;
+
+               if (seg->metadata_lv &&
+                   !monitor_dev_for_events(cmd, seg->metadata_lv, NULL, monitor))
+                       r = 0;
+
                if (!seg_monitored(seg) || (seg->status & PVMOVE))
                        continue;
 
index ccea991916a7cfb0c87cb064a40a408e81394ff8..2b90a7b8a9c3e7486e3aad5869c56c0d7ff37222 100644 (file)
@@ -36,6 +36,7 @@ struct lv_activate_opts {
        int no_merging;
        int real_pool;
        int is_activate;
+       int skip_in_use;
        unsigned revert;
        unsigned read_only;
 };
index 0c00e7a6a2d364b7a10ef00df5c001a34a65c6eb..ae8d509ecb341190c8b0088e4d6fda9a9e91be23 100644 (file)
@@ -388,6 +388,8 @@ int extend_pool(struct logical_volume *pool_lv, const struct segment_type *segty
 
 int update_pool_lv(struct logical_volume *lv, int activate)
 {
+       int monitored;
+
        if (!lv_is_thin_pool(lv)) {
                log_error(INTERNAL_ERROR "Updated LV %s is not pool.", lv->name);
                return 0;
@@ -399,10 +401,13 @@ int update_pool_lv(struct logical_volume *lv, int activate)
        if (activate) {
                /* If the pool is not active, do activate deactivate */
                if (!lv_is_active(lv)) {
+                       monitored = dmeventd_monitor_mode();
+                       init_dmeventd_monitor(DMEVENTD_MONITOR_IGNORE);
                        if (!activate_lv_excl(lv->vg->cmd, lv))
                                return_0;
                        if (!deactivate_lv(lv->vg->cmd, lv))
                                return_0;
+                       init_dmeventd_monitor(monitored);
                }
                /*
                 * Resume active pool to send thin messages.
index 55799c66d2ba0f40be84ab968917b79fdcbeb049..2ed8c16c5455e9f36dc8f22086d506cb69110cb6 100644 (file)
@@ -94,7 +94,8 @@ static int lvchange_monitoring(struct cmd_context *cmd,
 {
        struct lvinfo info;
 
-       if (!lv_info(cmd, lv, 0, &info, 0, 0) || !info.exists) {
+       if (!lv_info(cmd, lv, lv_is_thin_pool(lv) ? 1 : 0,
+                    &info, 0, 0) || !info.exists) {
                log_error("Logical volume, %s, is not active", lv->name);
                return 0;
        }
index d8a8eee9c546b919d6951c40b50d8e9a2d1c04d7..dc06ac9f22f77c56163a3102f459a087435fa765 100644 (file)
@@ -24,21 +24,19 @@ static int _monitor_lvs_in_vg(struct cmd_context *cmd,
        struct lv_list *lvl;
        struct logical_volume *lv;
        struct lvinfo info;
-       int lv_active;
        int r = 1;
 
        dm_list_iterate_items(lvl, &vg->lvs) {
                lv = lvl->lv;
 
-               if (!lv_info(cmd, lv, 0, &info, 0, 0))
-                       lv_active = 0;
-               else
-                       lv_active = info.exists;
-
+               if (!lv_info(cmd, lv, lv_is_thin_pool(lv) ? 1 : 0,
+                            &info, 0, 0) ||
+                   !info.exists)
+                       continue;
                /*
                 * FIXME: Need to consider all cases... PVMOVE, etc
                 */
-               if ((lv->status & PVMOVE) || !lv_active)
+               if (lv->status & PVMOVE)
                        continue;
 
                if (!monitor_dev_for_events(cmd, lv, 0, reg)) {
This page took 0.045286 seconds and 5 git commands to generate.