- Remove stale patches already accepted by upstream

- Fix the raid-check script to only try and check a device if it is
    checkable
- Update to official mdadm-3.0 version
- Resolves: bz505587, bz505552
This commit is contained in:
Doug Ledford 2009-06-29 19:22:06 +00:00
parent f58f390b84
commit d395ee1418
9 changed files with 15 additions and 490 deletions

View File

@ -12,3 +12,4 @@ mdadm-2.6.7.tar.bz2
mdadm-2.6.7.1.tar.bz2
mdadm-3.0-devel2.tar.bz2
mdadm-3.0-devel3.tar.bz2
mdadm-3.0.tar.bz2

View File

@ -20,5 +20,5 @@ Binary files mdadm-3.0-devel2/mdadm.static and mdadm-3.0-devel2/mdadm differ
- $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm.klibc
install-man: mdadm.8 md.4 mdadm.conf.5
install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
$(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8

View File

@ -1,24 +0,0 @@
--- mdadm-3.0-devel3/super-ddf.c.orig 2009-03-10 01:39:41.000000000 -0400
+++ mdadm-3.0-devel3/super-ddf.c 2009-03-17 15:22:41.000000000 -0400
@@ -1062,9 +1062,9 @@
map_num(ddf_sec_level, vc->srl) ?: "-unknown-");
}
printf(" Device Size[%d] : %llu\n", n,
- __be64_to_cpu(vc->blocks)/2);
+ (unsigned long long)__be64_to_cpu(vc->blocks)/2);
printf(" Array Size[%d] : %llu\n", n,
- __be64_to_cpu(vc->array_blocks)/2);
+ (unsigned long long)__be64_to_cpu(vc->array_blocks)/2);
}
}
@@ -1111,7 +1111,8 @@
//printf("\n");
printf(" %3d %08x ", i,
__be32_to_cpu(pd->refnum));
- printf("%lluK ", __be64_to_cpu(pd->config_size)>>1);
+ printf("%lluK ",
+ (unsigned long long)__be64_to_cpu(pd->config_size)>>1);
for (dl = sb->dlist; dl ; dl = dl->next) {
if (dl->disk.refnum == pd->refnum) {
char *dv = map_dev(dl->major, dl->minor, 0);

View File

@ -1,299 +0,0 @@
--- mdadm-3.0-devel3/Incremental.c.foreign 2009-03-20 17:49:20.000000000 -0400
+++ mdadm-3.0-devel3/Incremental.c 2009-03-20 21:19:50.000000000 -0400
@@ -29,12 +29,14 @@
*/
#include "mdadm.h"
+#include <ctype.h>
static int count_active(struct supertype *st, int mdfd, char **availp,
struct mdinfo *info);
static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
int number, __u64 events, int verbose,
char *array_name);
+static int compare_array_name(char *conf_name, char *sb_name);
int Incremental(char *devname, int verbose, int runstop,
struct supertype *st, char *homehost, int autof)
@@ -48,8 +50,10 @@ int Incremental(char *devname, int verbo
* 2/ Find metadata, reject if none appropriate (check
* version/name from args)
* 3/ Check if there is a match in mdadm.conf
- * 3a/ if not, check for homehost match. If no match, assemble as
- * a 'foreign' array.
+ * 3a/ Evalutate the quality of match and whether or not we have a
+ * conf file at all, and make a decision about whether or not
+ * to allow this array to keep its preferred name based upon
+ * that
* 4/ Determine device number.
* - If in mdadm.conf with std name, use that
* - UUID in /dev/md/mdadm.map use that
@@ -78,7 +82,7 @@ int Incremental(char *devname, int verbo
*/
struct stat stb;
struct mdinfo info;
- struct mddev_ident_s *array_list, *match;
+ struct mddev_ident_s *array_list, *match, *match_uuid, *match_name;
char chosen_name[1024];
int rv;
struct map_ent *mp, *map = NULL;
@@ -148,26 +152,42 @@ int Incremental(char *devname, int verbo
st->ss->getinfo_super(st, &info);
/* 3/ Check if there is a match in mdadm.conf */
+ name_to_use = strchr(info.name, ':');
+ if (name_to_use)
+ name_to_use++;
+ else
+ name_to_use = info.name;
array_list = conf_get_ident(NULL);
match = NULL;
+ match_uuid = NULL;
+ match_name = NULL;
for (; array_list; array_list = array_list->next) {
+ /* Check for matching uuid, then drop through to check and see
+ * if we also have a matching name, and to catch cases of
+ * matching names without a corresponding uuid match */
if (array_list->uuid_set &&
same_uuid(array_list->uuid, info.uuid, st->ss->swapuuid)
- == 0) {
- if (verbose >= 2 && array_list->devname)
+ != 0)
+ match_uuid = array_list;
+ else if (array_list->uuid_set && verbose >= 2 &&
+ array_list->devname)
fprintf(stderr, Name
": UUID differs from %s.\n",
array_list->devname);
- continue;
- }
+ /* If we match name, save it off separately so we can tell if
+ * we matched uuid, name, or both, and if both, if they were
+ * the same entry */
if (array_list->name[0] &&
- strcasecmp(array_list->name, info.name) != 0) {
- if (verbose >= 2 && array_list->devname)
+ compare_array_name(array_list->name, info.name))
+ match_name = array_list;
+ else if (array_list->name[0] && verbose >= 2 &&
+ array_list->devname)
fprintf(stderr, Name
": Name differs from %s.\n",
array_list->devname);
+ if ((!match_uuid || match == match_uuid) &&
+ (!match_name || match == match_name))
continue;
- }
if (array_list->devices &&
!match_oneof(array_list->devices, devname)) {
if (verbose >= 2 && array_list->devname)
@@ -197,7 +217,13 @@ int Incremental(char *devname, int verbo
/* FIXME, should I check raid_disks and level too?? */
if (match) {
- if (verbose >= 0) {
+ if (match_uuid != match_name) {
+ if (match_uuid->devname)
+ fprintf(stderr, Name ": more than one "
+ "match for %s, using the UUID "
+ "match\n", match_uuid->devname);
+ match = match_uuid;
+ } else if (verbose >= 0) {
if (match->devname && array_list->devname)
fprintf(stderr, Name
": we match both %s and %s - cannot decide which to use.\n",
@@ -205,23 +231,52 @@ int Incremental(char *devname, int verbo
else
fprintf(stderr, Name
": multiple lines in mdadm.conf match\n");
+ return 2;
}
- return 2;
}
match = array_list;
}
- /* 3a/ if not, check for homehost match. If no match, continue
- * but don't trust the 'name' in the array. Thus a 'random' minor
- * number will be assigned, and the device name will be based
- * on that. */
- if (match)
+ /* 3a/ Decide if we got a good match, two matches, no matches, or a
+ * likely foreign match. I dropped the homehost test entirely because
+ * it didn't seem to add any value whatsoever above and beyond what
+ * these tests can do. */
+ if (match && match_uuid == match_name) {
+ /* found in conf, both name and uuid match */
trustworthy = LOCAL;
- else if (homehost == NULL ||
- st->ss->match_home(st, homehost) != 1)
- trustworthy = FOREIGN;
- else
+ } else if (match_uuid && match_name) {
+ /* found both a name and a uuid match, but not on the same
+ * entry, so prefer the uuid match (done above) */
trustworthy = LOCAL;
+ } else if (!match_uuid && match_name) {
+ /* no uuid match, but name match */
+ if (match_name->uuid_set) {
+ /* oops, name that matched had a uuid, it just wasn't
+ * right, assume there is a local device with both
+ * a matching name and uuid, so this needs a random
+ * name */
+ trustworthy = FOREIGN;
+ match = NULL;
+ } else
+ /* matched name, and the matching entry in conf file
+ * didn't include a uuid, and this uuid never showed
+ * up anywhere else in the conf file, so consider it
+ * a soft match and allow it...although users should
+ * *REALLY* include the uuid on array lines in the
+ * conf file */
+ trustworthy = LOCAL;
+ } else { /* no match at all */
+ if (!conf_exists())
+ /* If we don't even have a conf file, this is foreign,
+ * but also not likely to conflict with anything
+ * local, so let it keep its preferred name */
+ trustworthy = LOCAL;
+ else
+ /* We have a conf file, this didn't match any uuids
+ * or names, so also not likely to conflict, let it
+ * keep its own name */
+ trustworthy = LOCAL;
+ }
/* There are three possible sources for 'autof': command line,
* ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
@@ -240,11 +295,6 @@ int Incremental(char *devname, int verbo
return Incremental_container(st, devname, verbose, runstop,
autof, trustworthy);
}
- name_to_use = strchr(info.name, ':');
- if (name_to_use)
- name_to_use++;
- else
- name_to_use = info.name;
if ((!name_to_use || name_to_use[0] == 0) &&
info.array.level == LEVEL_CONTAINER &&
@@ -797,3 +847,45 @@ int Incremental_container(struct superty
map_unlock(&map);
return 0;
}
+
+static int compare_array_name(char *conf_name, char *sb_name)
+{
+ char *cptr, *sptr;
+ int conf_num = -1;
+
+ /* usage of the name variable in the superblock comes in several
+ * flavors:
+ * A) full md pathname (/dev/md0)
+ * B) just the md name (md0)
+ * C) just the md number (0)
+ * D) all of the above, but with hostname: prefixed to it
+ *
+ * Depending on which of those variants we have, we need to alter
+ * how we attempt to match the array name in the mdadm.conf file
+ * which is always a full pathname. We don't match on hostname:
+ * though, so eliminate it from the equation.
+ */
+
+ if ((sptr = strchr(sb_name, ':')) == NULL)
+ sptr = sb_name;
+ else
+ sptr++;
+
+ /* Do we have a full pathname in the superblock name field? */
+ if (strchr(sptr, '/'))
+ return !strcasecmp(conf_name, sptr);
+ /* If not, is it just a number or an md device name? */
+ else if (isdigit(sptr[0])) {
+ cptr = conf_name + strlen(conf_name);
+ while (cptr > conf_name && isdigit(cptr[-1]))
+ cptr--;
+ if (cptr[0])
+ conf_num = strtoul(cptr, NULL, 10);
+ return conf_num == strtoul(sptr, NULL, 10);
+ } /* fall through else, it's a device name but not a full path */
+
+ cptr = strcasestr(conf_name, sptr);
+ if (cptr)
+ return !strcasecmp(cptr, sptr);
+ return 0;
+}
--- mdadm-3.0-devel3/mdadm.h.foreign 2009-03-10 01:39:41.000000000 -0400
+++ mdadm-3.0-devel3/mdadm.h 2009-03-20 17:49:20.000000000 -0400
@@ -785,6 +785,7 @@ extern mddev_dev_t conf_get_devs(void);
extern int conf_test_dev(char *devname);
extern struct createinfo *conf_get_create_info(void);
extern void set_conffile(char *file);
+extern int conf_exists(void);
extern char *conf_get_mailaddr(void);
extern char *conf_get_mailfrom(void);
extern char *conf_get_program(void);
--- mdadm-3.0-devel3/mdopen.c.foreign 2009-03-20 19:02:38.000000000 -0400
+++ mdadm-3.0-devel3/mdopen.c 2009-03-20 19:02:43.000000000 -0400
@@ -159,7 +159,6 @@ int create_mddev(char *dev, char *name,
strcpy(chosen, "/dev/md/");
cname = chosen + strlen(chosen);
-
if (dev) {
if (strncmp(dev, "/dev/md/", 8) == 0) {
@@ -240,12 +239,14 @@ int create_mddev(char *dev, char *name,
if (num < 0 && trustworthy == LOCAL && name) {
/* if name is numeric, use that for num
* if it is not already in use */
- char *ep;
- num = strtoul(name, &ep, 10);
- if (ep == name || *ep)
- num = -1;
- else if (mddev_busy(use_mdp ? (-1-num) : num))
- num = -1;
+ char *e = name + strlen(name);
+ while (e > name && isdigit(e[-1]))
+ e--;
+ if (e[0]) {
+ num = strtoul(e, NULL, 10);
+ if (mddev_busy(use_mdp ? (-1-num) : num))
+ num = -1;
+ }
}
if (num < 0) {
--- mdadm-3.0-devel3/config.c.foreign 2009-03-10 01:39:41.000000000 -0400
+++ mdadm-3.0-devel3/config.c 2009-03-20 17:49:20.000000000 -0400
@@ -637,7 +637,7 @@ void homehostline(char *line)
}
}
-
+int exists = 0;
int loaded = 0;
static char *conffile = NULL;
@@ -683,6 +683,7 @@ void load_conffile(void)
if (f == NULL)
return;
+ exists = 1;
loaded = 1;
while ((line=conf_line(f))) {
switch(match_keyword(line)) {
@@ -718,6 +719,13 @@ void load_conffile(void)
/* printf("got file\n"); */
}
+int conf_exists(void)
+{
+ if (!loaded)
+ load_conffile();
+ return exists;
+}
+
char *conf_get_mailaddr(void)
{
load_conffile();

View File

@ -1,15 +0,0 @@
--- mdadm-3.0-devel3/udev-md-raid.rules.incremental 2009-03-18 14:16:24.000000000 -0400
+++ mdadm-3.0-devel3/udev-md-raid.rules 2009-03-18 14:17:11.000000000 -0400
@@ -1,10 +1,10 @@
# do not edit this file, it will be overwritten on update
SUBSYSTEM!="block", GOTO="md_end"
-ACTION!="add|change", GOTO="md_end"
+ACTION!="add", GOTO="md_end"
# import data from a raid member and activate it
-#ENV{ID_FS_TYPE}=="linux_raid_member", IMPORT{program}="/sbin/mdadm --examine --export $tempnode", RUN+="/sbin/mdadm --incremental $env{DEVNAME}"
+ENV{ID_FS_TYPE}=="linux_raid_member", IMPORT{program}="/sbin/mdadm --examine --export $tempnode", RUN+="/sbin/mdadm --incremental $env{DEVNAME}"
# import data from a raid set
KERNEL!="md*", GOTO="md_end"

View File

@ -1,130 +0,0 @@
--- mdadm-3.0-devel3/mapfile.c.mapfile 2009-03-10 01:39:41.000000000 -0400
+++ mdadm-3.0-devel3/mapfile.c 2009-04-17 13:22:45.000000000 -0400
@@ -1,5 +1,5 @@
/*
- * mapfile - manage /var/run/mdadm.map. Part of:
+ * mapfile - manage /dev/.mdadm.map. Part of:
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2006 Neil Brown <neilb@suse.de>
@@ -28,7 +28,7 @@
* Australia
*/
-/* /var/run/mdadm.map is used to track arrays being created in --incremental
+/* /dev/.mdadm.map is used to track arrays being created in --incremental
* more. It particularly allows lookup from UUID to array device, but
* also allows the array device name to be easily found.
*
@@ -48,13 +48,8 @@
{
FILE *f;
int err;
- int subdir = 1;
- f = fopen("/var/run/mdadm/map.new", "w");
- if (!f) {
- f = fopen("/var/run/mdadm.map.new", "w");
- subdir = 0;
- }
+ f = fopen("/dev/.mdadm.map.new", "w");
if (!f)
return 0;
for (; mel; mel = mel->next) {
@@ -73,32 +68,19 @@
err = ferror(f);
fclose(f);
if (err) {
- if (subdir)
- unlink("/var/run/mdadm/map.new");
- else
- unlink("/var/run/mdadm.map.new");
+ unlink("/dev/.mdadm.map.new");
return 0;
}
- if (subdir)
- return rename("/var/run/mdadm/map.new",
- "/var/run/mdadm/map") == 0;
- else
- return rename("/var/run/mdadm.map.new",
- "/var/run/mdadm.map") == 0;
+ return rename("/dev/.mdadm.map.new",
+ "/dev/.mdadm.map") == 0;
}
static int lfd = -1;
-static int lsubdir = 0;
int map_lock(struct map_ent **melp)
{
if (lfd < 0) {
- lfd = open("/var/run/mdadm/map.lock", O_CREAT|O_RDWR, 0600);
- if (lfd < 0) {
- lfd = open("/var/run/mdadm.map.lock", O_CREAT|O_RDWR, 0600);
- lsubdir = 0;
- } else
- lsubdir = 1;
+ lfd = open("/dev/.mdadm.map.lock", O_CREAT|O_RDWR, 0600);
if (lfd < 0)
return -1;
if (lockf(lfd, F_LOCK, 0) != 0) {
@@ -117,10 +99,7 @@
{
if (lfd >= 0)
close(lfd);
- if (lsubdir)
- unlink("/var/run/mdadm/map.lock");
- else
- unlink("/var/run/mdadm.map.lock");
+ unlink("/dev/.mdadm.map.lock");
lfd = -1;
}
@@ -149,16 +128,12 @@
*melp = NULL;
- f = fopen("/var/run/mdadm/map", "r");
- if (!f)
- f = fopen("/var/run/mdadm.map", "r");
+ f = fopen("/dev/.mdadm.map", "r");
if (!f) {
RebuildMap();
- f = fopen("/var/run/mdadm/map", "r");
+ f = fopen("/dev/.mdadm.map", "r");
}
if (!f)
- f = fopen("/var/run/mdadm.map", "r");
- if (!f)
return;
while (fgets(buf, sizeof(buf), f)) {
--- mdadm-3.0-devel3/Incremental.c.mapfile 2009-03-10 01:39:41.000000000 -0400
+++ mdadm-3.0-devel3/Incremental.c 2009-03-20 21:21:51.000000000 -0400
@@ -52,7 +52,7 @@
* a 'foreign' array.
* 4/ Determine device number.
* - If in mdadm.conf with std name, use that
- * - UUID in /var/run/mdadm.map use that
+ * - UUID in /dev/md/mdadm.map use that
* - If name is suggestive, use that. unless in use with different uuid.
* - Choose a free, high number.
* - Use a partitioned device unless strong suggestion not to.
@@ -67,7 +67,7 @@
* - check one drive in array to make sure metadata is a reasonably
* close match. Reject if not (e.g. different type)
* - add the device
- * 6/ Make sure /var/run/mdadm.map contains this array.
+ * 6/ Make sure /dev/md/mdadm.map contains this array.
* 7/ Is there enough devices to possibly start the array?
* For a container, this means running Incremental_container.
* 7a/ if not, finish with success.
@@ -315,7 +315,7 @@
}
info.array.working_disks = 1;
sysfs_free(sra);
- /* 6/ Make sure /var/run/mdadm.map contains this array. */
+ /* 6/ Make sure /dev/md/mdadm.map contains this array. */
map_update(&map, fd2devnum(mdfd),
info.text_version,
info.uuid, chosen_name);

View File

@ -1,16 +1,12 @@
Summary: The mdadm program controls Linux md devices (software RAID arrays)
Name: mdadm
Version: 3.0
Release: 0.devel3.7%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}-devel3.tar.bz2
Release: 1%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.bz2
Source1: mdmonitor.init
Source2: raid-check
Source3: mdadm.rules
Patch1: mdadm-2.5.2-static.patch
Patch2: mdadm-3.0-cast.patch
Patch3: mdadm-3.0-incremental.patch
Patch4: mdadm-3.0-mapfile.patch
Patch5: mdadm-3.0-foreign.patch
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
License: GPLv2+
Group: System Environment/Base
@ -30,12 +26,8 @@ almost all functions without a configuration file, though a configuration
file can be used to help with some common tasks.
%prep
%setup -q -n mdadm-3.0-devel3
%setup -q
%patch1 -p1 -b .static
%patch2 -p1 -b .cast
%patch3 -p1 -b .incremental
%patch4 -p1 -b .mapfile
%patch5 -p1 -b .foreign
%build
make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" SYSCONFDIR="%{_sysconfdir}" mdadm.static mdadm mdmon
@ -56,14 +48,6 @@ rm -rf $RPM_BUILD_ROOT
if [ "$1" = 1 ]; then
/sbin/chkconfig --add mdmonitor
fi
# If we are upgrading, the postun for mdmpd will not have deleted the init.d
# file, so clean the stale file out here. We should only have to carry this
# baggage around for a little while before we can assume that the old mdmpd
# stuff has been cleaned up.
if [ -x /etc/init.d/mdmpd ]; then
service mdmpd stop > /dev/null 2>&1 ||:
/sbin/chkconfig --del mdmpd
fi
%preun
if [ "$1" = 0 ]; then
@ -87,6 +71,13 @@ fi
%attr(0700,root,root) %dir /var/run/mdadm
%changelog
* Mon Jun 29 2009 Doug Ledford <dledford@redhat.com> - 3.0-1
- Remove stale patches already accepted by upstream
- Fix the raid-check script to only try and check a device if it is
checkable
- Update to official mdadm-3.0 version
- Resolves: bz505587, bz505552
* Tue May 19 2009 Doug Ledford <dledford@redhat.com> - 3.0-0.devel3.7
- Move the mdadm.map file from /dev/md/ to /dev/ so the installer doesn't
need to precreate the /dev/md/ directory in order for incremental

View File

@ -1,6 +1,7 @@
#!/bin/bash
for dev in `grep "^md.*: active" /proc/mdstat | cut -f 1 -d ' '`; do
echo "check" > /sys/block/$dev/md/sync_action
[ -f /sys/block/$dev/md/sync_action ] && \
echo "check" > /sys/block/$dev/md/sync_action
done

View File

@ -1 +1 @@
8cf5b1abb20b2bc33a2bd4b1afbae814 mdadm-3.0-devel3.tar.bz2
bcd27a1359b18e25e61593221d098f6a mdadm-3.0.tar.bz2