diff --git a/Start-kpartx-for-imsm-devices.patch b/Start-kpartx-for-imsm-devices.patch new file mode 100644 index 0000000..9ff2216 --- /dev/null +++ b/Start-kpartx-for-imsm-devices.patch @@ -0,0 +1,131 @@ +From 057fb70bf4e4b284cc06299853122273815b1d6e Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Fri, 7 Nov 2008 22:22:41 +1100 +Subject: [PATCH] Start kpartx for imsm devices. + +This probably wont get into mainline, but is need on SLES +to create partitions that the YaST partitioner has a chance +of recognising. + +Signed-off-by: NeilBrown +--- + Assemble.c | 4 +++- + Create.c | 3 +++ + Manage.c | 4 ++++ + mdadm.h | 1 + + super-intel.c | 2 +- + util.c | 25 +++++++++++++++++++++++++ + 6 files changed, 37 insertions(+), 2 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 20c4be7..c597526 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -1251,8 +1251,10 @@ int assemble_container_content(struct supertype *st, int mdfd, + fprintf(stderr, " (%d new)", working); + fprintf(stderr, "\n"); + } +- wait_for(chosen_name); + close(mdfd); ++ wait_for(chosen_name); ++ if (st->ss->match_metadata_desc("imsm")) ++ run_kpartx('a', chosen_name); + return 0; + /* FIXME should have an O_EXCL and wait for read-auto */ + } else { +diff --git a/Create.c b/Create.c +index 783ab09..4368107 100644 +--- a/Create.c ++++ b/Create.c +@@ -780,7 +780,10 @@ int Create(struct supertype *st, char *mddev, + ping_monitor(devnum2devname(st->container_dev)); + close(container_fd); + } ++ close(mdfd); + wait_for(chosen_name); ++ if (st->ss->match_metadata_desc("imsm")) ++ run_kpartx('a', chosen_name); + } else { + fprintf(stderr, Name ": not starting array - not enough devices.\n"); + } +diff --git a/Manage.c b/Manage.c +index 9424650..06f9e05 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -219,8 +219,12 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet) + if (mdi && + mdi->array.level > 0 && + is_subarray(mdi->text_version)) { ++ struct map_ent *me = map_by_devnum(&map, devnum); + /* This is mdmon managed. */ + close(fd); ++ ++ /* Delete any kpartx partitions */ ++ run_kpartx('d', me->path); + if (sysfs_set_str(mdi, NULL, + "array_state", "inactive") < 0) { + if (quiet == 0) +diff --git a/mdadm.h b/mdadm.h +index 2b34acf..9d819f9 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -833,6 +833,7 @@ extern char *devnum2devname(int num); + extern int devname2devnum(char *name); + extern int stat2devnum(struct stat *st); + extern int fd2devnum(int fd); ++extern void run_kpartx(char mode, char *dev); + + static inline int dev2major(int d) + { +diff --git a/super-intel.c b/super-intel.c +index a2b9bd2..5f06f30 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -636,7 +636,7 @@ static void brief_examine_super_imsm(struct supertype *st) + getinfo_super_imsm(st, &info); + fname_from_uuid(st, &info, nbuf1,'-'); + printf("ARRAY /dev/md/%.16s container=%s\n" +- " member=%d auto=mdp UUID=%s\n", ++ " member=%d auto=md UUID=%s\n", + dev->volume, nbuf + 5, i, nbuf1 + 5); + } + } +diff --git a/util.c b/util.c +index 8845a0f..f21d2bb 100644 +--- a/util.c ++++ b/util.c +@@ -1327,6 +1327,31 @@ void append_metadata_update(struct supertype *st, void *buf, int len) + } + #endif /* MDASSEMBLE */ + ++void run_kpartx(char mode, char *dev) ++{ ++ char buf[1024]; ++ char *cp; ++ ++ sprintf(buf, "/sbin/kpartx > /dev/null 2>&1 -%c '", mode); ++ ++ cp = buf + strlen(buf); ++ while (cp < buf+sizeof(buf)-10 && ++ *dev) { ++ if (*dev == '\'') { ++ *cp++ = '\''; ++ *cp++ = '\\'; ++ *cp++ = '\''; ++ /* *cp++ = '\''; */ ++ } ++ *cp ++ = *dev++; ++ } ++ *cp++ = '\''; ++ *cp++ = 0; ++ system(buf); ++} ++ ++ ++ + #ifdef __TINYC__ + /* tinyc doesn't optimize this check in ioctl.h out ... */ + unsigned int __invalid_size_argument_for_IOC = 0; +-- +1.5.6.5 + diff --git a/mdadm-auto-assemble.patch b/mdadm-auto-assemble.patch new file mode 100644 index 0000000..716d60c --- /dev/null +++ b/mdadm-auto-assemble.patch @@ -0,0 +1,110 @@ +diff --git a/Assemble.c b/Assemble.c +index c86a165..20c4be7 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -320,7 +320,7 @@ int Assemble(struct supertype *st, char *mddev, + + tmpdev->content = content->next; + if (tmpdev->content == NULL) +- tmpdev->used = 1; ++ tmpdev->used = 2; + + } else if (ident->container || ident->member) { + /* No chance of this matching if we don't have +@@ -396,12 +396,15 @@ int Assemble(struct supertype *st, char *mddev, + * looking. If the chosen member is active, skip. + */ + if (is_member_busy(content->text_version)) { ++ if (report_missmatch) ++ fprintf(stderr, Name ": member %s in %s is already assembled\n", ++ content->text_version, ++ devname); ++ tst->ss->free_super(tst); ++ tst = NULL; ++ content = NULL; + if (auto_assem) + goto loop; +- fprintf(stderr, Name ": member %s in %s is already assembled\n", +- content->text_version, +- devname); +- tst->ss->free_super(tst); + return 1; + } + st = tst; tst = NULL; +@@ -1202,8 +1205,10 @@ int assemble_container_content(struct supertype *st, int mdfd, + + sra = sysfs_read(mdfd, 0, GET_VERSION); + if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) +- if (sysfs_set_array(content, md_get_version(mdfd)) != 0) ++ if (sysfs_set_array(content, md_get_version(mdfd)) != 0) { ++ close(mdfd); + return 1; ++ } + if (sra) + sysfs_free(sra); + +@@ -1212,9 +1217,10 @@ int assemble_container_content(struct supertype *st, int mdfd, + working++; + else if (errno == EEXIST) + preexist++; +- if (working == 0) +- /* Nothing new, don't try to start */ ; +- else if (runstop > 0 || ++ if (working == 0) { ++ close(mdfd); ++ return 1;/* Nothing new, don't try to start */ ++ } else if (runstop > 0 || + (working + preexist) >= content->array.working_disks) { + + map_update(&map, fd2devnum(mdfd), +@@ -1246,15 +1252,18 @@ int assemble_container_content(struct supertype *st, int mdfd, + fprintf(stderr, "\n"); + } + wait_for(chosen_name); ++ close(mdfd); ++ return 0; + /* FIXME should have an O_EXCL and wait for read-auto */ +- } else ++ } else { + if (verbose >= 0) + fprintf(stderr, Name + ": %s assembled with %d devices but " + "not started\n", + chosen_name, working); +- +- return 0; ++ close(mdfd); ++ return 1; ++ } + } + #endif + +diff --git a/Create.c b/Create.c +index da05eed..783ab09 100644 +--- a/Create.c ++++ b/Create.c +@@ -780,11 +780,11 @@ int Create(struct supertype *st, char *mddev, + ping_monitor(devnum2devname(st->container_dev)); + close(container_fd); + } ++ wait_for(chosen_name); + } else { + fprintf(stderr, Name ": not starting array - not enough devices.\n"); + } + close(mdfd); +- wait_for(chosen_name); + return 0; + + abort: +diff --git a/Incremental.c b/Incremental.c +index ff8aa9a..474f78d 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -829,7 +829,6 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, + + err = assemble_container_content(st, mdfd, ra, runstop, + chosen_name, verbose); +- close(mdfd); + if (err) + return err; + } diff --git a/mdadm.changes b/mdadm.changes index c634021..b91a6b5 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri Nov 7 12:34:30 CET 2008 - nfbrown@suse.de + +- mdadm-auto-assemble.patch - fix various bugs in + auto-assemble +- start-kpartx-for-imsm-devices.patch - IMSM devices + need to be partitioned, and may programs including + YaST don't understand partitioned md devices, + so run kpartx to create 'dm' based partitions which + have a better chance for being understood + This relates to FATE#304220 + ------------------------------------------------------------------- Fri Nov 7 10:32:35 CET 2008 - ro@suse.de diff --git a/mdadm.spec b/mdadm.spec index 343567e..c7422e5 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -20,7 +20,7 @@ Name: mdadm Version: 3.0 -Release: 6 +Release: 7 %define ver 3.0-devel2 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq @@ -36,6 +36,8 @@ Patch1: super-intel-undefined-operation.patch Patch2: mdmon-ia64-clone.patch Patch3: mdadm-destdir.patch Patch4: mdadm-overflow.patch +Patch5: mdadm-auto-assemble.patch +Patch6: Start-kpartx-for-imsm-devices.patch Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm Source3: mdadmd @@ -60,6 +62,8 @@ Authors: %patch2 %patch3 %patch4 +%patch5 +%patch6 %build %{suse_update_config -f} @@ -148,6 +152,15 @@ rm -rf $RPM_BUILD_ROOT /lib/mkinitrd/scripts/boot-md.sh %changelog +* Fri Nov 07 2008 nfbrown@suse.de +- mdadm-auto-assemble.patch - fix various bugs in + auto-assemble +- start-kpartx-for-imsm-devices.patch - IMSM devices + need to be partitioned, and may programs including + YaST don't understand partitioned md devices, + so run kpartx to create 'dm' based partitions which + have a better chance for being understood + This relates to FATE#304220 * Fri Nov 07 2008 ro@suse.de - remove udev rule (conflicting with file in udev package) * Fri Nov 07 2008 ro@suse.de