summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2014-11-05 11:53:11 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2014-11-05 15:30:58 +0100
commit6e5790f2d24d798e217fc005522c07e06c97adc9 (patch)
treea360b2e5a36556103e7b350c17b0d5815eabafea
parenta3a2c792a87054ab78a1b8e54b99db1c24739fb8 (diff)
downloadlvm2-6e5790f2d24d798e217fc005522c07e06c97adc9.tar.gz
activate: check all snap segs are inactive
When deactivating origin, we may have possibly left table in broken state, where origin is not active, but snapshot volume is still present. Let's ensure deactivation of origin detects also all associated snapshots are inactive - otherwise do not skip deactivation. (so i.e. 'vgchange -an' would detect errors)
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/activate/activate.c15
2 files changed, 15 insertions, 1 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 03baa06d5..06d3b9bb7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Deactivation of snapshot origin detects and deactivates left-over snapshots.
Properly report error when taking snapshot of any cache type LV.
Add basic thread debugging messages to dmeventd.
Include threads being shutdown in dmeventd device registration responses.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c2a662f03..ac6330f94 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2002,6 +2002,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
const struct logical_volume *lv_to_free = NULL;
struct lvinfo info;
static const struct lv_activate_opts laopts = { .skip_in_use = 1 };
+ struct dm_list *snh;
int r = 0;
if (!activation())
@@ -2023,7 +2024,19 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
if (!info.exists) {
r = 1;
- goto out;
+ /* Check attached snapshot segments are also inactive */
+ dm_list_iterate(snh, &lv->snapshot_segs) {
+ if (!lv_info(cmd, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow,
+ 0, &info, 0, 0))
+ goto_out;
+ if (info.exists) {
+ r = 0; /* Snapshot left in table? */
+ break;
+ }
+ }
+
+ if (r)
+ goto out;
}
if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||