1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +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) const char *pv_name)
{ {
struct pv_list *pvl; 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) { * 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
* pv_dev can't be NULL here! * non-NULL PV which happens to be missing (i.e. its pv->dev is NULL)
* We have to catch this situation earlier in the * for such devices.
* code if this internal error is hit. Otherwise, */
* there's a possibility that pv_dev will match if (!dev)
* cached_dev in case both are NULL. return NULL;
*
* NULL cached_dev may happen in case this device dm_list_iterate_items(pvl, &vg->pvs)
* is filtered and NULL pv_dev may happen if the if (pvl->pv->dev == dev)
* 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))
return pvl; return pvl;
}
return NULL; return NULL;
} }