1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-02 13:47:42 +03:00

Cache config_tree

Start to use config_tree for cache just like vgmetadata.
When vgmetadata are erased destroy its cached config tree.
This commit is contained in:
Zdenek Kabelac 2011-01-10 13:15:57 +00:00
parent 7cbf6fa3a6
commit 40fbdb71bd
3 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.80 -
====================================
Speedup command processing by caching resolved config tree.
Pass config_tree to renamed function import_vg_from_config_tree().
Detect NULL handle in get_property().
Fix superfluous /usr in ocf_scriptdir instalation path.

12
lib/cache/lvmcache.c vendored
View File

@ -83,6 +83,12 @@ static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo)
vginfo->vgmetadata = NULL;
/* Release also cached config tree */
if (vginfo->cft) {
destroy_config_tree(vginfo->cft);
vginfo->cft = NULL;
}
log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
}
@ -651,7 +657,9 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
vgid, NULL)))
return_NULL;
if (!(vginfo->cft =
/* Build config tree from vgmetadata, if not yet cached */
if (!vginfo->cft &&
!(vginfo->cft =
create_config_tree_from_string(fid->fmt->cmd,
vginfo->vgmetadata))) {
_free_cached_vgmetadata(vginfo);
@ -660,10 +668,8 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
if (!(vg = import_vg_from_config_tree(vginfo->cft, fid))) {
_free_cached_vgmetadata(vginfo);
destroy_config_tree(vginfo->cft);
return_NULL;
}
destroy_config_tree(vginfo->cft);
log_debug("Using cached %smetadata for VG %s.",
vginfo->precommitted ? "pre-committed" : "", vginfo->vgname);

View File

@ -48,6 +48,7 @@ struct lvmcache_vginfo {
char *creation_host;
char *vgmetadata; /* Copy of VG metadata as format_text string */
struct config_tree *cft; /* Config tree created from vgmetadata */
/* Lifetime is directly tied to vgmetadata */
unsigned precommitted; /* Is vgmetadata live or precommitted? */
};