diff -u mdadm-2.6.7.1/Incremental.c mdadm-2.6.7.1/Incremental.c --- mdadm-2.6.7.1/Incremental.c +++ mdadm-2.6.7.1/Incremental.c @@ -29,6 +29,7 @@ */ #include "mdadm.h" +#include static int count_active(struct supertype *st, int mdfd, char **availp, struct mdinfo *info); @@ -83,13 +84,11 @@ int dfd, mdfd; char *avail; int active_disks; + int parts = 0; struct createinfo *ci = conf_get_create_info(); - if (autof == 0) - autof = ci->autof; - /* 1/ Check if devices is permitted by mdadm.conf */ if (!conf_test_dev(devname)) { @@ -213,6 +212,18 @@ return 2; } } + + /* There are three possible sources for 'autof': command line, + * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf. + * ARRAY takes precedence, then command line, then + * CREATE. + */ + if (match && match->autof) + autof = match->autof; + if (autof == 0) + autof = ci->autof; + parts = autof >> 3; + autof &= 7; /* 4/ Determine device number. */ /* - If in mdadm.conf with std name, use that */ /* - UUID in /var/run/mdadm.map use that */ @@ -221,48 +232,61 @@ /* - Choose a free, high number. */ /* - Use a partitioned device unless strong suggestion not to. */ /* e.g. auto=md */ + + if(map_lock(&map)) + fprintf(stderr, "map_lock() failed!"); if (match && is_standard(match->devname, &devnum)) /* We have devnum now */; - else if ((mp = map_by_uuid(&map, info.uuid)) != NULL) - devnum = mp->devnum; else { - /* Have to guess a bit. */ - int use_partitions = 1; - char *np, *ep; - if ((autof&7) == 3 || (autof&7) == 5) - use_partitions = 0; - np = strchr(info.name, ':'); - if (np) - np++; - else - np = info.name; - devnum = strtoul(np, &ep, 10); - if (ep > np && *ep == 0) { - /* This is a number. Let check that it is unused. */ - if (mddev_busy(use_partitions ? (-1-devnum) : devnum)) + mp = map_by_uuid(&map, info.uuid); + if (mp != NULL) { + if (verbose >= 2) + fprintf(stdout, "\n devnum found from mapfile is: %d", devnum); + devnum = mp->devnum; + } + else { + /* Have to guess a bit. */ + int use_partitions = 1; + char *np, *ep; + if (autof == 4 || autof == 6) + use_partitions = 1; + else + use_partitions = 0; + np = strchr(info.name, ':'); + if (np) + np++; + else + np = info.name; + devnum = strtoul(np, &ep, 10); + if (ep > np && *ep == 0) { + /* This is a number. Let check that it is unused. */ + if (mddev_busy(use_partitions ? (-1-devnum) : devnum)) + devnum = -1; + } else devnum = -1; - } else - devnum = -1; - if (devnum < 0) { - /* Haven't found anything yet, choose something free */ - devnum = find_free_devnum(use_partitions); - - if (devnum == NoMdDev) { - fprintf(stderr, Name - ": No spare md devices!!\n"); - return 2; - } - } else - devnum = use_partitions ? (-1-devnum) : devnum; + if (devnum < 0) { + /* Haven't found anything yet, choose something free */ + devnum = find_free_devnum(use_partitions); + + if (devnum == NoMdDev) { + fprintf(stderr, Name + ": No spare md devices!!\n"); + map_unlock(&map); + return 2; + } + } else + devnum = use_partitions ? (-1-devnum) : devnum; + } } - mdfd = open_mddev_devnum(match ? match->devname : NULL, + mdfd = create_mddev_devnum(match ? match->devname : NULL, devnum, info.name, - chosen_name, autof >> 3); + chosen_name, parts); if (mdfd < 0) { fprintf(stderr, Name ": failed to open %s: %s.\n", chosen_name, strerror(errno)); + map_unlock(&map); return 2; } /* 5/ Find out if array already exists */ @@ -284,6 +308,7 @@ ": SET_ARRAY_INFO failed for %s: %s\b", chosen_name, strerror(errno)); close(mdfd); + map_unlock(&map); return 2; } sprintf(md, "%d.%d\n", st->ss->major, st->minor_version); @@ -295,9 +320,10 @@ sysfs_free(sra); if (ioctl(mdfd, ADD_NEW_DISK, &disk) != 0) { fprintf(stderr, Name ": failed to add %s to %s: %s.\n", - devname, chosen_name, strerror(errno)); + devname ? devname:"null", chosen_name, strerror(errno)); ioctl(mdfd, STOP_ARRAY, 0); close(mdfd); + map_unlock(&map); return 2; } sra = sysfs_read(mdfd, devnum, GET_DEVS); @@ -312,6 +338,7 @@ " --incremental reliably. Aborting.\n"); close(mdfd); sysfs_free(sra); + map_unlock(&map); return 2; } } else { @@ -338,6 +365,7 @@ sra->array.minor_version, st->ss->major, st->minor_version); close(mdfd); + map_unlock(&map); return 1; } sprintf(dn, "%d:%d", sra->devs->disk.major, @@ -350,6 +378,7 @@ chosen_name); close(mdfd); close(dfd2); + map_unlock(&map); return 2; } close(dfd2); @@ -362,6 +391,7 @@ ": unexpected difference between %s and %s.\n", chosen_name, devname); close(mdfd); + map_unlock(&map); return 2; } memset(&disk, 0, sizeof(disk)); @@ -380,15 +410,19 @@ fprintf(stderr, Name ": failed to add %s to %s: %s.\n", devname, chosen_name, strerror(errno)); close(mdfd); + map_unlock(&map); return 2; } } + /* 6/ Make sure /var/run/mdadm.map contains this array. */ map_update(&map, devnum, info.array.major_version, info.array.minor_version, info.uuid, chosen_name); + map_unlock(&map); + /* 7/ Is there enough devices to possibly start the array? */ /* 7a/ if not, finish with success. */ avail = NULL; @@ -423,6 +457,7 @@ return 0; } } + if (runstop > 0 || active_disks >= info.array.working_disks) { struct mdinfo *sra; /* Let's try to start it */ @@ -602,6 +637,7 @@ struct mdinfo *sd; for (sd = sra->devs ; sd ; sd = sd->next) { + char namebuf[100]; char dn[30]; int dfd; int ok; @@ -622,13 +658,36 @@ if (ok != 0) continue; st->ss->getinfo_super(st, &info); - if (md->devnum > 0) + if (md->devnum >= 0) path = map_dev(MD_MAJOR, md->devnum, 0); else path = map_dev(mdp, (-1-md->devnum)<< 6, 0); + if (path == NULL || + strncmp(path, "/dev/md/", 8) != 0) { + /* We would really like a name that provides + * an MD_DEVNAME for udev. + * The name needs to be unique both in /dev/md/ + * and in this mapfile. + * It needs to match watch -I or -As would come + * up with. + * That means: + * Check if array is in mdadm.conf + * - if so use that. + * find a unique name based on metadata name. + */ + struct mddev_ident_s *match = conf_match(&info, st); + if (match && match->devname && match->devname[0] == '/') { + path = match->devname; + if (path[0] != '/') { + strcpy(namebuf, "/dev/md/"); + strcat(namebuf, path); + path = namebuf; + } + } + } map_add(&map, md->devnum, st->ss->major, st->minor_version, - info.uuid, path ? : "/unknown"); + info.uuid, path); st->ss->free_super(st); break; } @@ -650,7 +709,8 @@ mddev_ident_t devs, mddev; int rv = 0; - map_read(&mapl); + map_lock(&mapl); + map_unlock(&mapl); devs = conf_get_ident(NULL); for (me = mapl ; me ; me = me->next) { @@ -658,7 +718,7 @@ mdu_array_info_t array; mdu_bitmap_file_t bmf; struct mdinfo *sra; - int mdfd = open_mddev_devnum(me->path, me->devnum, + int mdfd = create_mddev_devnum(me->path, me->devnum, NULL, path, 0); if (mdfd < 0) continue; diff -u mdadm-2.6.7.1/Assemble.c mdadm-2.6.7.1/Assemble.c --- mdadm-2.6.7.1/Assemble.c +++ mdadm-2.6.7.1/Assemble.c @@ -375,7 +375,7 @@ if (mdfd < 0) { /* So... it is up to me to open the device. * We create a name '/dev/md/XXX' based on the info in the - * superblock, and call open_mddev on that + * superblock, and call create_mddev on that */ mdu_array_info_t inf; char *c; @@ -394,7 +394,7 @@ int ret = asprintf(&mddev, "/dev/md/%s", c); assert(ret >= 0); } - mdfd = open_mddev(mddev, ident->autof); + mdfd = create_mddev(mddev, ident->autof); if (mdfd < 0) { st->ss->free_super(st); free(devices); diff -u mdadm-2.6.7.1/config.c mdadm-2.6.7.1/config.c --- mdadm-2.6.7.1/config.c +++ mdadm-2.6.7.1/config.c @@ -804,0 +805,70 @@ + +struct mddev_ident_s *conf_match(struct mdinfo *info, struct supertype *st) +{ + struct mddev_ident_s *array_list, *match; + int verbose = 0; + char *devname = NULL; + array_list = conf_get_ident(NULL); + match = NULL; + for (; array_list; array_list = array_list->next) { + if (array_list->uuid_set && + same_uuid(array_list->uuid, info->uuid, st->ss->swapuuid) + == 0) { + if (verbose >= 2 && array_list->devname) + fprintf(stderr, Name + ": UUID differs from %s.\n", + array_list->devname); + continue; + } + if (array_list->name[0] && + strcasecmp(array_list->name, info->name) != 0) { + if (verbose >= 2 && array_list->devname) + fprintf(stderr, Name + ": Name differs from %s.\n", + array_list->devname); + continue; + } + if (array_list->devices && devname && + !match_oneof(array_list->devices, devname)) { + if (verbose >= 2 && array_list->devname) + fprintf(stderr, Name + ": Not a listed device for %s.\n", + array_list->devname); + continue; + } + if (array_list->super_minor != UnSet && + array_list->super_minor != info->array.md_minor) { + if (verbose >= 2 && array_list->devname) + fprintf(stderr, Name + ": Different super-minor to %s.\n", + array_list->devname); + continue; + } + if (!array_list->uuid_set && + !array_list->name[0] && + !array_list->devices && + array_list->super_minor == UnSet) { + if (verbose >= 2 && array_list->devname) + fprintf(stderr, Name + ": %s doesn't have any identifying information.\n", + array_list->devname); + continue; + } + /* FIXME, should I check raid_disks and level too?? */ + + if (match) { + if (verbose >= 0) { + if (match->devname && array_list->devname) + fprintf(stderr, Name + ": we match both %s and %s - cannot decide which to use.\n", + match->devname, array_list->devname); + else + fprintf(stderr, Name + ": multiple lines in mdadm.conf match\n"); + } + return NULL; + } + match = array_list; + } + return match; +} diff -u mdadm-2.6.7.1/debian/changelog mdadm-2.6.7.1/debian/changelog --- mdadm-2.6.7.1/debian/changelog +++ mdadm-2.6.7.1/debian/changelog @@ -1,3 +1,37 @@ +mdadm (2.6.7.1-1ubuntu17) maverick; urgency=low + + * Rebuild a map file if it does not exist (LP: #550131) + * Scan and read the maps file correctly + * While rebuilding the mapfile (mdadm -Ir), if appropriate name is not found + in /dev/md, look for a name in mdadm.conf or the metadata. + * Allow an empty name rather than "unknown" for an array + * Identify md0 correctly - fixed typo (LP: #532960) + * Resolve issues like mdadm -Ss; mdadm: unable to open /dev/md/r1: "No such + file or directory" + * Report the correct superblock version. + * Correct the logic for partitions in md devices. Use /sys/dev links to map + major/minor to devnum in sysfs + * Changed the open_mddev_devnum() to create_mddev_devnum() - as its really + creating something in /dev. Also renamed for porting few changes from + mdadm-3.4.1 to mdadm-2.6.7.x + * If two devices are added via -I, mdadm can get badly confused. Fixed this. + * Fixed bugs in device name choosing. Fixed locking issues for the same. + Also added verbose messages when memory allocation failed while choosing a + device name. Also fixed the logic for chosing the partition number in + Incremental() with what is used in create_mddev(). (LP: #532960) + * For autoassembly to work properly the initramfs should set the hostname. + Copy the hostname binary and /etc/hostname in the initramfs so as to set + the hostname at boot time. (LP: #136252) + * At installation time hostname will not be set before the array is + created. Thus the uuid written on the root array created at Ubuntu + installation time will never correspond to that of the hostname. Due to + this auto assembly will never work. Add support to use the machine name + when the hostname is unspecified example at installation time. + (LP: #136252) (LP: #532960) (LP: #330399) + * Fix the error " /dev/MKDEV not found" + + -- Surbhi Palande Mon, 23 May 2011 14:24:29 +0300 + mdadm (2.6.7.1-1ubuntu16) maverick; urgency=low * debian/initramfs/hook: Added following code (invoked on update-initramfs) diff -u mdadm-2.6.7.1/debian/mdadm.postinst mdadm-2.6.7.1/debian/mdadm.postinst --- mdadm-2.6.7.1/debian/mdadm.postinst +++ mdadm-2.6.7.1/debian/mdadm.postinst @@ -22,13 +22,15 @@ && [ ! -e /dev/.static/dev/md15 ] \ && [ ! -e /dev/.devfsd ]; then - echo -n 'Generating array device nodes... ' >&2 - cd /dev - if /dev/MAKEDEV md >&2 >/dev/null; then - echo 'done.' >&2 - else - echo 'failed.' >&2 - fi + if [ -x /dev/MAKEDEV ]; then + echo -n 'Generating array device nodes... ' >&2 + cd /dev + if /dev/MAKEDEV md >&2 >/dev/null; then + echo 'done.' >&2 + else + echo 'failed.' >&2 + fi + fi fi DEBIANCONFIG=/etc/default/mdadm diff -u mdadm-2.6.7.1/debian/initramfs/hook mdadm-2.6.7.1/debian/initramfs/hook --- mdadm-2.6.7.1/debian/initramfs/hook +++ mdadm-2.6.7.1/debian/initramfs/hook @@ -51,6 +51,12 @@ # copy the binary as early as possible copy_exec /sbin/mdadm /sbin +# needed for autoassembly +copy_exec /bin/hostname /bin/ +if [ -f "/etc/hostname" ]; then + cp -p /etc/hostname $DESTDIR/etc/ +fi + # copy the udev rules for rules in 65-mdadm-blkid.rules 85-mdadm.rules; do cp -p /lib/udev/rules.d/$rules ${DESTDIR}/lib/udev/rules.d only in patch2: unchanged: --- mdadm-2.6.7.1.orig/util.c +++ mdadm-2.6.7.1/util.c @@ -433,8 +433,10 @@ int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s) { struct stat st; + if (S_ISLNK(stb->st_mode)) { - stat(name, &st); + if (stat(name, &st) != 0) + return 0; stb = &st; } only in patch2: unchanged: --- mdadm-2.6.7.1.orig/sysfs.c +++ mdadm-2.6.7.1/sysfs.c @@ -83,11 +83,34 @@ if (fstat(fd, &stb)) return NULL; if (ioctl(fd, RAID_VERSION, &vers) != 0) return NULL; - if (major(stb.st_rdev)==9) + if (major(stb.st_rdev) == MD_MAJOR) sprintf(sra->sys_name, "md%d", (int)minor(stb.st_rdev)); - else + else if (major(stb.st_rdev) == get_mdp_major()) sprintf(sra->sys_name, "md_d%d", (int)minor(stb.st_rdev)>>MdpMinorShift); + else { + /* must be an extended-minor partition. Look at the + * /sys/dev/block/%d:%d link which must look like + * ../../block/mdXXX/mdXXXpYY + */ + char path[30]; + char link[200]; + char *cp; + int n; + sprintf(path, "/sys/dev/block/%d:%d", major(stb.st_rdev), + minor(stb.st_rdev)); + n = readlink(path, link, sizeof(link)-1); + if (n <= 0) + return NULL; + link[n] = 0; + cp = strrchr(link, '/'); + if (cp) *cp = 0; + cp = strchr(link, '/'); + if (cp && strncmp(cp, "/md", 3) == 0) + strcpy(sra->sys_name, cp+1); + else + return NULL; + } } else { if (devnum >= 0) sprintf(sra->sys_name, "md%d", devnum); @@ -244,7 +267,7 @@ char fname[50]; int n; if (fstat(fd, &stb)) return 0; - if (major(stb.st_rdev) == 9) + if (major(stb.st_rdev) != get_mdp_major()) sprintf(fname, "/sys/block/md%d/md/component_size", (int)minor(stb.st_rdev)); else only in patch2: unchanged: --- mdadm-2.6.7.1.orig/mdassemble.c +++ mdadm-2.6.7.1/mdassemble.c @@ -55,7 +55,7 @@ #ifndef MDASSEMBLE_AUTO /* from mdopen.c */ -int open_mddev(char *dev, int autof/*unused */) +int create_mddev(char *dev, int autof/*unused */) { int mdfd = open(dev, O_RDWR, 0); if (mdfd < 0) @@ -86,7 +86,7 @@ } else for (; array_list; array_list = array_list->next) { mdu_array_info_t array; - mdfd = open_mddev(array_list->devname, array_list->autof); + mdfd = create_mddev(array_list->devname, array_list->autof); if (mdfd < 0) { rv |= 1; continue; only in patch2: unchanged: --- mdadm-2.6.7.1.orig/mdopen.c +++ mdadm-2.6.7.1/mdopen.c @@ -106,7 +106,7 @@ * If it now doesn't exist, we find a new md array and create the device. * Default ownership/mode comes from config file. */ -int open_mddev(char *dev, int autof) +int create_mddev(char *dev, int autof) { int mdfd; struct stat stb; @@ -268,7 +268,7 @@ } -int open_mddev_devnum(char *devname, int devnum, char *name, +int create_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name, int parts) { /* Open the md device with number 'devnum', possibly using 'devname', @@ -282,7 +282,7 @@ if (devname) strcpy(chosen_name, devname); - else if (name && strchr(name,'/') == NULL) { + else if (name && (strchr(name,'/') == NULL)) { char *n = strchr(name, ':'); if (n) n++; else n = name; if (isdigit(*n) && devnum < 0) only in patch2: unchanged: --- mdadm-2.6.7.1.orig/mapfile.c +++ mdadm-2.6.7.1/mapfile.c @@ -42,6 +42,7 @@ #include "mdadm.h" +#include int map_write(struct map_ent *mel) @@ -53,7 +54,7 @@ f = fopen("/var/run/mdadm/map.new", "w"); if (!f) { f = fopen("/var/run/mdadm.map.new", "w"); - subdir = 1; + subdir = 0; } if (!f) return 0; @@ -65,7 +66,7 @@ fprintf(f, "%d.%d ", mel->major, mel->minor); fprintf(f, "%08x:%08x:%08x:%08x ", mel->uuid[0], mel->uuid[1], mel->uuid[2], mel->uuid[3]); - fprintf(f, "%s\n", mel->path); + fprintf(f, "%s\n", mel->path?:""); mel = mel->next; } fflush(f); @@ -86,16 +87,67 @@ "/var/run/mdadm.map") == 0; } + +static int lfd = -1; +static int lsubdir = 0; +int map_lock(struct map_ent **melp) +{ + while (lfd < 0) { + struct stat buf; + 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; + if (lfd < 0) + return -1; + if (flock(lfd, LOCK_EX) != 0) { + close(lfd); + lfd = -1; + return -1; + } + if (fstat(lfd, &buf) != 0 || + buf.st_nlink == 0) { + /* The owner of the lock unlinked it, + * so we have a lock on a stale file, + * try again + */ + close(lfd); + lfd = -1; + } + } + if (*melp) + map_free(*melp); + map_read(melp); + return 0; +} + +void map_unlock(struct map_ent **melp) +{ + if (lfd >= 0) { + if (lsubdir) + unlink("/var/run/mdadm/map.lock"); + else + unlink("/var/run/mdadm.map.lock"); + close(lfd); + } + lfd = -1; +} + void map_add(struct map_ent **melp, int devnum, int major, int minor, int uuid[4], char *path) { struct map_ent *me = malloc(sizeof(*me)); - + if(!me) { + fprintf(stderr, "\n Could not allocate memory for map entry!"); + return; + } me->devnum = devnum; me->major = major; me->minor = minor; memcpy(me->uuid, uuid, 16); - me->path = strdup(path); + me->path = path ? strdup(path) : NULL; me->next = *melp; *melp = me; } @@ -113,14 +165,24 @@ f = fopen("/var/run/mdadm/map", "r"); if (!f) f = fopen("/var/run/mdadm.map", "r"); - if (!f) - return; + if (!f) { + RebuildMap(); + f = fopen("/var/run/mdadm/map", "r"); + if (!f) + f = fopen("/var/run/mdadm.map", "r"); + if (!f) { + fprintf(stderr, "\n Could not rebuild the map! "); + return; + } + } while (fgets(buf, sizeof(buf), f)) { - if (sscanf(buf, " md%1[p]%d %d.%d %x:%x:%x:%x %200s", + if (sscanf(buf, " %3[mdp]%d %d.%d %x:%x:%x:%x %200s", nam, &devnum, &major, &minor, uuid, uuid+1, uuid+2, uuid+3, path) == 9) { - if (nam[0] == 'p') + if (strncmp(nam, "md", 2) != 0) + continue; + if (nam[2] == 'p') devnum = -1 - devnum; map_add(melp, devnum, major, minor, uuid, path); } @@ -133,7 +195,8 @@ while (map) { struct map_ent *mp = map; map = mp->next; - free(mp->path); + if(mp->path) + free(mp->path); free(mp); } } @@ -154,15 +217,17 @@ mp->major = major; mp->minor = minor; memcpy(mp->uuid, uuid, 16); - free(mp->path); - mp->path = strdup(path); + if(mp->path) + free(mp->path); + mp->path = path ? strdup(path) : NULL; break; } if (!mp) map_add(&map, devnum, major, minor, uuid, path); - *mpp = NULL; rv = map_write(map); map_free(map); + if(mpp) + *mpp = NULL; return rv; } @@ -176,7 +241,8 @@ for (mp = *mapp; mp; mp = *mapp) { if (mp->devnum == devnum) { *mapp = mp->next; - free(mp->path); + if(mp->path) + free(mp->path); free(mp); } else mapp = & mp->next; only in patch2: unchanged: --- mdadm-2.6.7.1.orig/Detail.c +++ mdadm-2.6.7.1/Detail.c @@ -161,7 +161,7 @@ struct mdstat_ent *ms = mdstat_read(0, 0); struct mdstat_ent *e; int devnum = array.md_minor; - if (major(stb.st_rdev) != MD_MAJOR) + if (major(stb.st_rdev) == get_mdp_major()) devnum = -1 - devnum; for (e=ms; e; e=e->next) only in patch2: unchanged: --- mdadm-2.6.7.1.orig/mdadm.h +++ mdadm-2.6.7.1/mdadm.h @@ -276,6 +276,8 @@ extern void map_free(struct map_ent *map); extern void map_add(struct map_ent **melp, int devnum, int major, int minor, int uuid[4], char *path); +extern int map_lock(struct map_ent **melp); +extern void map_unlock(struct map_ent **melp); /* various details can be requested */ #define GET_LEVEL 1 @@ -499,6 +501,7 @@ extern char *conf_get_homehost(void); extern char *conf_line(FILE *file); extern char *conf_word(FILE *file, int allow_key); +extern struct mddev_ident_s *conf_match(struct mdinfo *info, struct supertype *st); extern void free_line(char *line); extern int match_oneof(char *devices, char *devname); extern void uuid_from_super(int uuid[4], mdp_super_t *super); @@ -523,8 +526,8 @@ extern char DefaultConfFile[]; -extern int open_mddev(char *dev, int autof); -extern int open_mddev_devnum(char *devname, int devnum, char *name, +extern int create_mddev(char *dev, int autof); +extern int create_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name, int parts); only in patch2: unchanged: --- mdadm-2.6.7.1.orig/Manage.c +++ mdadm-2.6.7.1/Manage.c @@ -125,9 +125,11 @@ devnum = minor(stb.st_rdev); else devnum = -1-(minor(stb.st_rdev)>>6); + map_lock(&map); map_delete(&map, devnum); map_write(map); map_free(map); + map_unlock(&map); } } return 0; only in patch2: unchanged: --- mdadm-2.6.7.1.orig/super0.c +++ mdadm-2.6.7.1/super0.c @@ -849,12 +849,15 @@ st->sb = NULL; if (strcmp(arg, "0") == 0 || strcmp(arg, "0.90") == 0 || - strcmp(arg, "0.91") == 0 || strcmp(arg, "default") == 0 || strcmp(arg, "") == 0 /* no metadata */ ) return st; + st->minor_version = 91; /* reshape in progress */ + if (strcmp(arg, "0.91") == 0) /* For dup_super support */ + return st; + st->minor_version = 9; /* flag for 'byte-swapped' */ if (strcmp(arg, "0.swap")==0 || strcmp(arg, "0.9") == 0) /* For dup_super support */ only in patch2: unchanged: --- mdadm-2.6.7.1.orig/mdadm.c +++ mdadm-2.6.7.1/mdadm.c @@ -948,7 +948,7 @@ } if (mode == MANAGE || mode == GROW) autof=1; /* Don't create */ - mdfd = open_mddev(devlist->devname, autof); + mdfd = create_mddev(devlist->devname, autof); if (mdfd < 0) exit(1); if ((int)ident.super_minor == -2) { @@ -981,7 +981,7 @@ if (homehost == NULL) homehost = conf_get_homehost(); - if (homehost && strcmp(homehost, "")==0) { + if (homehost == NULL || strcmp(homehost, "")==0) { if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) { sys_hostname[sizeof(sys_hostname)-1] = 0; homehost = sys_hostname; @@ -1012,7 +1012,7 @@ devlist->devname); rv |= 1; } else { - mdfd = open_mddev(devlist->devname, + mdfd = create_mddev(devlist->devname, array_ident->autof ? array_ident->autof : autof); if (mdfd < 0) rv |= 1; @@ -1044,7 +1044,7 @@ rv |= 1; continue; } - mdfd = open_mddev(dv->devname, + mdfd = create_mddev(dv->devname, array_ident->autof ?array_ident->autof : autof); if (mdfd < 0) { rv |= 1; @@ -1073,7 +1073,7 @@ } for (; array_list; array_list = array_list->next) { mdu_array_info_t array; - mdfd = open_mddev(array_list->devname, + mdfd = create_mddev(array_list->devname, array_list->autof ? array_list->autof : autof); if (mdfd < 0) { rv |= 1; @@ -1246,7 +1246,7 @@ e->dev); continue; } - mdfd = open_mddev(name, 1); + mdfd = create_mddev(name, 1); if (mdfd >= 0) { if (Manage_runstop(name, mdfd, -1, quiet?1:last?0:-1)) err = 1; @@ -1280,7 +1280,7 @@ case 'W': rv |= Wait(dv->devname); continue; } - mdfd = open_mddev(dv->devname, 1); + mdfd = create_mddev(dv->devname, 1); if (mdfd>=0) { switch(dv->disposition) { case 'R':