diff --git a/WHATS_NEW b/WHATS_NEW index 7910cb832..31e35cd93 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.30 - =================================== + Prevent pvcreate from overwriting MDA-less PVs belonging to active VGs. Fix a segfault if using pvs with --all argument. (2.02.29) Update --uuid argument description in man pages. Fix vgreduce PV list processing not to process every PV in the VG. (2.02.29) diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 20fcdfdac..3e12c5c7b 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -14,6 +14,7 @@ */ #include "tools.h" +#include "metadata.h" struct pvcreate_params { int zero; @@ -43,6 +44,17 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name) /* FIXME Use partial mode here? */ pv = pv_read(cmd, name, NULL, NULL, 0); + /* + * If a PV has no MDAs it may appear to be an orphan until the + * metadata is read off another PV in the same VG. Detecting + * this means checking every VG by scanning every PV on the + * system. + */ + if (pv && is_orphan(pv)) { + (void) get_vgs(cmd, 1); + pv = pv_read(cmd, name, NULL, NULL, 0); + } + /* Allow partial & exported VGs to be destroyed. */ /* We must have -ff to overwrite a non orphan */ if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {