mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
metadata: remember parsing size of VG metadata
When creating lvm2 metadata for VG, lvm2 allocate some buffer, and if buffer is not big enough, the buffer is 'reallocated' bigger, and whole metadata creation is repeated until metadata fits. We can try to use 'previous' metadata size as hint to reduce looping here.
This commit is contained in:
parent
a42ea349f6
commit
24e90f9594
@ -1071,7 +1071,7 @@ size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf,
|
||||
.header = 0,
|
||||
.out_with_comment = &_out_with_comment_raw,
|
||||
.nl = &_nl_raw,
|
||||
.data.buf.size = 65536, /* Initial metadata limit */
|
||||
.data.buf.size = vg->buffer_size_hint + 16384, /* Initial metadata limit */
|
||||
};
|
||||
|
||||
_init();
|
||||
|
@ -187,6 +187,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
|
||||
|
||||
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
|
||||
vg->committed_cft = cft; /* Reuse CFT for recreation of committed VG */
|
||||
vg->buffer_size_hint = size + size2;
|
||||
cft = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ struct volume_group {
|
||||
unsigned needs_backup : 1;
|
||||
unsigned needs_write_and_commit : 1;
|
||||
uint32_t write_count; /* count the number of vg_write calls */
|
||||
uint32_t buffer_size_hint; /* hint with buffer size of parsed VG */
|
||||
|
||||
/*
|
||||
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
|
||||
|
Loading…
Reference in New Issue
Block a user