Skip to contentSkip to conversation

automatically filter disks with imsm or ddf superblocks, v3

PATCH New Miquel van Smoorenburg 1 participant 1 message Sep 22, 2012 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 automatically filter disks with imsm or ddf superblocks, v3

The only change wrt v2 is that this fixes a small cosmetic bug in debug output.

#====#

lvm.conf has a setting called md_component_detection, which makes lvm ignore disks with a linux "md" raid superblock. This patch adds detection of more raid superblock formats, ddf and imsm.

lib/Makefile.in renamed from LVM2.2.02.97/lib/Makefile.in +2 -0
diff -ruN orig/LVM2.2.02.97/lib/Makefile.in LVM2.2.02.97/lib/Makefile.in
@@ -54,6 +54,8 @@
 	device/dev-cache.c \
 	device/dev-io.c \
 	device/dev-md.c \
+	device/dev-ddf.c \
+	device/dev-imsm.c \
 	device/dev-swap.c \
 	device/dev-luks.c \
 	device/device.c \
lib/device/dev-ddf.c renamed from LVM2.2.02.97/lib/device/dev-ddf.c +69 -0

69 lines not on this page · raw message

lib/device/dev-imsm.c renamed from LVM2.2.02.97/lib/device/dev-imsm.c +55 -0

55 lines not on this page · raw message

lib/device/device.h renamed from LVM2.2.02.97/lib/device/device.h +2 -0
diff -ruN orig/LVM2.2.02.97/lib/device/device.h LVM2.2.02.97/lib/device/device.h
@@ -101,6 +101,8 @@
 
 /* Does device contain md superblock?  If so, where? */
 int dev_is_md(struct device *dev, uint64_t *sb);
+int dev_is_ddf(struct device *dev, uint64_t *sb);
+int dev_is_imsm(struct device *dev, uint64_t *sb);
 int dev_is_swap(struct device *dev, uint64_t *signature);
 int dev_is_luks(struct device *dev, uint64_t *signature);
 unsigned long dev_md_stripe_width(const char *sysfs_dir, struct device *dev);
lib/filters/filter-md.c renamed from LVM2.2.02.97/lib/filters/filter-md.c +10 -4
diff -ruN orig/LVM2.2.02.97/lib/filters/filter-md.c LVM2.2.02.97/lib/filters/filter-md.c
@@ -23,20 +23,26 @@
 		      struct device *dev)
 {
 	int ret;
+	const char *sb_type;
 	
 	if (!md_filtering())
 		return 1;
 	
-	ret = dev_is_md(dev, NULL);
+	if ((ret = dev_is_md(dev, NULL)) != 0)
+		sb_type = "md";
+	else if ((ret = dev_is_ddf(dev, NULL)) != 0)
+		sb_type = "ddf";
+	else if ((ret = dev_is_imsm(dev, NULL)) != 0)
+		sb_type = "imsm";
 
 	if (ret == 1) {
-		log_debug("%s: Skipping md component device", dev_name(dev));
+		log_debug("%s: Skipping %s component device", dev_name(dev), sb_type);
 		return 0;
 	}
 
 	if (ret < 0) {
-		log_debug("%s: Skipping: error in md component detection",
-			  dev_name(dev));
+		log_debug("%s: Skipping: error in %s component detection",
+			  dev_name(dev), sb_type);
 		return 0;
 	}
 
lib/metadata/metadata.c renamed from LVM2.2.02.97/lib/metadata/metadata.c +6 -0
diff -ruN orig/LVM2.2.02.97/lib/metadata/metadata.c LVM2.2.02.97/lib/metadata/metadata.c
@@ -1392,6 +1392,12 @@
 	if (!_wipe_sb(dev, "software RAID md superblock", name, 4, pp, dev_is_md))
 		goto_bad;
 
+	if (!_wipe_sb(dev, "software RAID imsm superblock", name, 1024, pp, dev_is_imsm))
+		goto_bad;
+
+	if (!_wipe_sb(dev, "RAID ddf superblock", name, 512, pp, dev_is_ddf))
+		goto_bad;
+
 	if (!_wipe_sb(dev, "swap signature", name, 10, pp, dev_is_swap))
 		goto_bad;
 
man/lvm.conf.5.in renamed from LVM2.2.02.97/man/lvm.conf.5.in +4 -2
diff -ruN orig/LVM2.2.02.97/man/lvm.conf.5.in LVM2.2.02.97/man/lvm.conf.5.in
@@ -130,8 +130,10 @@
 .IP
 \fBmd_component_detection\fP \(em If set to 1, LVM2 will ignore devices
 used as components of software RAID (md) devices by looking for md
-superblocks. This doesn't always work satisfactorily e.g. if a device
-has been reused without wiping the md superblocks first.
+superblocks, ddf (common raid Disk Data Format) superblocks, and imsm
+(Intel Matrix Raid or Intel RST) superblocks.  This doesn't always work
+satisfactorily e.g. if a device has been reused without wiping the raid
+superblocks first.
 .IP
 \fBmd_chunk_alignment\fP \(em If set to 1, and a Physical Volume is placed
 directly upon an md device, LVM2 will align its data blocks with the