mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
vg_read: reuse already parsed config tree
When parsing VG metadata we can create from a single config tree also 'vg_committed' that is always created for writable VG. This avoids extra uncessary step of serializing and deserilizing just parsed VG.
This commit is contained in:
parent
bc0cb66304
commit
936c7b5104
@ -186,6 +186,8 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
|||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
|
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
|
||||||
|
vg->committed_cft = cft; /* Reuse CFT for recreation of committed VG */
|
||||||
|
cft = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +200,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
|||||||
*use_previous_vg = 0;
|
*use_previous_vg = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (cft)
|
||||||
config_destroy(cft);
|
config_destroy(cft);
|
||||||
return vg;
|
return vg;
|
||||||
}
|
}
|
||||||
|
@ -5186,8 +5186,6 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
|
|||||||
* FIXME: be specific about exactly when this works correctly.
|
* FIXME: be specific about exactly when this works correctly.
|
||||||
*/
|
*/
|
||||||
if (writing) {
|
if (writing) {
|
||||||
struct dm_config_tree *cft;
|
|
||||||
|
|
||||||
if (dm_pool_locked(vg->vgmem)) {
|
if (dm_pool_locked(vg->vgmem)) {
|
||||||
/* FIXME: can this happen? */
|
/* FIXME: can this happen? */
|
||||||
log_warn("WARNING: vg_read no vg copy: pool locked.");
|
log_warn("WARNING: vg_read no vg copy: pool locked.");
|
||||||
@ -5208,15 +5206,15 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
|
|||||||
vg->vg_precommitted = NULL;
|
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.");
|
log_warn("WARNING: vg_read no vg copy: copy export failed.");
|
||||||
|
if (!(vg->committed_cft = export_vg_to_config_tree(vg)))
|
||||||
goto out;
|
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.");
|
log_warn("WARNING: vg_read no vg copy: copy import failed.");
|
||||||
|
|
||||||
dm_config_destroy(cft);
|
|
||||||
} else {
|
} else {
|
||||||
if (vg->vg_precommitted)
|
if (vg->vg_precommitted)
|
||||||
log_error(INTERNAL_ERROR "vg_read vg %p vg_precommitted %p", (void *)vg, (void *)vg->vg_precommitted);
|
log_error(INTERNAL_ERROR "vg_read vg %p vg_precommitted %p", (void *)vg, (void *)vg->vg_precommitted);
|
||||||
|
@ -79,6 +79,8 @@ static void _free_vg(struct volume_group *vg)
|
|||||||
|
|
||||||
log_debug_mem("Freeing VG %s at %p.", vg->name ? : "<no name>", (void *)vg);
|
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_hash_destroy(vg->hostnames);
|
||||||
dm_pool_destroy(vg->vgmem);
|
dm_pool_destroy(vg->vgmem);
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ struct volume_group {
|
|||||||
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
|
* 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,
|
* 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
|
* 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
|
* this will be NULL). The pointer is maintained by calls to vg_write & vg_commit
|
||||||
* _vg_update_vg_committed.
|
|
||||||
*/
|
*/
|
||||||
|
struct dm_config_tree *committed_cft;
|
||||||
struct volume_group *vg_committed;
|
struct volume_group *vg_committed;
|
||||||
struct volume_group *vg_precommitted;
|
struct volume_group *vg_precommitted;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user