goto_out;
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
+ vg->committed_cft = cft; /* Reuse CFT for recreation of committed VG */
+ cft = NULL;
break;
}
*use_previous_vg = 0;
out:
- config_destroy(cft);
+ if (cft)
+ config_destroy(cft);
return vg;
}
* FIXME: be specific about exactly when this works correctly.
*/
if (writing) {
- struct dm_config_tree *cft;
-
if (dm_pool_locked(vg->vgmem)) {
/* FIXME: can this happen? */
log_warn("WARNING: vg_read no vg copy: pool locked.");
vg->vg_precommitted = NULL;
}
- if (!(cft = export_vg_to_config_tree(vg))) {
+ if (!vg->committed_cft) {
log_warn("WARNING: vg_read no vg copy: copy export failed.");
- goto out;
+ if (!(vg->committed_cft = export_vg_to_config_tree(vg)))
+ goto out;
}
- if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, cft)))
+ if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, vg->committed_cft)))
log_warn("WARNING: vg_read no vg copy: copy import failed.");
- dm_config_destroy(cft);
} else {
if (vg->vg_precommitted)
log_error(INTERNAL_ERROR "vg_read vg %p vg_precommitted %p", (void *)vg, (void *)vg->vg_precommitted);
log_debug_mem("Freeing VG %s at %p.", vg->name ? : "<no name>", (void *)vg);
+ if (vg->committed_cft)
+ config_destroy(vg->committed_cft);
dm_hash_destroy(vg->hostnames);
dm_pool_destroy(vg->vgmem);
}
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
* version (i.e. vg_committed == NULL *implies* this is the committed copy,
* there is no guarantee that if this VG is the same as the committed one
- * this will be NULL). The pointer is maintained by calls to
- * _vg_update_vg_committed.
+ * this will be NULL). The pointer is maintained by calls to vg_write & vg_commit
*/
+ struct dm_config_tree *committed_cft;
struct volume_group *vg_committed;
struct volume_group *vg_precommitted;