1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

More work towards pv->size always holding the same value in internal metadata.

Store it in external text metadata as dev_size, and estimate it if not
present when metadata is read back in.
This commit is contained in:
Alasdair Kergon 2006-10-07 23:17:17 +00:00
parent 5faf02761f
commit ab507e894c
3 changed files with 18 additions and 2 deletions

View File

@ -409,6 +409,11 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
outf(f, "tags = %s", buffer);
}
if (!out_size(f, pv->size, "dev_size = %" PRIu64, pv->size)) {
stack;
return 0;
}
outf(f, "pe_start = %" PRIu64, pv->pe_start);
if (!out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
"pe_count = %u", pv->pe_count)) {

View File

@ -1465,8 +1465,16 @@ static int _text_pv_setup(const struct format_type *fmt,
}
}
/* FIXME Cope with genuine pe_count 0 */
/* If missing, estimate pv->size from file-based metadata */
if (!pv->size && pv->pe_count)
pv->size = pv->pe_count * (uint64_t) vg->extent_size +
pv->pe_start + mda_size2;
/* Recalculate number of extents that will fit */
pv->pe_count = (pv->size - pv->pe_start - mda_size2) / vg->extent_size;
if (!pv->pe_count)
pv->pe_count = (pv->size - pv->pe_start - mda_size2) / vg->extent_size;
/* Unlike LVM1, we don't store this outside a VG */
/* FIXME Default from config file? vgextend cmdline flag? */

View File

@ -179,6 +179,9 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
return 0;
}
/* Late addition */
_read_int64(pvn, "dev_size", &pv->size);
if (!_read_int64(pvn, "pe_start", &pv->pe_start)) {
log_error("Couldn't read extent size for volume group.");
return 0;
@ -206,7 +209,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
vg->free_count += pv->pe_count;
pv->pe_size = vg->extent_size;
pv->size = vg->extent_size * (uint64_t) pv->pe_count;
pv->pe_alloc_count = 0;
pv->fmt = fid->fmt;