summaryrefslogtreecommitdiffstats
path: root/lib/cache/lvmcache.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2011-03-11 15:08:31 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2011-03-11 15:08:31 +0000
commite8d4946ec784e38454ed25eeff7846b7524414d4 (patch)
tree671e3f6c26200700074b1dbafc532d16bb06ebe7 /lib/cache/lvmcache.c
parent2feb2a66fddc205363ea87224580c12c1a58cf59 (diff)
downloadlvm2-e8d4946ec784e38454ed25eeff7846b7524414d4.tar.gz
lvm2-e8d4946ec784e38454ed25eeff7846b7524414d4.tar.xz
lvm2-e8d4946ec784e38454ed25eeff7846b7524414d4.zip
Various cleanups for fid mem and ref_count changes.
Missing free_vg on error_path in lvmcache_get_vg fn. Call destroy_instance only if the fid is not part of the vg in backup_read_vg fn (otherwise it's part of the VG we're returning and we definitely don't want to destroy it!).
Diffstat (limited to 'lib/cache/lvmcache.c')
-rw-r--r--lib/cache/lvmcache.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 523b1961..ff397215 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -627,7 +627,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
{
struct lvmcache_vginfo *vginfo;
- struct volume_group *vg;
+ struct volume_group *vg = NULL;
struct format_instance *fid;
struct format_instance_ctx fic;
@@ -663,20 +663,21 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
if (!vginfo->cft &&
!(vginfo->cft =
create_config_tree_from_string(fid->fmt->cmd,
- vginfo->vgmetadata))) {
- _free_cached_vgmetadata(vginfo);
- return_NULL;
- }
+ vginfo->vgmetadata)))
+ goto_bad;
- if (!(vg = import_vg_from_config_tree(vginfo->cft, fid))) {
- _free_cached_vgmetadata(vginfo);
- return_NULL;
- }
+ if (!(vg = import_vg_from_config_tree(vginfo->cft, fid)))
+ goto_bad;
log_debug("Using cached %smetadata for VG %s.",
vginfo->precommitted ? "pre-committed" : "", vginfo->vgname);
return vg;
+
+bad:
+ free_vg(vg);
+ _free_cached_vgmetadata(vginfo);
+ return NULL;
}
struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,