]> sourceware.org Git - lvm2.git/commitdiff
Cache config_tree
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 10 Jan 2011 13:15:57 +0000 (13:15 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 10 Jan 2011 13:15:57 +0000 (13:15 +0000)
Start to use config_tree for cache just like vgmetadata.
When vgmetadata are erased destroy its cached config tree.

WHATS_NEW
lib/cache/lvmcache.c
lib/cache/lvmcache.h

index 2672e039f0666efc9c84ee11da7c6596c2aa182a..68a708a2158dc4613156b1728f0af9aa7903e3a9 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
index ebd6d44444907fab59477044ad1aeab9cb4e8374..0e9cae19471093af2b6844f67fabd128f0d25850 100644 (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);
index 8c07a26f49d50de92591260d7a7b4e430e4cd816..080f3b5ee33072986c2fe0bd08dc72da9b96575b 100644 (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? */
 };
 
This page took 0.041984 seconds and 5 git commands to generate.