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

metadata: Fix find_pv_in_vg for missing PVs/filtered devices.

This commit is contained in:
Petr Rockai 2014-10-07 16:06:21 +02:00
parent 0cbb381e15
commit 88959032f7

View File

@ -1778,31 +1778,20 @@ struct pv_list *find_pv_in_vg(const struct volume_group *vg,
const char *pv_name)
{
struct pv_list *pvl;
struct device *dev = dev_cache_get(pv_name, vg->cmd->filter);
dm_list_iterate_items(pvl, &vg->pvs) {
if (!pvl->pv->dev) {
/*
* pv_dev can't be NULL here!
* We have to catch this situation earlier in the
* code if this internal error is hit. Otherwise,
* there's a possibility that pv_dev will match
* cached_dev in case both are NULL.
*
* NULL cached_dev may happen in case this device
* is filtered and NULL pv_dev may happen if the
* device is missing!
*
* If such incorrect match was hit, simply incorrect
* PV would be processed. This really needs to be
* handled earlier in the code in that case.
*/
log_error(INTERNAL_ERROR "find_pv_in_vg: PV that is not "
"bound to any existing device found.");
return NULL;
}
if (pvl->pv->dev == dev_cache_get(pv_name, vg->cmd->filter))
/*
* If the device does not exist or is filtered out, don't bother trying
* to find it in the list. This also prevents accidentally finding a
* non-NULL PV which happens to be missing (i.e. its pv->dev is NULL)
* for such devices.
*/
if (!dev)
return NULL;
dm_list_iterate_items(pvl, &vg->pvs)
if (pvl->pv->dev == dev)
return pvl;
}
return NULL;
}