automatically filter disks with imsm or ddf superblocks
An earlier version of this patch was sent to the debian bugsystem (bug 684712). I am now submitting this as an RFC to the upstream maintainers.
The linux md raid subsystem supports more than just MD formatted superblocks - it also works with DDF and IMSM (Intel Matrix RAID) superblocks.
Because of that I added reckognition of those types of superblocks to lvm, similar to what is already being done for md.
Note that dev-ddf.c and dev-imsm.c have "Copyright: Miquel van Smoorenburg" headers.. it looks like lvm only has redhat copyrighted stuff in it. Feel free to remove my copyright there, and/or add redhat copyright. The contents of those files aren't really original anyway, mostly copied from dev-md.c.
Questions:
- mdadm calls this format "imsm", should we keep that name or use "matrix", or perhaps "(Intel) RST" since Intel renamed "matrix raid" to "Rapid Storage Technology" last year.
- right now the md_component_detection configuration option also turns on/off ddf and imsm detection. I think that is fine as in linux it is the "md" driver that supports those formats. Or should this option be renamed, or perhaps different options for each superblock type (not my preference).
Thanks
Mike.
lib/Makefile.in renamed from LVM2.2.02.97/lib/Makefile.in +2 -0
@@ -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 +67 -0
67 lines not on this page · raw message
lib/device/dev-imsm.c renamed from LVM2.2.02.97/lib/device/dev-imsm.c +53 -0
53 lines not on this page · raw message
lib/device/device.h renamed from LVM2.2.02.97/lib/device/device.h +2 -0
@@ -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 +12 -2
@@ -23,14 +23,24 @@ struct device *dev) {int ret; - +char *type; +if (!md_filtering ())return 1 ; + type ="md" ; ret =dev_is_md (dev,NULL ); +if (ret ==0 ) { + type ="ddf" ; + ret =dev_is_ddf (dev,NULL ); + } +if (ret ==0 ) { + type ="imsm" ; + ret =dev_is_imsm (dev,NULL ); + }if (ret ==1 ) { -log_debug ("%s: Skipping md component device" ,dev_name (dev)); +log_debug ("%s: Skipping %s component device" ,dev_name (dev), type);return 0 ; }
lib/metadata/metadata.c renamed from LVM2.2.02.97/lib/metadata/metadata.c +6 -0
@@ -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 +3 -2
@@ -130,8 +130,9 @@ .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 superblocks, and imsm (Intel Matrix Raid) 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
Quoted 5 lines · Miquel van Smoorenburg
Note that
dev-ddf.canddev-imsm.chave "Copyright: Miquel van Smoorenburg" headers.. it looks like lvm only has redhat copyrighted stuff in it. Feel free to remove my copyright there, and/or add redhat copyright. The contents of those files aren't really original anyway, mostly copied fromdev-md.c.
Copyright is additive in these circumstances: keep our copyright line and append yours.
Quoted 3 lines
- mdadm calls this format "imsm", should we keep that name or use "matrix", or perhaps "(Intel) RST" since Intel renamed "matrix raid" to "Rapid Storage Technology" last year.
Internally, I'm not bothered. Docs should probably mention alternative names.
Quoted 3 lines
- right now the
md_component_detectionconfiguration option also turns on/off ddf and imsm detection. I think that is fine as in linux it is the "md" driver that supports those formats.
I agree. It's unlikely people will need one without the other.
Alasdair
On 14-09-12 3:35 PM, Alasdair G Kergon wrote:
[review]
thanks for the comments. I'll send a v2 soon (after the weekend, probably).
Mike.
PATCH 1/1 automatically filter disks with imsm or ddf superblocks, v2
According to Miquel van Smoorenburg:
Quoted 4 lines · Alasdair G Kergon
[review]
thanks for the comments. I'll send a v2 soon (after the weekend, probably).
Here's version two of the patch. I've taken your comments into account, and I've also fixed some wrong assumptions (like size being in sectors, not bytes). It's been tested on both imsm and ddf formatted disks.
Thanks,
Mike.
#====#
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
@@ -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
@@ -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
@@ -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 ="ddf" ; +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
@@ -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
@@ -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
Re: [linux-lvm] [PATCH] automatically filter disks with imsm or ddf superblocks, v2
According to Miquel van Smoorenburg:
Quoted 3 lines
Here's version two of the patch. I've taken your comments into account, and I've also fixed some wrong assumptions (like size being in sectors, not bytes). It's been tested on both imsm and ddf formatted disks.
Hmm, I caused a small cosmetic bug when I implemented one of your suggestions, this should fix it (I'l send a full patch as well):
lib/filters/filter-md.c +1 -1
@@ -29,7 +29,7 @@return 1 ;if ((ret =dev_is_md (dev,NULL )) !=0 ) - sb_type ="ddf" ; + sb_type ="md" ;else if ((ret =dev_is_ddf (dev,NULL )) !=0 ) sb_type ="ddf" ;else if ((ret =dev_is_imsm (dev,NULL )) !=0 )