mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
metadata: move vg parsing to vg_write
Parsing vg structure during supend/commit/resume may require a lot of memory - so move this into vg_write. FIXME: there are now multiple cache layers which our doing some thing multiple times at different levels. Moreover there is now different caching path with and without lvmetad - this should be unified and both path should use same mechanism.
This commit is contained in:
parent
203affffc7
commit
8c878438f5
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.106 -
|
Version 2.02.106 -
|
||||||
====================================
|
====================================
|
||||||
|
Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99)
|
||||||
Avoid a PV label scan while in a critical section.
|
Avoid a PV label scan while in a critical section.
|
||||||
Remove (always 0) skip argument from lv_activation_skip().
|
Remove (always 0) skip argument from lv_activation_skip().
|
||||||
Create /dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for each PV via udev.
|
Create /dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for each PV via udev.
|
||||||
|
@ -856,30 +856,45 @@ int vgcreate_params_validate(struct cmd_context *cmd,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _vg_update_vg_ondisk(struct volume_group *vg)
|
/*
|
||||||
|
* Update content of precommitted VG
|
||||||
|
*
|
||||||
|
* TODO: Optimize in the future, since lvmetad needs similar
|
||||||
|
* config tree processing in lvmetad_vg_update().
|
||||||
|
*/
|
||||||
|
static int _vg_update_vg_precommitted(struct volume_group *vg)
|
||||||
{
|
{
|
||||||
struct dm_config_tree *cft;
|
struct dm_config_tree *cft;
|
||||||
int pool_locked;
|
|
||||||
|
release_vg(vg->vg_precommitted);
|
||||||
|
vg->vg_precommitted = NULL;
|
||||||
|
|
||||||
|
if (!(cft = export_vg_to_config_tree(vg)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
if (!(vg->vg_precommitted = import_vg_from_config_tree(cft, vg->fid)))
|
||||||
|
stack;
|
||||||
|
|
||||||
|
dm_config_destroy(cft);
|
||||||
|
|
||||||
|
return vg->vg_precommitted ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _vg_update_vg_ondisk(struct volume_group *vg)
|
||||||
|
{
|
||||||
|
if (dm_pool_locked(vg->vgmem))
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (vg->vg_ondisk || is_orphan_vg(vg->name)) /* we already have it */
|
if (vg->vg_ondisk || is_orphan_vg(vg->name)) /* we already have it */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
pool_locked = dm_pool_locked(vg->vgmem);
|
if (!_vg_update_vg_precommitted(vg))
|
||||||
if (pool_locked && !dm_pool_unlock(vg->vgmem, 0))
|
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
cft = export_vg_to_config_tree(vg);
|
vg->vg_ondisk = vg->vg_precommitted;
|
||||||
if (!cft)
|
vg->vg_precommitted = NULL;
|
||||||
return 0;
|
|
||||||
|
|
||||||
vg->vg_ondisk = import_vg_from_config_tree(cft, vg->fid);
|
return 1;
|
||||||
dm_config_destroy(cft);
|
|
||||||
|
|
||||||
/* recompute the pool crc */
|
|
||||||
if (pool_locked && !dm_pool_lock(vg->vgmem, 1))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
return vg->vg_ondisk ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2687,6 +2702,9 @@ int vg_write(struct volume_group *vg)
|
|||||||
if (!(vg->fid->fmt->features & FMT_PRECOMMIT) && !lvmetad_vg_update(vg))
|
if (!(vg->fid->fmt->features & FMT_PRECOMMIT) && !lvmetad_vg_update(vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
if (!_vg_update_vg_precommitted(vg)) /* prepare precommited */
|
||||||
|
return_0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2753,9 +2771,8 @@ int vg_commit(struct volume_group *vg)
|
|||||||
|
|
||||||
/* This *is* the original now that it's commited. */
|
/* This *is* the original now that it's commited. */
|
||||||
release_vg(vg->vg_ondisk);
|
release_vg(vg->vg_ondisk);
|
||||||
vg->vg_ondisk = NULL;
|
vg->vg_ondisk = vg->vg_precommitted;
|
||||||
if (!_vg_update_vg_ondisk(vg)) /* make a new one for future edits */
|
vg->vg_precommitted = NULL;
|
||||||
return_0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If update failed, remove any cached precommitted metadata. */
|
/* If update failed, remove any cached precommitted metadata. */
|
||||||
@ -2772,6 +2789,9 @@ void vg_revert(struct volume_group *vg)
|
|||||||
{
|
{
|
||||||
struct metadata_area *mda;
|
struct metadata_area *mda;
|
||||||
|
|
||||||
|
release_vg(vg->vg_precommitted); /* VG is no longer needed */
|
||||||
|
vg->vg_precommitted = NULL;
|
||||||
|
|
||||||
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
|
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
|
||||||
if (mda->ops->vg_revert &&
|
if (mda->ops->vg_revert &&
|
||||||
!mda->ops->vg_revert(vg->fid, vg, mda)) {
|
!mda->ops->vg_revert(vg->fid, vg, mda)) {
|
||||||
|
@ -89,6 +89,7 @@ void release_vg(struct volume_group *vg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
release_vg(vg->vg_ondisk);
|
release_vg(vg->vg_ondisk);
|
||||||
|
release_vg(vg->vg_precommitted);
|
||||||
_free_vg(vg);
|
_free_vg(vg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ struct volume_group {
|
|||||||
* _vg_update_vg_ondisk.
|
* _vg_update_vg_ondisk.
|
||||||
*/
|
*/
|
||||||
struct volume_group *vg_ondisk;
|
struct volume_group *vg_ondisk;
|
||||||
|
struct volume_group *vg_precommitted; /* Parsed from precommitted */
|
||||||
|
|
||||||
alloc_policy_t alloc;
|
alloc_policy_t alloc;
|
||||||
struct profile *profile;
|
struct profile *profile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user