diff options
author | David Teigland <teigland@redhat.com> | 2016-04-27 12:13:26 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2016-04-27 12:13:26 -0500 |
commit | 3c53acb378478f23acf624be8836c0cb24c2724e (patch) | |
tree | 9a232dff7b31e409744329606ab38d04c4cce3bb | |
parent | 49f32e4859017104555ba0297fa0384d4aa3d5f2 (diff) | |
download | lvm2-3c53acb378478f23acf624be8836c0cb24c2724e.tar.gz |
metadata: fix segfault when filters reject devices
Checking for devices uses is_missing_pv() to check
if there is a device for the PV. is_missing_pv()
is based on the MISSING_PV flag, which does not
always correspond to !pv->dev. When using lvmetad,
a command like:
pvs --config 'devices/filter=["a|/dev/sdb|", "r|.*|"]'
will cause a number of PVs to have NULL pv->dev, but
not the MISSING_PV flag. So, NULL pv->dev needs to
also be checked.
-rw-r--r-- | lib/metadata/metadata.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 6d101e02d..c8237d5a3 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -4682,6 +4682,15 @@ static int _check_devs_used_correspond_with_vg(struct volume_group *vg) /* Mark all PVs in VG as used. */ dm_list_iterate_items(pvl, &vg->pvs) { + /* + * FIXME: It's not clear if the meaning + * of "missing" should always include the + * !pv->dev case, or if "missing" is the + * more narrow case where VG metadata has + * been written with the MISSING flag. + */ + if (!pvl->pv->dev) + continue; if (is_missing_pv(pvl->pv)) continue; pvl->pv->dev->flags |= DEV_ASSUMED_FOR_LV; |