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

Fix last snapshot removal to avoid table reload while a device is suspended.

This commit is contained in:
Alasdair Kergon 2011-06-13 22:28:04 +00:00
parent 98a0fa72be
commit 7df72b3c88
3 changed files with 41 additions and 16 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.86 - Version 2.02.86 -
================================= =================================
Fix last snapshot removal to avoid table reload while a device is suspended.
Use dm_get_suspended_counter in replacement critical_section logic. Use dm_get_suspended_counter in replacement critical_section logic.
Downgrade critical_section errors to debug level until it is moved to libdm. Downgrade critical_section errors to debug level until it is moved to libdm.
Fix ignored background polling default in vgchange -ay. Fix ignored background polling default in vgchange -ay.

View File

@ -534,6 +534,8 @@ int lv_check_transient(struct logical_volume *lv)
if (!activation()) if (!activation())
return 0; return 0;
log_debug("Checking transient status for LV %s/%s", lv->vg->name, lv->name);
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
return_0; return_0;
@ -556,6 +558,8 @@ int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent)
if (!activation()) if (!activation())
return 0; return 0;
log_debug("Checking snapshot percent for LV %s/%s", lv->vg->name, lv->name);
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
return_0; return_0;
@ -585,6 +589,8 @@ int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
if (!activation()) if (!activation())
return 0; return 0;
log_debug("Checking mirror percent for LV %s/%s", lv->vg->name, lv->name);
if (!lv_info(cmd, lv, 0, &info, 0, 0)) if (!lv_info(cmd, lv, 0, &info, 0, 0))
return_0; return_0;
@ -692,7 +698,7 @@ static int _lv_suspend_lv(struct logical_volume *lv, unsigned origin_only, int l
/* /*
* These two functions return the number of visible LVs in the state, * These two functions return the number of visible LVs in the state,
* or -1 on error. * or -1 on error. FIXME Check this.
*/ */
int lvs_in_vg_activated(struct volume_group *vg) int lvs_in_vg_activated(struct volume_group *vg)
{ {
@ -702,10 +708,11 @@ int lvs_in_vg_activated(struct volume_group *vg)
if (!activation()) if (!activation())
return 0; return 0;
dm_list_iterate_items(lvl, &vg->lvs) { dm_list_iterate_items(lvl, &vg->lvs)
if (lv_is_visible(lvl->lv)) if (lv_is_visible(lvl->lv))
count += (_lv_active(vg->cmd, lvl->lv) == 1); count += (_lv_active(vg->cmd, lvl->lv) == 1);
}
log_debug("Counted %d active LVs in VG %s", count, vg->name);
return count; return count;
} }
@ -718,10 +725,11 @@ int lvs_in_vg_opened(const struct volume_group *vg)
if (!activation()) if (!activation())
return 0; return 0;
dm_list_iterate_items(lvl, &vg->lvs) { dm_list_iterate_items(lvl, &vg->lvs)
if (lv_is_visible(lvl->lv)) if (lv_is_visible(lvl->lv))
count += (_lv_open_count(vg->cmd, lvl->lv) > 0); count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
}
log_debug("Counted %d open LVs in VG %s", count, vg->name);
return count; return count;
} }
@ -822,12 +830,14 @@ int lv_is_active_locally(struct logical_volume *lv)
int lv_is_active_exclusive_locally(struct logical_volume *lv) int lv_is_active_exclusive_locally(struct logical_volume *lv)
{ {
int l, e; int l, e;
return _lv_is_active(lv, &l, &e) && l && e; return _lv_is_active(lv, &l, &e) && l && e;
} }
int lv_is_active_exclusive_remotely(struct logical_volume *lv) int lv_is_active_exclusive_remotely(struct logical_volume *lv)
{ {
int l, e; int l, e;
return _lv_is_active(lv, &l, &e) && !l && e; return _lv_is_active(lv, &l, &e) && !l && e;
} }
@ -1258,6 +1268,10 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
goto out; goto out;
} }
log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name,
error_if_not_active ? "" : " if active",
origin_only ? " without snapshots" : "");
if (!lv_info(cmd, lv, origin_only, &info, 0, 0)) if (!lv_info(cmd, lv, origin_only, &info, 0, 0))
goto_out; goto_out;
@ -1347,6 +1361,8 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
goto out; goto out;
} }
log_debug("Deactivating %s/%s.", lv->vg->name, lv->name);
if (!lv_info(cmd, lv, 0, &info, 1, 0)) if (!lv_info(cmd, lv, 0, &info, 1, 0))
goto_out; goto_out;
@ -1454,6 +1470,8 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
goto out; goto out;
} }
log_debug("Activating %s/%s%s.", lv->vg->name, lv->name, exclusive ? " exclusively" : "");
if (!lv_info(cmd, lv, 0, &info, 0, 0)) if (!lv_info(cmd, lv, 0, &info, 0, 0))
goto_out; goto_out;

View File

@ -2677,6 +2677,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
struct lvinfo info; struct lvinfo info;
struct logical_volume *origin = NULL; struct logical_volume *origin = NULL;
int was_merging = 0; int was_merging = 0;
int reload_required = 0;
vg = lv->vg; vg = lv->vg;
@ -2738,6 +2739,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0; return_0;
} }
/* FIXME Review and fix the snapshot error paths! */
if (!deactivate_lv(cmd, lv)) { if (!deactivate_lv(cmd, lv)) {
log_error("Unable to deactivate logical volume \"%s\"", log_error("Unable to deactivate logical volume \"%s\"",
lv->name); lv->name);
@ -2750,20 +2752,24 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0; return 0;
} }
/* If no snapshots left, and was not merging, reload without -real. */
if (origin && (!lv_is_origin(origin) && !was_merging))
reload_required = 1;
/* store it on disks */ /* store it on disks */
if (!vg_write(vg) || !vg_commit(vg)) if (!vg_write(vg))
return_0; return_0;
/* If no snapshots left, and was not merging, reload without -real. */ if (reload_required && !suspend_lv(cmd, origin))
if (origin && (!lv_is_origin(origin) && !was_merging)) { log_error("Failed to refresh %s without snapshot.", origin->name);
if (!suspend_lv(cmd, origin)) { /* FIXME Falls through because first part of change already in kernel! */
log_error("Failed to refresh %s without snapshot.", origin->name);
return 0; if (!vg_commit(vg))
} return_0;
if (!resume_lv(cmd, origin)) {
log_error("Failed to resume %s.", origin->name); if (reload_required && !resume_lv(cmd, origin)) {
return 0; log_error("Failed to resume %s.", origin->name);
} return 0;
} }
backup(vg); backup(vg);