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

Don't attempt to deactivate an LV if any of its snapshots are in use.

This commit is contained in:
Alasdair Kergon 2009-09-29 18:50:28 +00:00
parent 89a6cdfd4c
commit 64a950108c
2 changed files with 32 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.54 -
=====================================
Don't attempt to deactivate an LV if any of its snapshots are in use.
Return fail if lv_deactivate fails to remove device from kernel.
Provide alternative implementation of obsolete siginterrupt().
Consolidate LV allocation into alloc_lv().

View File

@ -975,6 +975,29 @@ int lv_resume(struct cmd_context *cmd, const char *lvid_s)
return _lv_resume(cmd, lvid_s, 1);
}
static int _lv_has_open_snapshots(struct logical_volume *lv)
{
struct lv_segment *snap_seg;
struct lvinfo info;
int r = 0;
dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) {
if (!lv_info(lv->vg->cmd, snap_seg->cow, &info, 1, 0)) {
r = 1;
continue;
}
if (info.exists && info.open_count) {
log_error("LV %s/%s has open snapshot %s: "
"not deactivating", lv->vg->name, lv->name,
snap_seg->cow->name);
r = 1;
}
}
return r;
}
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
{
struct logical_volume *lv;
@ -1001,10 +1024,14 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
goto out;
}
if (info.open_count && lv_is_visible(lv)) {
log_error("LV %s/%s in use: not deactivating", lv->vg->name,
lv->name);
goto out;
if (lv_is_visible(lv)) {
if (info.open_count) {
log_error("LV %s/%s in use: not deactivating",
lv->vg->name, lv->name);
goto out;
}
if (lv_is_origin(lv) && _lv_has_open_snapshots(lv))
goto_out;
}
lv_calculate_readahead(lv, NULL);