]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Remove partitions from components of an md array
authorNeil Brown <neilb@suse.de>
Thu, 12 Oct 2006 23:02:35 +0000 (09:02 +1000)
committerNeil Brown <neilb@suse.de>
Thu, 12 Oct 2006 23:02:35 +0000 (09:02 +1000)
They do nothing but cause confusion.

Assemble.c
ChangeLog
Create.c
Manage.c
mdadm.h
util.c

index 5acb076caf01cec617d31a2d71f095f0583fe650..e8fec8e954cb19868351768d2630eb6163b27205 100644 (file)
@@ -421,6 +421,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        }
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
 
+                       remove_partitions(dfd);
+
                        if (super) {
                                free(super);
                                super = NULL;
@@ -460,6 +462,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        int dfd;
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
 
+                       remove_partitions(dfd);
+
                        if (super) {
                                free(super);
                                super = NULL;
index 950ec68d3c58d30379dc7dabbf85829e79e3a164..cc1e509d4e4f1b90f238aec1f6c527fa6029af5b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@ Changes Prior to this release
     -   Fix endian problem with 'bitmap' metadata
     -   Allow a number (of partitions) after the 'yes' option to --auto=
        This is particularly useful in the 'create' line in mdadm.conf.
+    -   Remove partitions from any whole device that is made part of
+       an md array.  This is a work-around for annoying messages
+       when the first block on some drive accidentally looks like a
+       partition table.
 
 Changes Prior to 2.5.3 release
     -   Document v0.91 superblocks in md.4
index 2dbc330975dd3a5c24e1a5997a44b226961ca8ad..ff87df09e65586c061b8a1e6eadf37bc3f2f2078 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -521,6 +521,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                                fstat(fd, &stb);
                                disk.major = major(stb.st_rdev);
                                disk.minor = minor(stb.st_rdev);
+                               remove_partitions(fd);
                                close(fd);
                        }
                        switch(pass){
index 1067bfe96e90b5b44f7cd2116424b3ee9f05ef97..aea21e65945118505b30d4c82fc68275d78e1103 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -259,6 +259,7 @@ int Manage_subdevs(char *devname, int fd,
                                                close(dfd);
                                                continue;
                                        }
+                                       remove_partitions(dfd);
                                        close(dfd);
                                        break;
                                }
diff --git a/mdadm.h b/mdadm.h
index 29fc7c8823030e27520be8e9a42309e00ec7be39..20537ede1fd309c2e8c921f96916abee36443e97 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -460,6 +460,7 @@ extern int enough(int level, int raid_disks, int layout,
                   char *avail, int avail_disks);
 extern int ask(char *mesg);
 extern unsigned long long get_component_size(int fd);
+extern void remove_partitions(int fd);
 
 
 extern char *human_size(long long bytes);
diff --git a/util.c b/util.c
index 08319cb6bccadb86b9c68884a066f1e96b8ef2f0..f3b7a3970224ffba7f2201287dcdb3a18b03dfbc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -31,6 +31,7 @@
 #include       "md_p.h"
 #include       <sys/utsname.h>
 #include       <ctype.h>
+#include       <linux/blkpg.h>
 
 /*
  * Parse a 128 bit uuid in 4 integers
@@ -118,6 +119,25 @@ int get_linux_version()
        return (a*1000000)+(b*1000)+c;
 }
 
+void remove_partitions(int fd)
+{
+       /* remove partitions from this block devices.
+        * This is used for components added to an array
+        */
+#ifdef BLKPG_DEL_PARTITION
+       struct blkpg_ioctl_arg a;
+       struct blkpg_partition p;
+
+       a.op = BLKPG_DEL_PARTITION;
+       a.data = (void*)&p;
+       a.datalen = sizeof(p);
+       a.flags = 0;
+       memset(a.data, 0, a.datalen);
+       for (p.pno=0; p.pno < 16; p.pno++)
+               ioctl(fd, BLKPG, &a);
+#endif
+}
+
 int enough(int level, int raid_disks, int layout,
           char *avail, int avail_disks)
 {