1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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)
This commit is contained in:
Zdenek Kabelac 2014-11-05 11:53:11 +01:00
parent a3a2c792a8
commit 6e5790f2d2
2 changed files with 15 additions and 1 deletions

View File

@ -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.

View File

@ -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) ||