summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-03-23 09:58:04 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2012-03-23 09:58:04 +0000
commit2caa558e7c57efa6c0d7cf4e38cee68445a6d7f6 (patch)
tree107900dd0aee55a103c6cb60ba628c8f6d913f35 /lib
parent5da4d94adc02df77976d1381bfea914fe2622850 (diff)
downloadlvm2-2caa558e7c57efa6c0d7cf4e38cee68445a6d7f6.tar.gz
lvm2-2caa558e7c57efa6c0d7cf4e38cee68445a6d7f6.tar.xz
lvm2-2caa558e7c57efa6c0d7cf4e38cee68445a6d7f6.zip
Update and fix monitoring of thin pool devices
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/activate/activate.c30
-rw-r--r--lib/activate/activate.h1
-rw-r--r--lib/metadata/thin_manip.c5
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index e6b40ba5..d2cc5bfb 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -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;
@@ -1236,6 +1238,19 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
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;
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index ccea9919..2b90a7b8 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -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;
};
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 0c00e7a6..ae8d509e 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -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.