From: Peter Rajnoha Date: Fri, 25 Feb 2011 14:08:54 +0000 (+0000) Subject: Allow only orphan PVs to be resized even with two metadata areas. X-Git-Tag: v2_02_91~1064 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=4a304dc1d8a8510f57f8a9ecd447e07f4a792fbd;p=lvm2.git Allow only orphan PVs to be resized even with two metadata areas. --- diff --git a/WHATS_NEW b/WHATS_NEW index 55e379f39..00711c137 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -2,7 +2,7 @@ Version 2.02.85 - =================================== Fix metadata balance code to work with recent changes in metadata handling. Add old_uuid field to physical_volume and fix pvchange -u for recent changes. - Allow pvresize on a PV with two metadata areas. + Allow pvresize on a PV with two metadata areas (for PVs not in a VG). Change pvcreate to use new metadata handling interface. Restructure existing pv_setup and pv_write fn, add pv_initialise fn. Add internal interface to support adding and removing metadata areas. diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 78f9ff9f9..703477c15 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -2161,6 +2161,17 @@ static int _text_pv_resize(const struct format_type *fmt, /* If there's an mda at the end, move it to a new position. */ if ((mda = fid_get_mda_indexed(fid, pvid, ID_LEN, 1)) && (mdac = mda->metadata_locn)) { + /* + * FIXME: Remove this restriction - we need to + * allow writing PV labels on non-orphan VGs + * for this to work correctly. + */ + if (vg) { + log_error("Resizing a PV with two metadata areas " + "that is part of a VG is not supported."); + return 0; + } + /* FIXME: Maybe MDA0 size would be better? */ mda_size = mdac->area.size >> SECTOR_SHIFT; mda_ignored = mda_is_ignored(mda); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 44c3e2f20..4aa0c31ff 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -3543,6 +3543,12 @@ int pv_write(struct cmd_context *cmd __attribute__((unused)), return 0; } + /* + * FIXME: Try to remove this restriction. This requires checking + * that the PV and the VG are in a consistent state. We need + * to provide some revert mechanism since PV label together + * with VG metadata write is not atomic. + */ if (!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count) { log_error("Assertion failed: can't _pv_write non-orphan PV " "(in VG %s)", pv->vg_name);