master - dev-type: filter out partitioned device-mapper devices as unsuitable for use as PVs
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=99d895014d971395fe7a739838952e7405eb4dda Commit: 99d895014d971395fe7a739838952e7405eb4dda Parent: 8dbe76734049a225a34bbbab383418b62acdcce1 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon Jan 12 14:02:57 2015 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon Jan 12 14:10:44 2015 +0100
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).
--- WHATS_NEW | 1 + lib/device/dev-type.c | 3 +++ test/shell/test-partition.sh | 3 ++- 3 files changed, 6 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -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.
lib/device/dev-type.c +3 -0
@@ -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 ;
test/shell/test-partition.sh +2 -1
@@ -28,4 +28,5 @@ pvs "$dev1" # create small partition table echo "1 2" | sfdisk "$dev1" -pvs "$dev1" +aux notify_lvmetad "$dev1" +not pvs "$dev1"