mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
metadata: vg: add removed_lvs field to collect LVs which have been removed
Do not keep dangling LVs if they're removed from the vg->lvs list and move them to vg->removed_lvs instead (this is actually similar to already existing vg->removed_pvs list, just it's for LVs now). Once we have this vg->removed_lvs list indexed so it's possible to do lookups for LVs quickly, we can remove the LV_REMOVED flag as that one won't be needed anymore - instead of checking the flag, we can directly check the vg->removed_lvs list if the LV is present there or not and to say if the LV is removed or not then. For now, we don't have this index, but it may be implemented in the future.
This commit is contained in:
parent
c9f021de0b
commit
8759f7d755
@ -5350,7 +5350,7 @@ int unlink_lv_from_vg(struct logical_volume *lv)
|
||||
if (!(lvl = find_lv_in_vg(lv->vg, lv->name)))
|
||||
return_0;
|
||||
|
||||
dm_list_del(&lvl->list);
|
||||
dm_list_move(&lv->vg->removed_lvs, &lvl->list);
|
||||
lv->status |= LV_REMOVED;
|
||||
|
||||
return 1;
|
||||
|
@ -125,6 +125,8 @@
|
||||
be referenced on internal lists of LVs.
|
||||
Any remaining references should check for
|
||||
this flag and ignore the LV is set.
|
||||
FIXME: Remove this flag once we have indexed
|
||||
vg->removed_lvs for quick lookup.
|
||||
*/
|
||||
#define LV_ERROR_WHEN_FULL UINT64_C(0x0008000000000000) /* LV - error when full */
|
||||
#define PV_ALLOCATION_PROHIBITED UINT64_C(0x0010000000000000) /* PV - internal use only - allocation prohibited
|
||||
|
@ -2568,12 +2568,26 @@ int vg_validate(struct volume_group *vg)
|
||||
r = 0;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->removed_lvs) {
|
||||
if (!(lvl->lv->status & LV_REMOVED)) {
|
||||
log_error(INTERNAL_ERROR "LV %s is not marked as removed while it's part "
|
||||
"of removed LV list for VG %s", lvl->lv->name, vg->name);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Count all non-snapshot invisible LVs
|
||||
*/
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
lv_count++;
|
||||
|
||||
if (lvl->lv->status & LV_REMOVED) {
|
||||
log_error(INTERNAL_ERROR "LV %s is marked as removed while it's "
|
||||
"still part of the VG %s", lvl->lv->name, vg->name);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
if (lvl->lv->status & LVM_WRITE_LOCKED) {
|
||||
log_error(INTERNAL_ERROR "LV %s has external flag LVM_WRITE_LOCKED set internally.",
|
||||
lvl->lv->name);
|
||||
|
@ -63,6 +63,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
|
||||
dm_list_init(&vg->pvs_to_create);
|
||||
dm_list_init(&vg->lvs);
|
||||
dm_list_init(&vg->tags);
|
||||
dm_list_init(&vg->removed_lvs);
|
||||
dm_list_init(&vg->removed_pvs);
|
||||
|
||||
log_debug_mem("Allocated VG %s at %p.", vg->name, vg);
|
||||
|
@ -112,6 +112,11 @@ struct volume_group {
|
||||
* FIXME: Move the next fields into a different struct?
|
||||
*/
|
||||
|
||||
/*
|
||||
* List of removed logical volumes by _lv_reduce.
|
||||
*/
|
||||
struct dm_list removed_lvs;
|
||||
|
||||
/*
|
||||
* List of removed physical volumes by pvreduce.
|
||||
* They have to get cleared on vg_commit.
|
||||
|
@ -2061,6 +2061,11 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
}
|
||||
|
||||
dm_list_iterate_items(lvl, &final_lvs) {
|
||||
/*
|
||||
* FIXME: Once we have index over vg->removed_lvs, check directly
|
||||
* LV presence there and remove LV_REMOVE flag/lv_is_removed fn
|
||||
* as they won't be needed anymore.
|
||||
*/
|
||||
if (lv_is_removed(lvl->lv))
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user