summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Assemble.c4
-rw-r--r--ChangeLog4
-rw-r--r--Create.c1
-rw-r--r--Manage.c1
-rw-r--r--mdadm.h1
-rw-r--r--util.c20
6 files changed, 31 insertions, 0 deletions
diff --git a/Assemble.c b/Assemble.c
index 5acb076..e8fec8e 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -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;
diff --git a/ChangeLog b/ChangeLog
index 950ec68..cc1e509 100644
--- 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
diff --git a/Create.c b/Create.c
index 2dbc330..ff87df0 100644
--- 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){
diff --git a/Manage.c b/Manage.c
index 1067bfe..aea21e6 100644
--- 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 29fc7c8..20537ed 100644
--- 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 08319cb..f3b7a39 100644
--- 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)
{