diff options
author | David Teigland <teigland@redhat.com> | 2019-05-02 16:41:42 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2019-05-03 14:39:42 -0500 |
commit | 607858538132a33a27039e0ff4796b1a7d9f4f32 (patch) | |
tree | 6b4e78d167ec8f77ecbf3d4001337c1e489c4796 | |
parent | ac627fd1cec77a8334b7e48c3cb8f3efff50fb3c (diff) | |
download | lvm2-607858538132a33a27039e0ff4796b1a7d9f4f32.tar.gz |
add md component check in vg_read based on size
If an md component is not excluded by other means and
vg_read is used to read metadata from it, then this new
check compares the device size with the PV size, and runs
a full md check on the device if the sizes don't match.
-rw-r--r-- | lib/format_text/import_vsn1.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index c9b927524..79c73ae57 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -292,6 +292,18 @@ static int _read_pv(struct format_instance *fid, pv->pe_align = 0; pv->fmt = fid->fmt; + /* + * It would be nice to check this earlier, e.g. in or after label scan, + * but this is first time we get far enough through the vg metadata to + * see the PV size, and can finally compare it with the device size. + */ + if (pv->dev && (pv->size != pv->dev->size)) { + if (dev_is_md(pv->dev, NULL, 1)) { + log_warn("WARNING: device %s is an md component, ignoring PV.", dev_name(pv->dev)); + return_0; + } + } + /* Fix up pv size if missing or impossibly large */ if ((!pv->size || pv->size > (1ULL << 62)) && pv->dev) { if (!dev_get_size(pv->dev, &pv->size)) { |