diff --git a/lib/format_text/export.c b/lib/format_text/export.c index 6ece94042..fbb8fb1ee 100644 --- a/lib/format_text/export.c +++ b/lib/format_text/export.c @@ -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(); diff --git a/lib/format_text/import.c b/lib/format_text/import.c index 2687d172e..e4e526354 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -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; } diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h index 8ce57acdc..96ab6a0b2 100644 --- a/lib/metadata/vg.h +++ b/lib/metadata/vg.h @@ -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