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

metadata: Fix metadata repair when devs still missing.

_check_reappeared_pv() incorrectly clears the MISSING_PV flags of
PVs with unknown devices.
While one caller avoids passing such PVs into the function, the other
doesn't.  Move the check inside the function so it's not forgotten.

Without this patch, if the normal VG reading code tries to repair
inconsistent metadata while there is an unknown PV, it incorrectly
considers the missing PVs no longer to be missing and produces
incorrect 'pvs' output omitting the missing PV, for example.

Easy reproducer:
Create a VG with 3 PVs pv1, pv2, pv3.
Hide pv2.
Run vgreduce --removemissing.
Reinstate the hidden PV pv2 and at the same time hide a different PV
pv3.
Run 'pvs' - incorrect output.
Run 'pvs' again - correct output.

See https://bugzilla.redhat.com/1434054
This commit is contained in:
Alasdair G Kergon 2017-05-11 02:04:50 +01:00
parent d45531712d
commit 80900dcf76
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.172 -
===============================
Don't reinstate still-missing devices when correcting inconsistent metadata.
Properly handle subshell return codes in fsadm.
Disallow cachepool creation with policy cleaner and mode writeback.

View File

@ -3910,7 +3910,13 @@ static int _check_reappeared_pv(struct volume_group *correct_vg,
* confusing.
*/
if (correct_vg->cmd->handles_missing_pvs)
return rv;
return rv;
/*
* Skip this if there is no underlying device present for this PV.
*/
if (!pv->dev)
return rv;
dm_list_iterate_items(pvl, &correct_vg->pvs)
if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) {
@ -4174,8 +4180,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
if (lvmetad_used() && !use_precommitted) {
if ((correct_vg = lvmcache_get_vg(cmd, vgname, vgid, precommitted))) {
dm_list_iterate_items(pvl, &correct_vg->pvs)
if (pvl->pv->dev)
reappeared += _check_reappeared_pv(correct_vg, pvl->pv, *consistent);
reappeared += _check_reappeared_pv(correct_vg, pvl->pv, *consistent);
if (reappeared && *consistent)
*consistent = _repair_inconsistent_vg(correct_vg);
else