From 0430ed4868970a9c72318357d30cd0b4d4144407 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 13 Oct 2006 09:02:35 +1000 Subject: [PATCH] Remove partitions from components of an md array They do nothing but cause confusion. --- Assemble.c | 4 ++++ ChangeLog | 4 ++++ Create.c | 1 + Manage.c | 1 + mdadm.h | 1 + util.c | 20 ++++++++++++++++++++ 6 files changed, 31 insertions(+) diff --git a/Assemble.c b/Assemble.c index 5acb076c..e8fec8e9 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 950ec68d..cc1e509d 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 2dbc3309..ff87df09 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 1067bfe9..aea21e65 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 29fc7c88..20537ede 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 08319cb6..f3b7a397 100644 --- a/util.c +++ b/util.c @@ -31,6 +31,7 @@ #include "md_p.h" #include #include +#include /* * 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) { -- 2.39.2