I submitted the patch to automatically filter disks with ddf and imsm superblocks to the linux-lvm mailinglist. I got some helpful comments and a patch review from Alasdair G Kergon. I rewrote the patch based on the review, sent it to the mailinglist and submitted it in the lvm2 (actually, redhat) bug tracker at https://bugzilla.redhat.com/show_bug.cgi?id=862085
I'm sure this patch will be included in upstream in one of the upcoming releases. Attached is the debian version of the patch (v3). Suggested changelog entry: * lvm already filters disks that have a mdraid signature, now filter DDF and IMSM formatted disks as well - also see https://bugzilla.redhat.com/show_bug.cgi?id=862085 Thanks. Mike.
diff -ruN ../work.o/lvm2-2.02.95/debian/patches/lvm-filter-imsm-ddf.patch lvm2-2.02.95/debian/patches/lvm-filter-imsm-ddf.patch --- ../work.o/lvm2-2.02.95/debian/patches/lvm-filter-imsm-ddf.patch 1970-01-01 00:00:00.000000000 +0000 +++ lvm2-2.02.95/debian/patches/lvm-filter-imsm-ddf.patch 2012-10-17 20:33:24.875265105 +0000 @@ -0,0 +1,245 @@ +From: Miquel van Smoorenburg <mik...@xs4all.net> +To: Alasdair G Kergon <a...@redhat.com> +Cc: LVM general discussion and development <linux-...@redhat.com> +Subject: [linux-lvm] [PATCH] automatically filter disks with imsm or ddf superblocks, v3 +Date: Sat, 22 Sep 2012 18:37:37 +0200 +Message-ID: <20120922163737.gb6...@xs4all.net> + +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. + +Index: lvm2-2.02.95/lib/Makefile.in +=================================================================== +--- lvm2-2.02.95.orig/lib/Makefile.in 2012-02-28 18:35:05.000000000 +0000 ++++ lvm2-2.02.95/lib/Makefile.in 2012-10-17 20:32:07.418009678 +0000 +@@ -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 \ +Index: lvm2-2.02.95/lib/device/dev-ddf.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ lvm2-2.02.95/lib/device/dev-ddf.c 2012-10-17 20:32:07.418009678 +0000 +@@ -0,0 +1,69 @@ ++/* ++ * Copyright (C) 2004 Luca Berra ++ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. ++ * Copyright (C) 2012 Miquel van Smoorenburg ++ * ++ * This file is part of LVM2. ++ * ++ * This copyrighted material is made available to anyone wishing to use, ++ * modify, copy, or redistribute it subject to the terms and conditions ++ * of the GNU Lesser General Public License v.2.1. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include "lib.h" ++#include "metadata.h" ++#include "xlate.h" ++#include "crc.h" ++ ++#define DDF_MAGIC 0xDE11DE11 ++struct ddf_header { ++ uint32_t magic; ++ uint32_t crc; ++ char guid[24]; ++ char revision[8]; ++ char padding[472]; ++} __attribute__ ((packed)); ++ ++/* ++ * Returns -1 on error ++ */ ++int dev_is_ddf(struct device *dev, uint64_t *sb) ++{ ++ struct ddf_header hdr; ++ uint64_t size, sb_offset; ++ uint32_t crc; ++ int ret = 0; ++ ++ if (!dev_get_size(dev, &size)) { ++ stack; ++ return -1; ++ } ++ ++ if (!dev_open_readonly(dev)) { ++ stack; ++ return -1; ++ } ++ ++ /* Also calculate CRC so we have at least 8 bytes to check */ ++ sb_offset = (size - 1) << SECTOR_SHIFT; ++ if (dev_read(dev, sb_offset, 512, &hdr) && ++ xlate32_be(hdr.magic) == DDF_MAGIC) { ++ crc = xlate32_be(hdr.crc); ++ hdr.crc = 0xffffffff; ++ if (calc_crc(0, (const uint8_t *)&hdr, 512) == crc) ++ ret = 1; ++ } ++ ++ if (!dev_close(dev)) ++ stack; ++ ++ if (ret && sb) ++ *sb = sb_offset; ++ ++ return ret; ++} ++ +Index: lvm2-2.02.95/lib/device/dev-imsm.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ lvm2-2.02.95/lib/device/dev-imsm.c 2012-10-17 20:32:07.418009678 +0000 +@@ -0,0 +1,55 @@ ++/* ++ * Copyright (C) 2004 Luca Berra ++ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. ++ * Copyright (C) 2012 Miquel van Smoorenburg ++ * ++ * This file is part of LVM2. ++ * ++ * This copyrighted material is made available to anyone wishing to use, ++ * modify, copy, or redistribute it subject to the terms and conditions ++ * of the GNU Lesser General Public License v.2.1. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with this program; if not, write to the Free Software Foundation, ++ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include "lib.h" ++#include "metadata.h" ++ ++#define IMSM_SIGNATURE "Intel Raid ISM Cfg Sig. " ++#define IMSM_SIG_LEN (strlen(IMSM_SIGNATURE)) ++ ++/* ++ * Returns -1 on error ++ */ ++int dev_is_imsm(struct device *dev, uint64_t *sb) ++{ ++ char imsm_signature[IMSM_SIG_LEN]; ++ uint64_t size, sb_offset; ++ int ret = 0; ++ ++ if (!dev_get_size(dev, &size)) { ++ stack; ++ return -1; ++ } ++ ++ if (!dev_open_readonly(dev)) { ++ stack; ++ return -1; ++ } ++ ++ sb_offset = (size - 2) << SECTOR_SHIFT; ++ if (dev_read(dev, sb_offset, IMSM_SIG_LEN, imsm_signature) && ++ memcmp(imsm_signature, IMSM_SIGNATURE, IMSM_SIG_LEN) == 0) ++ ret = 1; ++ ++ if (!dev_close(dev)) ++ stack; ++ ++ if (ret && sb) ++ *sb = sb_offset; ++ ++ return ret; ++} ++ +Index: lvm2-2.02.95/lib/device/device.h +=================================================================== +--- lvm2-2.02.95.orig/lib/device/device.h 2011-05-24 13:36:57.000000000 +0000 ++++ lvm2-2.02.95/lib/device/device.h 2012-10-17 20:32:07.418009678 +0000 +@@ -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); +Index: lvm2-2.02.95/lib/filters/filter-md.c +=================================================================== +--- lvm2-2.02.95.orig/lib/filters/filter-md.c 2010-09-22 01:50:38.000000000 +0000 ++++ lvm2-2.02.95/lib/filters/filter-md.c 2012-10-17 20:32:07.418009678 +0000 +@@ -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; + } + +Index: lvm2-2.02.95/lib/metadata/metadata.c +=================================================================== +--- lvm2-2.02.95.orig/lib/metadata/metadata.c 2012-03-02 20:46:37.000000000 +0000 ++++ lvm2-2.02.95/lib/metadata/metadata.c 2012-10-17 20:32:07.418009678 +0000 +@@ -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; + +Index: lvm2-2.02.95/man/lvm.conf.5.in +=================================================================== +--- lvm2-2.02.95.orig/man/lvm.conf.5.in 2012-01-12 02:32:09.000000000 +0000 ++++ lvm2-2.02.95/man/lvm.conf.5.in 2012-10-17 20:32:36.138475181 +0000 +@@ -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 diff -ruN ../work.o/lvm2-2.02.95/debian/patches/series lvm2-2.02.95/debian/patches/series --- ../work.o/lvm2-2.02.95/debian/patches/series 2012-05-27 12:27:52.000000000 +0000 +++ lvm2-2.02.95/debian/patches/series 2012-10-17 20:31:44.869644216 +0000 @@ -6,3 +6,4 @@ implicit-pointer.patch dm-event-api.patch monitoring-default-off.patch +lvm-filter-imsm-ddf.patch