From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13664 invoked by alias); 7 Oct 2006 23:17:17 -0000 Received: (qmail 13651 invoked by uid 9447); 7 Oct 2006 23:17:17 -0000 Date: Sat, 07 Oct 2006 23:17:00 -0000 Message-ID: <20061007231717.13649.qmail@sourceware.org> From: agk@sourceware.org To: lvm2-cvs@sourceware.org Subject: LVM2/lib/format_text export.c format-text.c im ... Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00024.txt.bz2 List-Id: CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2006-10-07 23:17:17 Modified files: lib/format_text: export.c format-text.c import_vsn1.c Log message: 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. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 --- LVM2/lib/format_text/export.c 2006/08/21 12:54:52 1.52 +++ LVM2/lib/format_text/export.c 2006/10/07 23:17:17 1.53 @@ -409,6 +409,11 @@ 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)) { --- LVM2/lib/format_text/format-text.c 2006/10/05 22:02:52 1.67 +++ LVM2/lib/format_text/format-text.c 2006/10/07 23:17:17 1.68 @@ -1465,8 +1465,16 @@ } } + /* 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? */ --- LVM2/lib/format_text/import_vsn1.c 2006/05/09 21:23:50 1.35 +++ LVM2/lib/format_text/import_vsn1.c 2006/10/07 23:17:17 1.36 @@ -179,6 +179,9 @@ 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 @@ 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;