diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-01-12 14:02:57 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-01-12 14:10:44 +0100 |
commit | 99d895014d971395fe7a739838952e7405eb4dda (patch) | |
tree | 67e77733b43b201a9d587ad18f6b8beb51976b8f | |
parent | 8dbe76734049a225a34bbbab383418b62acdcce1 (diff) | |
download | lvm2-99d895014d971395fe7a739838952e7405eb4dda.tar.gz |
dev-type: filter out partitioned device-mapper devices as unsuitable for use as PVs
Normally, if there are partitions defined on top of device-mapper
device, there should be a device-mapper device created for each
partiton on top of the old one and once the underlying DM device
is used by another devices (partition mappings in this case),
it can't be used as a PV anymore.
However, sometimes, it may happen the partition mappings are
missing - either the partitioning tool is not creating them if
it does not contain full support for device-mapper devices or
the mappings were removed.
Better safe than sorry - check for partition header on DM devs
and filter them out as unsuitable for PVs in case the check is
positive. Whatever the user is doing, let's do our best to prevent
unwanted corruption (...by running pvcreate on top of such device
that would corrupt the partition header).
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | lib/device/dev-type.c | 3 | ||||
-rw-r--r-- | test/shell/test-partition.sh | 3 |
3 files changed, 6 insertions, 1 deletions
@@ -1,5 +1,6 @@ Version 2.02.115 - ===================================== + Filter out partitioned device-mapper devices as unsuitable for use as PVs. Also notify lvmetad about filtered device if using pvscan --cache DevicePath. Use LVM's own selection instead of awk expressions in clvmd startup scripts. Do not filter out snapshot origin LVs as unusable devices for an LVM stack. diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c index 001248d45..a84f7e97b 100644 --- a/lib/device/dev-type.c +++ b/lib/device/dev-type.c @@ -272,6 +272,9 @@ static int _is_partitionable(struct dev_types *dt, struct device *dev) { int parts = major_max_partitions(dt, MAJOR(dev->dev)); + if (MAJOR(dev->dev) == dt->device_mapper_major) + return 1; + /* All MD devices are partitionable via blkext (as of 2.6.28) */ if (MAJOR(dev->dev) == dt->md_major) return 1; diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh index af04b4ef5..e79216e4c 100644 --- a/test/shell/test-partition.sh +++ b/test/shell/test-partition.sh @@ -28,4 +28,5 @@ pvs "$dev1" # create small partition table echo "1 2" | sfdisk "$dev1" -pvs "$dev1" +aux notify_lvmetad "$dev1" +not pvs "$dev1" |